akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int, int> iP;

bool isStraight(int a[]) {
  
  bool t[14];
  memset(t, false, sizeof(t));
  for(int i = 0; i < 5; i++) 
    t[a[i] - 1] = true;

  for(int i = 0; i <= 9; i++) {
    bool judge = true;
    for(int j = 0; j < 5; j++) {
      if(!t[(i + j) % 13]) judge = false;
    }
    if(judge) return true;
  }
  return false;
}

int main(){
  
  int a[5];
  while(~scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4])) {
    vector< int > S, sum(14, 0);
    for(int i = 0; i < 5; i++)
      sum[a[i]]++;
          
    int maxi = 0, mini = INF;
    for(int i = 1; i <= 13; i++) {
      if(sum[i]) {
        S.push_back(sum[i]);
        mini = min(mini, sum[i]);
        maxi = max(maxi, sum[i]);
      }
    }

    if(maxi >= 4) cout << "four card" << endl;
    else if(maxi == 3 && mini == 2) cout << "full house" << endl;
    else if(isStraight(a)) cout << "straight" << endl;
    else if(maxi == 3) cout << "three card" << endl;
    else if(maxi == 2 && mini == 1 && S.size() == 3) cout << "two pair" << endl;
    else if(maxi == 2) cout << "one pair" << endl;
    else cout << "null" << endl;
  }
}

Measured memory_bytes: 1224
N = int(input())
Alst = list(map(int, input().split()))
l = len(Alst)
Blst = [0]*l
k = 0
ans = 0
for i in range(l-1, 0, -1):
    k = (k + Alst[i])%(10**9 + 7)
    Blst[i] = k

for j in range(l-1):
    ans = (ans + Alst[j] * Blst[j+1])%(10**9 + 7)

print(ans)

Measured memory_bytes: 94284
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(pow(n, 0.5)) + 1):
        if n % k == 0:
            return False
    return True


def resolve():
    q = int(input())
    LR = [list(map(int, input().split())) for _ in range(q)]

    Lile_2017 = [0] * (10 ** 5 + 1)
    prime = set()
    for n in range(1, 10 ** 5 + 1):
        flg1, flg2 = False, False
        if n % 2 != 0:
            if n is not prime:
                if is_prime(n):
                    flg1 = True
                    prime.add(n)
                else:
                    flg1 = False
            else:
                flg1 = True

            if (n + 1) // 2 is not prime:
                if is_prime((n + 1) // 2):
                    flg2 = True
                    prime.add((n + 1) // 2)
                else:
                    flg2 = False
            else:
                flg2 = True

        if flg1 and flg2:
            Lile_2017[n - 1] = 1

    Ruiseki = [0]
    for i in range(1, 10 ** 5 + 1):
        Ruiseki.append(Ruiseki[-1] + Lile_2017[i - 1])

    for i in range(q):
        l, r = LR[i]
        print(Ruiseki[r] - Ruiseki[l - 1])


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 32892
import java.util.Scanner;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.Arrays;
import java.util.Stack;

public class Main {
		static  Scanner scn=new Scanner(System.in);
		static int count=0;
		public static void main(String[] args) {
			
			int n=scn.nextInt();
			String str=scn.next();
			char ch=str.charAt(0);
			int count=1;
			for(int i=1;i<n;i++)
			{
				if(str.charAt(i)==ch)
					count=count;
				else if(str.charAt(i)!=ch)
				{
					ch=str.charAt(i);
					count++;
				}
			}
			System.out.println(count);
		}
		public static int gcd(int a,int b)
		{
			if(a==0)return b;
			int l= gcd(b%a,a);
			return l;
		}

		
}


Measured memory_bytes: 25812
#ifndef _LOCAL
#	define NDEBUG
#	define dprint(...)
#endif

#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <assert.h>
using namespace std;
typedef long long ll;

struct Lead
{
	int i;
	ll step;
};

vector<int> brute(vector<int> a, ll k)
{
	int n = a.size();
	vector<int> ans;
	int last2[200111] = {0};
	
	for(ll j=0; j<n*k; ++j)
	{
		if(last2[a[j%n]])
		{
			int l = last2[a[j%n]]-1;
			for(int i=l; i<ans.size(); ++i)
				last2[ans[i]] = 0;
				
			ans.resize(l);
		}
		else
		{
			ans.push_back(a[j%n]);
			last2[a[j%n]] = ans.size();
		}
	}
	
	dprint(ans);
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	
	int n;
	ll k;
	cin >> n >> k;
	vector<int> a(n), next(n,-1);
	for(int i=0; i<n; ++i)
		cin >> a[i];

	int last[200111] = {0};
	for(int i=0; i<2*n; ++i)
	{
		if(last[a[i%n]])
		{
			next[(last[a[i%n]] - 1)%n] = i%n;
		}
		
		last[a[i%n]] = i+1;
	}
	dprint(next);
	
	vector<Lead> leads;
	leads.push_back({0,0});
	
	while(1)
	{
		int j = next[leads.back().i];
		int step = (j - leads.back().i);
		if(step <= 0)
			step += n;
		j = (j+1)%n;
		leads.push_back({j,leads.back().step + step+1});
		if(j == leads[0].i)
			break;
	}
	
	for(auto l : leads)
	{
		//dprint(l.i, l.step);
	}
	
	ll period = leads.back().step;
	leads.pop_back();
	ll nk = (n*k-1) % period;
	
	//ll last_step = 0;
	Lead last_lead = {-1,0};
	for(Lead x : leads)
	{
		if(nk < x.step)
			break;
		
		last_lead = x;
	}
	
	dprint(nk, period, last_lead.step);

	int last2[200111] = {0};
	vector<int> ans;
	//ans.push_back(a[last_lead.i]);
	for(ll i=last_lead.step; i<=nk; ++i)
	{
		int j = (last_lead.i + i - last_lead.step)%n;
		if(last2[a[j]])
		{
			int l = last2[a[j]]-1;
			for(int m=l; m<ans.size(); ++m)
				last2[ans[m]] = 0;
			ans.resize(l);
		}
		else
		{
			ans.push_back(a[j]);
			last2[a[j]] = ans.size();
		}
	}

	dprint(a);
	dprint(n, k);
	for(int i=0; i<ans.size(); ++i)
		cout << ans[i] << " ";
	cout << "\n";
	
	//assert(ans == brute(a, k));
	
	return 0;
}


Measured memory_bytes: 10220
#include<iostream>
using namespace std;

long long gcd(long long a, long long b){
 return a % b ? gcd(b, a % b) : b;
}
long long lcm(long long a, long long b){
 return a * b / gcd(a, b);
}

int main()
{
long long m,n,r,t;


cin>>m>>n;
t=lcm(m,n);

cout<<t<<endl;

return 0;
}

Measured memory_bytes: 256
# (+1,+2)をn回，(+2,+1)をm回とすると
#  n + 2m = X
# 2n +  m = Y でn,mが求まる．
# このとき答えは(n+m)Cn通り

def combination(n,r):
	"""
    高速な組み合わせの計算．
	nCrは必ず整数になるため分母を全部約分で1にしてから残った分子の積を求める．
	[参考]https://kadzus.hatenadiary.org/entry/20081211/1229023326
    """

	if n-r < r: r = n-r
	if r == 0: return 1
	if r == 1: return int(n)

	numerator = [i+1 for i in range(n-r, n)]
	denominator = [i+1 for i in range(r)]

	for p in range(2,r+1):
		pivot = denominator[p-1]
		if pivot > 1:
			offset = (n-r)%p
			for k in range(p-1, r, p):
				numerator[k-offset] /= pivot
				denominator[k] /= pivot
	
	ans = 1
	for i in range(r):
		if numerator[i] > 1:
			ans *= numerator[i]
			ans %= 1e9+7
	
	return int(ans)

X,Y = map(int, input().split())

if (X+Y)%3 != 0:
	ans = 0
else:
	n = int((2*Y-X)/3)
	m = int(Y-2*n)
	if n<0 or m<0:
		ans = 0
	else:
		ans = combination(n+m, n)

print(ans)

Measured memory_bytes: 44056
#include<cstdio>
long long d[500005];
long long up[500005];
long long x[500005];

long long abs(long long u){ return u>0?u:-u; }

int main(){
    int n; long long D;
    scanf("%d%lld",&n,&D);
    for(int i = 1; i <= n; i++) scanf("%lld",&d[i]);
    up[n+1] = 0;
    //count i
    for(int i = n; i >= 1; i--){
        long long mid = d[i]/2;
        if(up[i+1]>=mid) up[i] = up[i+1]+d[i];
        else up[i] = up[i+1];
    }
    x[0] = D;
    for(int i = 1; i <= n; i++){
        x[i] = x[i-1];
        long long offer = abs(x[i-1]-d[i]);
        if(x[i]>offer) x[i] = offer;
    }
    int q;
    scanf("%d",&q);
    while(q--){
        int p;
        scanf("%d",&p);
        long long u = x[p-1];
        if(u==0) printf("NO\n");
        else{
            if(up[p+1]>=u) printf("NO\n");
            else printf("YES\n");
        }
    }
    return 0;
}


Measured memory_bytes: 13792
n = int(input())
a = list(map(int,input().split()))

tot = sum(a)
ans = -1
dif = 10**6
for i,ai in enumerate(a):
    dif_i = abs(ai*n - tot)
    if(dif > dif_i):
        dif = dif_i
        ans = i
print(ans)

Measured memory_bytes: 61704
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>
using namespace std;

/* debug macros */
#ifdef WAFDAYO
#define DBG_PRINT(s, t, u) { std::cerr << s << " \e[2m=\e[m \e[1m" << t << "\e[m" << u; }
#else
#define DBG_PRINT(s, t, u) {}
#endif
#define dbg(x) DBG_PRINT(#x, x, std::endl)
#define dbgc(x) DBG_PRINT(#x, x, ", ")
#define idbg(x, i) DBG_PRINT(#x "[" << i << "]", x[i], std::endl)
#define idbgc(x, i) DBG_PRINT(#x "[" << i << "]", x[i], ", ")

/* IO utilities */
struct read_item { read_item() {}; template<class T> operator T() { T t; std::cin >> t; return t; } };

/* types and constants */
typedef long long i64;
//const i64 inf = (i64)1.05e18;
const int inf = (int)1.05e9;

int main() {

	const int n = read_item();
	const int m = read_item();
	vector<int> ds(n);
	vector<vector<pair<int,int>>> g(n);
	for(int i = 0; i < n; i++) {
		const int d = read_item();
		ds[i] = d;
	}
	for(int i = 0; i < m; i++) {
		const int u = read_item();
		const int v = read_item();
		g[u - 1].push_back({v - 1, i});
		g[v - 1].push_back({u - 1, i});
	}

	vector<int> color(n, -1);
	vector<int> length(m, 0);

	vector<int> index(n);
	iota(index.begin(), index.end(), 0);
	sort(index.begin(), index.end(),
		[&](const int l, const int r){ return ds[l] < ds[r]; });

	for(auto v : index) {

		dbgc(ds[v]); dbg(v);

		bool ok = false;
		for(auto e : g[v]) {
			if(ds[e.first] <= ds[v]) {
				ok = true;
			}
		}

		if(!ok) {
			printf("-1\n");
			return 0;
		}

		int uncolored = -1;

		for(auto e : g[v]) {

			const int w = e.first;
			const int e_idx = e.second;

			if(ds[w] > ds[v]) {
				continue;
			}

			length[e_idx] = ds[v];
			if(color[w] >= 0) {
				if(color[v] == -1) {
					color[v] = 1 - color[w];
				}
			} else {
				assert(ds[w] == ds[v]);
				uncolored = w;
			}
		}

		if(color[v] == -1) {
			assert(uncolored != -1);
			color[v] = 0;
			color[uncolored] = 1;
		}
	}

	for(int i = 0; i < n; i++) {
		int mini = inf;
		for(auto& e : g[i]) {
			if(color[e.first] != color[i]) {
				mini = min(mini, length[e.second]);
			}
		}
		assert(mini == ds[i]);
	}

	for(int i = 0; i < n; i++) {
		printf("%c", color[i] == 1 ? 'W' : 'B');
	}
	printf("\n");
	for(int i = 0; i < m; i++) {
		printf("%d\n", length[i]);
	}

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string e;
int main(){
    q a,b,c,o,d,z,x;
    cin>>a>>b;
    o=(int)(a+b)/2;
    c=a-o;
    d=b-o;
    z=abs(c);
    x=abs(d);
    if(x==z){cout<<o;}else{cout<<"IMPOSSIBLE";}
return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main(){
	int a,b,c;
    cin >> a >> b >> c;
    if(a==b){
      if(b==c)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    }
    else{
      if(b==c)
        cout << 2 << endl;
      else if(c==a)
        cout << 2 << endl;
      else
        cout << 3 << endl;  
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long[] ar = new long[n];
        for (int i = 0; i < n; i++) {
            ar[i] = sc.nextLong();
        }
        long[] dp = new long[n];
        for (int i = 1; i < n; i++) {
            dp[i] = Math.min(dp[i-1] + a * (ar[i] - ar[i-1]),
                    dp[i-1] + b);
        }
        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 49788
Sa = list(raw_input())
Sb = list(raw_input())
Sc = list(raw_input())

#Sa,Sb,Sc = for x in range(3):list(raw_input())

x = Sa[0]
del Sa[0]

flag = 0
while(flag == 0):
    if x in 'a':
        if len(Sa)>0:
            x = Sa[0]
            del Sa[0]
        else:
            flag = 1
    elif x in 'b':
        if len(Sb)>0:
            x = Sb[0]
            del Sb[0]
        else:
            flag = 2
    elif x in 'c':
        if len(Sc)>0:
            x = Sc[0]
            del Sc[0]
        else:
            flag = 3

if flag == 1:
    print 'A'
elif flag == 2:
    print 'B'
elif flag == 3:
    print 'C'


Measured memory_bytes: 2696
#include <bits/stdc++.h>

using namespace std;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	
	int n;
	cin >>n;
	VI a(n);
	vector<ll> ds(n+1);
	rep(i,n) cin >>a[i];
	a.push_back(0);
	//n++;
	ll ans =0;
	int cr=0;
	rep(i,n){
		ds[i+1] = ds[i] + abs(a[i] - cr);
		cr=a[i];
	}
	//for(auto x :ds) printf("%lld, ",x); puts("");
	
	rep(i,n){
		ll ans =0;
		if(i==0){
			ans += abs(a[1]);
			ans += ds[n] - ds[2];
			ans += abs(a[n-1]);
		}else if(i==n-1){
			ans += ds[n-1];
			ans += abs(a[n-2]);
		}else{
			ans +=ds[i];
			ans += abs(a[i-1] - a[i+1]);
			ans +=ds[n] - ds[i+2];
			ans +=abs(a[n-1]);
		}
		
		
		cout << ans <<"\n";
	}
	
	
	
	return 0;
	
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)x.size()
//#define int ll

const int N = 1e5 + 10;
bool p[N];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	vector<ll> cubes;
	for (int i = 2;; i++) {
		if (i * 1ll * i * i > 1e10) {
			break;
		}
		cubes.pb(i * 1ll * i * i);
	}
	for (int i = 2; i <= 1e5; i++) {
		if (!p[i] && i * 1ll * i <= 1e5) {
			for (int j = i * i; j <= 1e5; j += i) {
				p[j] = true;
			}
		}
	}
	vector<int> primes;
	for (int i = 2; i <= 1e5; i++) {
		if (!p[i]) {
			primes.pb(i);
		}
	}
	int n;
	cin >> n;
	bool was_cube = false;
	map<vector<pair<ll, int>>, int> calc;
	map<ll, vector<pair<ll, int>>> lol;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		vector<pair<ll, int>> cur;
		for (auto it : cubes) {
			if (it > x) {
				break;
			}
			while (x % it == 0) {
				x /= it;
			}
		}
		ll wasx = x;
		if (lol.find(x) != lol.end()) {
			cur = lol[x];
		}
		else {
			for (auto it : primes) {
				if (it * 1ll * it > x) {
					break;
				}
				if (x % it == 0) {
					x /= it;
					if (x % it == 0) {
						x /= it;
						cur.pb({it, 2});
					}
					else {
						cur.pb({it, 1});
					}
				}
			}
			if (x > 1) {
				cur.pb({x, 1});
			}
		}
		lol[wasx] = cur;
		if (cur.empty()) {
			was_cube = true;
		}
		else {
			calc[cur]++;
		}
	}
	int ans = 0;
	map<vector<pair<ll, int>>, bool> used;
	for (auto it : calc) {
		vector<pair<ll, int>> antiit;
		for (auto kek : it.F) {
			antiit.pb({kek.F, 3 - kek.S});
		}
		if (calc.find(antiit) != calc.end()) {
			used[it.F] = true;
			used[antiit] = true;
			ans += max(it.S, calc[antiit]);
		}
		else {
			ans += it.S * 2;
		}
	}
	ans /= 2;
	if (was_cube) {
		ans++;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 30996
#include <iostream>
using namespace std;

int main() {
	int n;
	int final =0;
	cin>>n;
	int max=0;
	char arr[101];
	for(int i=0; i<n; i++)
	cin>>arr[i];
	
	for(int i=0; i<n; i++)
	{
		if(arr[i]=='I')
		max= max + 1;
		
		else max= max-1;

		if(max>final)
		final = max;
	}
	cout<<final;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
#include <cstdlib>

using namespace std;
int main(){
  int n, m;
  string s[110], t[110];
  cin >> n;
  for(int i=0; i<n; i++) cin >> s[i];
  cin >> m;
  for(int i=0; i<m; i++) cin >> t[i];

  int max_p=0;
  for(int i=0; i<n; i++){
    int plus=0;
    int minus=0;
    string str = s[i];
    for(int k=0; k<n; k++){
      if(str==s[k]) plus++;
    }
    for(int j=0; j<m; j++){
      if(str == t[j]) minus++;
    }
    if((plus-minus) > max_p) max_p = plus - minus;
  }
  cout << max_p << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
using P = pair<int,int>;

const int dx[4]={0,-1,0,1};
const int dy[4]={-1,0,1,0};
int h,w;
int bfs(const vector<string> &s,int x,int y){
    vector<vector<int>> d(h,vector<int>(w,-INF));
    queue<P> q;
    q.push(make_pair(x,y));
    d[x][y] = 0;
    int ma=0;
    while(!q.empty()){
        int xi = q.front().first;
        int yi = q.front().second;
        q.pop();
        rep(i,4){
            int nx = xi + dx[i];
            int ny = yi + dy[i];
            if(nx>=0 && nx<h && ny>=0 && ny<w && d[nx][ny]==-INF &&s[nx][ny]=='.'){
                q.push(make_pair(nx,ny));
                d[nx][ny] = d[xi][yi] + 1;
                ma = max(ma,d[nx][ny]);
                //cout << d[nx][ny] << endl;
            }
        }
    }
    return ma;
}


int main(){
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ma=0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.'){
                int t = bfs(s,i,j);
                ma = max(ma,t);
                //cout << "t= " << t << endl;
            }
        }
    }
    cout << ma << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main(void){
    bool appear[1000] = {};
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N){
        if(A[i] != 0){
            appear[A[i]] = true;
            if(i+1 < N) appear[A[i]*10 + A[i+1]] = true;
            if(i+2 < N) appear[A[i]*100 + A[i+1]*10 + A[i+2]] = true;
        }
        else appear[0] = true;
    }
    rep(i, 1000){
        if(!appear[i]){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3112
package main

import (
	"fmt"
	"io"
	"os"
)

const Mod = 1000000007

func main() {
	r := NewScannerSize(os.Stdin, 1000*1000+2000)
	h, w := r.Int(), r.Int()

	grid := make([][]byte, h)
	for i := 0; i < h; i++ {
		grid[i] = r.UnsafeBytes()
	}

	var dp [1001][1001]int
	dp[0][0] = 1

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if grid[i][j] != '.' {
				continue
			}
			if i == 0 && j == 0 {
				dp[i][j] = 1
				continue
			}
			if i == 0 {
				dp[i][j] = dp[i][j-1]
				continue
			}
			if j == 0 {
				dp[i][j] = dp[i-1][j]
				continue
			}

			dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % Mod
		}
	}

	fmt.Println(dp[h-1][w-1])
}

// generated by https://github.com/murosan/gollect

type Scanner struct {
	r     io.Reader
	buf   []byte
	delim byte
	size, eof,
	start, end int
}

func NewScannerSize(r io.Reader, size int) *Scanner {
	return &Scanner{
		r:     r,
		buf:   make([]byte, size),
		delim: ' ',
		size:  size, start: size, end: size,
	}
}

func (s *Scanner) UnsafeBytes() []byte { return s.bytes() }

func (s *Scanner) Int() int { return ParseInt(s.bytes()) }

func (s *Scanner) bytes() []byte { b, _ := s.next(); return b }
func (s *Scanner) next() (b []byte, size int) {
	for n := 0; ; {
		for i := s.end; i < s.size; i++ {
			if s.buf[i] == s.delim || s.buf[i] == '\n' || i == s.eof {
				b, size = s.buf[s.start:i], i-s.start
				s.start, s.end = i+1, i+1
				return
			}
		}
		s.end = s.size
		if n++; n == 2 {
			panic("lack of buffer size")
		}
		s.read()
	}
}
func (s *Scanner) read() {
	copy(s.buf, s.buf[s.start:s.end])
	s.end -= s.start
	s.start = 0
	n, _ := s.r.Read(s.buf[s.end:])
	s.eof = s.end + n
}

func ParseInt(b []byte) (n int) {
	var i int
	if b[0] == '-' {
		i++
	}
	for ; i < len(b); i++ {
		n *= 10
		n += int(b[i] - '0')
	}
	if b[0] == '-' {
		return -n
	}
	return
}


Measured memory_bytes: 9472
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 2005
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
bool s[MN][MN];
char ch[MN];
int s1[MN][MN],s2[MN][MN],f[MN][MN],sum[MN][MN];
int n,m,q,xa,ya,xb,yb,res;
int main()
{
	n=in();m=in();q=in();
	for (int i=1;i<=n;++i){
		scanf("%s",ch);
		for (int j=0;j<m;++j) s[i][j+1]=ch[j]-'0';
	}
	for (int i=1;i<=n;++i){
		for (int j=1;j<=m;++j){
			s1[i][j]=s1[i][j-1]+(s[i][j]&&s[i-1][j]);
			s2[i][j]=s2[i-1][j]+(s[i][j]&&s[i][j-1]); 
			f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(s[i][j]&&s[i-1][j])+(s[i][j]&&s[i][j-1]);
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(s[i][j]);
		}
	}
	for (int i=1;i<=q;++i){
		xa=in();ya=in();xb=in();yb=in();
		res=sum[xb][yb]-sum[xa-1][yb]-sum[xb][ya-1]+sum[xa-1][ya-1];
		res-=f[xb][yb]-f[xa-1][yb]-f[xb][ya-1]+f[xa-1][ya-1];
		res+=s1[xa][yb]+s2[xb][ya]-s1[xa][ya-1]-s2[xa-1][ya];printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 68480
#include <bits/stdc++.h> 

#define int long long
//#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e18;
const int MOD = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N; cin >> N;
    vvi A(N, vi(N)); REP(i, N) REP(j, N) cin >> A[i][j];

    REP(k, N)
    {
        REP(i, N)
        {
            REP(j, N)
            {
                if(chmin(A[i][j], A[i][k]+A[k][j]))
                {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }

    int ans = 0;
    REP(i, N)
    {
        for(int j = i+1; j < N; j++)
        {
            bool plus = true;
            REP(k, N)
            {
                if(k == i || k == j) continue;
                if(A[i][j] == A[i][k]+A[k][j]) plus = false;
            }
            if(plus) ans += A[i][j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, count;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
       cin >> s.at(i);
    }
    int m;
    cin >> m;
    vector<string> t(m);
    for (int i = 0; i < m; i++) {
        cin >> t.at(i);
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
        int count = 0;
        for (int j = 0; j < n; j++) {
            if (s.at(i) == s.at(j)) {
                count++;
            }
        }
        for (int j = 0; j < m; j++) {
            if (s.at(i) == t.at(j)) {
                count--;
            }
        }
        sum = max(sum, count);
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int A[200100];
int cnt[200010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    
    rep(i, N) cin >> A[i];
    rep(i, N) cnt[A[i]]++;
    int ans = 0;
    rep(i, N + 1) {
        ans += cnt[i] * (cnt[i] - 1)/2;
    }
    rep(i, N) {
        int loss = max(0LL, cnt[A[i]] - 1);
        cout << ans - loss << endl;
    }
    

    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <ii> vii;
typedef vector <vii> vvii;
#define endl '\n'
#define PB push_back
#define MP make_pair
#define fr first
#define sc second
#define OO (1000000000)         // ToDo
#define EPS (1e-9)              // ToDo
#define MOD (1000000007)        // ToDo
#define all(v) ((v).begin()),((v).end())
#define WT(x) cout<< #x <<" = "<<"\""<< (x) <<"\""<<endl
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
void read_file(bool outToFile = true){
#ifdef LOCAL_TEST
    freopen("in", "rt", stdin);
    if(outToFile)
    freopen("out", "wt", stdout);
#endif
}
//
ll K;
//
int main()
{
    read_file();
    while(scanf("%lld", &K) != -1)
    {
        ll n = 50;
        ll q = K/n;
        ll r = K%n;
        ll a = q + n - 1;
        
        printf("%lld\n", n);
        for(int i=0; i<r; i++)
            printf("%lld ", a + n - r + 1);
        for(int i=0; i<n-r; i++)
            printf("%lld%c", a - r, " \n"[i == n-r-1]);
    }
}


Measured memory_bytes: 256
import numpy as np

N, X = list(map(int, input().split()))
x = np.array(list(map(int, input().split())))
x = np.abs(X - x)

for i in range(N-1):
    a, b = x[i:i+2]
    while b > 0:
        a, b = b, a % b
    x[i+1] = a

print(x[-1])


Measured memory_bytes: 23244
/*****************************
 Filename: dkljlkfd.cpp
 Author: hbb
 Create: 2020-04-05 13:36:56
*****************************/
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = INT_MAX >> 1;
typedef long long int LL;

int n, k, c;
char s[maxn];
int l[maxn], r[maxn];

int main(){
	scanf("%d %d %d", &n, &k, &c);
	scanf("%s", s + 1);
	memset(l, 0, sizeof(l));
	memset(r, 0, sizeof(r));
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		if(s[i] == 'o'){
			l[i] = ++cnt;
			i += (c);
		}
	}
	cnt = k;
	for(int i = n; i >= 1; i--){
		if(s[i] == 'o'){
			r[i] = cnt--;
			i -= (c);
		}
	}

	for(int i = 1; i <= n; i++){
		if(r[i] == l[i] && r[i] > 0){
			printf("%d\n", i);
		}
	}
}

Measured memory_bytes: 9728
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-09 22:15:28
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#include<iostream>
#include<string>
const int N=6010;
int n,v[N],id[N][2],c[2],p[N];
char s[N];
std::string f[N];
int main()
{
	n=read()*2; scanf("%s",s+1);
	fr(i,1,n){ s[i]-='a'; id[++c[s[i]]][s[i]]=i; }
	fr(i,1,n/2){ p[id[i][0]]=id[i][1]; p[id[i][1]]=id[i][0]; }
//	fr(i,1,n/2) printf("%d %d\n",id[i][0],id[i][1]);
	fd(i,n,1)
	{
		if(p[i]>i)
		{
			if(s[i]<s[p[i]]) f[i]="ab"+f[p[i]+1];
			else
			{
				int j=i;
				for(int k=i;k<=j;k++)
					if(s[k]){ f[i]+='b'; v[p[k]]=1; j=p[k]; }
					else if(v[k]) f[i]+='a';
				fr(k,i,j) v[k]=0;
				f[i]+=f[j+1];
			}
		}
		f[i]=std::max(f[i],f[i+1]);
	}
	std::cout<<f[1]<<std::endl;
	return 0;
}

Measured memory_bytes: 14720
import math
a, b, x = map(int, input().split())
x /= a
half = a * b // 2
# 引数の角度で入る水の量を計算する
def check(theta):
    if x <= half:
        theta = math.radians(theta)
        return b ** 2 / 2 * math.tan(theta)
    else:
        theta = math.radians(90-theta)
        return a * b - (0.5 * a ** 2 * math.tan(theta))

l, r = 0, 90
for _ in range(10000):
    mid = (l+r) / 2
    if check(mid) > x:
        r = mid
    else:
        l = mid
    
print(90-l)




Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long
#define MAX 1000000010

signed main() {
    int n; cin >> n;
    vector<int> val, cnt;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        auto itr = find(val.begin(), val.end(), a);
        size_t idx = distance(val.begin(), itr);
        if(idx == val.size()) {
            val.push_back(a);
            cnt.push_back(1);
        }
        else {
            cnt[idx]++;
        }
    }
  
    int ans = 0;
    for(int i = 0; i < val.size(); i++) {
        if(cnt[i] > val[i]) {
            ans += cnt[i] - val[i];
        }
        else if(val[i] > cnt[i]) {
            ans += cnt[i];
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int N;
  cin >> N;
  cout << ((1 + N) * N) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

struct edge { int to, cap, cost, rev;};
const int V = 2002;
vector<edge> G[V];
int dist[V];
int prevv[V], preve[V];

void add_edge(int from, int to, int cap, int cost){
	edge e1={to, cap, cost, int(G[to].size())};
    G[from].push_back(e1);
	edge e2={from, 0, -cost, int(G[from].size() - 1)};
    G[to].push_back(e2);
}

const int INF=INT_MAX/10;
int min_cost_flow(int s, int t, int f){
    int res = 0;
    while(f > 0){
        fill(dist, dist + V, INF);
        dist[s] = 0;
		bool update = true;
		while(update){
			update=false;
			REP(v,V){
				if(dist[v]==INF)continue;
				REP(i,G[v].size()){
					edge&e=G[v][i];
					if(e.cap>0&&dist[e.to]>dist[v]+e.cost){
						dist[e.to]=dist[v]+e.cost;
						prevv[e.to]=v;
						preve[e.to]=i;
						update=true;
					}
				}
			}
		}

		if(dist[t] == INF) {
			return INF;
		}
        
        int d = f;
        for(int v = t; v != s; v = prevv[v]){
            d = min(d, G[prevv[v]][preve[v]].cap);
		}
        f -= d;
        res += d * dist[t];
        for(int v = t; v != s; v = prevv[v]){
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}

const int start=2000,goal=2001,gap=1000;
int main(){
	int n;
	while(cin>>n,n){
		REP(i,V){
			G[i].clear();
		}

		vi s(n),e(n),w(n);
		REP(i,n){
			cin>>s[i]>>e[i]>>w[i];
		}
		REP(i,n){
			add_edge(start,i,1,0);
			add_edge(i+gap,goal,1,0);
			add_edge(i,i+gap,1,-w[i]);
			REP(j,n){
				if(e[i]<s[j]){
					add_edge(i+gap,j,1,0);
				}
			}
		}

		int ans=min_cost_flow(start,goal,2);
		cout<<-ans<<endl;
	}
}

Measured memory_bytes: 23912
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Edge{ // sとs+1を繋ぐ辺
    long long int cost;
    bool PorQ; // true:P false:Q

    bool operator <(const Edge& another) const{
        return cost > another.cost;
    }
};

int main()
{
    vector<Edge> edge;
    long long int total = 0;

    int W,H; cin >> W >> H;
    for(int i=0;i<W;++i){
        int buff; cin >> buff;
        edge.push_back({buff,true});
    }
    for(int i=0;i<H;++i){
        int buff; cin >> buff;
        edge.push_back({buff,false});
    }

    // コスト降順にソート
    sort(edge.begin(),edge.end());

    while(!edge.empty()){
        if(edge.back().PorQ){
            total += (edge.back().cost * (H+1));
            --W;
            edge.pop_back();
        }else{
            total += (edge.back().cost * (W+1));
            --H;
            edge.pop_back();
        }
    }
    cout << total << endl;
    return 0;
}



Measured memory_bytes: 4464
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define cont continue
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 987654321;


int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false); 
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
} 

Measured memory_bytes: 3648
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cout << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cout<<endl; 
	}
	eni(!=) cout << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n;
		cin >> n;
		ll int dp[n + 1][4];
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		for(ll int i = 1; i <= n; i++)
		{
			dp[i][0] = (dp[i - 1][0] * 8) % hell;
			dp[i][1] = (dp[i - 1][0] + dp[i - 1][1] * 9) % hell;
			dp[i][2] = (dp[i - 1][0] + dp[i - 1][2] * 9) % hell;
			dp[i][3] = (dp[i - 1][3] * 10 + dp[i - 1][1] + dp[i - 1][2]) % hell;
		}
		cout << dp[n][3] << endl;
	}
	return 0;
}

Measured memory_bytes: 34808
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;

string J(string s, int len) {
  return s.substr(1) + s[0];
}

string C(string s, int len) {
  return s[len-1] + s.substr(0,len-1);
}

string E(string s, int len) {
  if (len % 2 == 1) {
    return s.substr(len/2+1) + s[len/2] + s.substr(0, len/2);
  } else {
    return s.substr(len/2) + s.substr(0, len/2);
  }
}

string A(string s, int len) {
  reverse(s.begin(), s.end());
  return s;
}

string P(string s, int len) {
  for (int i = 0; i < len; i++) {
    if (!isdigit(s[i])) continue;
    if (s[i] == '9') s[i] = '0';
    else s[i]++;
  }
  return s;
}

string M(string s, int len) {
  for (int i = 0; i < len; i++) {
    if (!isdigit(s[i])) continue;
    if (s[i] == '0') s[i] = '9';
    else s[i]--;
  }
  return s;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string messengers, crypt;
    cin >> messengers >> crypt;
    int len = crypt.length();
    reverse(messengers.begin(), messengers.end());
    for (char m : messengers) {
      if (m == 'J') {
        crypt = C(crypt, len);
      } else if (m == 'C') {
        crypt = J(crypt, len);
      } else if (m == 'E') {
        crypt = E(crypt, len);
      } else if (m == 'A') {
        crypt = A(crypt, len);
      } else if (m == 'P') {
        crypt = M(crypt, len);
      } else if (m == 'M') {
        crypt = P(crypt, len);
      }
    }
    cout << crypt << endl;
  }
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int R[N],L[N];
int cnt[N];



int main(){
    string s;
    cin>>s;
    int n= s.length();
    //cout<<"\nn="<<n<<endl;
    int pos;
	for(int i=1;i<=n;i++){
        int idx= i-1; ///idx= string er idx
		if(s[idx]=='R')pos=i;
		R[i]=pos;
	}
	for(int i=n; i>=1; i--){
        int idx= i-1;
        if(s[idx]=='L') pos= i;
        L[i]= pos;
	}


    for(int i=1; i<=n; i++){
        int idx= i-1; ///idx = string er index
        int r, l;
        if(s[idx]=='L'){
            /***
            then "RL" er position koi?
            simply R[i] = RL er R er position;
            so R[i]+1= RL er L er position
            */
            r= R[i];
            l= r+1;
            ///for i= 14: r=11, l=12

        }
        else if(s[idx]=='R'){
            l= L[i];
            r= l-1;
        }
        if(i%2==r%2){
                ///then i and r er parity same ; so r barbe
            cnt[r]++;
        }else{
            cnt[l]++;
        }

    }
    //cout<<"\nCnt:"; 
    for(int i=1; i<=n; i++) cout<<cnt[i]<<" ";
    cout<<endl;

    return 0;

}





Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <vector>
#include<bits/stdc++.h> 
#include<cstring>
#include<utility>
#define mod 1000000007
using namespace std;
 
int main()
{
   int h; int w;
   cin>>h>>w;
   	vector<vector<char> > v;
   	for(int i =0;i<h;i++)
   	{
   		vector<char> temp;
   		for(int j =0;j<w;j++)
   		{
   			char x;
   			cin>>x;
   			temp.push_back(x);
		   }
		   v.push_back(temp);
	   }
   	int dp[h][w];
   	memset(dp, 0, sizeof(dp));
   	for(int i = 0;i<h;i++ )
   	{
   		for(int j =0;j<w;j++)
   		{
   			if(i==0 && j==0) dp[i][j]=1;
   		  else if(i==0)
			 {
			 	if(v[i][j]=='.') dp[i][j] = dp[i][j-1];
		    }
		  else if(j==0)
		  {
		  	if(v[i][j]=='.') dp[i][j]= dp[i-1][j];
			}  
		  else if(v[i][j]=='.') dp[i][j]= (dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;  
		}
	}
	cout<<dp[h-1][w-1];
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

static const ll INF = 1e15;

static const ll mod = 1e9 + 7;

int main() {
	char c;
	cin >> c;
	if (c >= 'a' && c <= 'z') {
		cout << 'a' << endl;
	}
	else {
		cout << 'A' << endl;
	}
	return 0;
}
	

Measured memory_bytes: 3592
#include <stdio.h>

#define MAX 1000000000
#define min(x,y) ((x)<(y)?(x):(y))

int cost[101];
int check[101];
int route[101][101];
int n,m;

 
void dijkstra(int start, int route[101][101]) {
    int i,j,k;
 
    for (i = 1; i < m + 1; i++) {
    cost[i] = MAX;
    check[i] = 0;
    }
    cost[start] =0;
    
    while (1) {
    k=-1;
	for (j=1;j<m+1;j++) {
        if (check[j] == 0 && (k == -1 || cost[j] < cost[k]))
        k = j;
    }
    if (k == -1)
        break;
        
    check[k] = 1;
 
    for (j=1;j< m + 1;j++) {
        cost[j] = min(cost[j], cost[k] + route[k][j]);
    }
    }
}
 
int main(void) {
    int l, o, count,a, b, cro, tro;;
    int result;
    int croute[101][101];
    int troute[101][101];
 
    while (scanf("%d%d", &n, &m)) {

	if(n+m==0) break;

	for (l = 0; l < 101; l++) {
        for (o = 0; o < 101; o++) {
        croute[l][o] = l == o ? 0 : MAX;
        troute[l][o] = l == o ? 0 : MAX;
        }
    }
    while (n > 0) {
        scanf("%d%d%d%d", &a, &b, &cro, &tro);
        croute[a][b] = croute[b][a] = cro;
        troute[a][b] = troute[b][a] = tro;
        n--;
    }
    
    scanf("%d", &count);

	while (count > 0) {
        int p, q, r;
        scanf("%d%d%d", &p, &q, &r);
        dijkstra(p, r == 0 ? croute : troute);
        result = cost[q];
        printf("%d\n", result);
        count--;
    }
    }
    return 0;
}

Measured memory_bytes: 684
import java.util.Scanner
import scala.io.StdIn._

object Main extends App {

  val k = readInt()
  val Array(a, b) = readLine().split(" ").map(_.toInt)


  def solve() = {
    val isOk = (a to b).map(i => i % k == 0).exists(identity)
    if(isOk) "OK" else "NG"
  }

  println(solve())

}



Measured memory_bytes: 54828
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define VSORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define vout(i,n,v) for(int i=0;i<(int)n-1;i++){cout<<v[i]<<" ";}cout<<v[n-1]<<"\n";
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;


void solve(long long N, long long Y){
    V v(3, -1);
    for (ll i = 0; i <= N; i++) {
        for (ll j = 0; i+j <= N; j++) {
            // ll tmp = Y-(i*10000+j*5000);
            // ll sen = N-i-j;
            // if(tmp <= sen*1000 && tmp >= 0) {
            //     v[0] = i;
            //     v[1] = j;
            //     v[2] = tmp/1000;
            //     break;
            // }
            ll sum = i*10000+j*5000+(N-i-j)*1000;
            if(sum==Y) {
                v[0] = i;
                v[1] = j;
                v[2] = N-i-j;
                break;
            }
        }
    }
    vout(i,v.size(),v);
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long Y;
    scanf("%lld",&Y);
    solve(N, Y);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
  double a,b,x;
  cin >> a >> b >> x;

  double s = x/a;
  double ans;
  if(s>a*b/2){
    double h = 2.0*(a*b-s)/a;
    ans = atan(h/a);
  }
  else{
    double w = 2.0*s/b;
    ans = atan(b/w);
  }
  ans *= 180.0/M_PI;
  printf("%.10lf\n",ans);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
#define MOD 1000000007LL
using namespace std;

LLI A[300007];

int main()
{
    int i,j;
    int N;

    scanf("%d", &N);
    for( i=0; i<N; i++)
    {
        scanf("%lld", &A[i]);
    }

    LLI ans = 0;
    LLI mul = 1;
    for( i=0; i<64; i++)
    {
        LLI t = 0;
        LLI f = 0;
        for( j=0; j<N; j++)
        {
            if((A[j]>>i)&1)
                t++;
            else
                f++;
        }
        ans += ( t * f % MOD) * mul % MOD;
        ans %= MOD;
        mul = mul *2 % MOD;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>
int main(void){
    double x1,x2,y1,y2;
    double ans;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    ans=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    printf("%f",ans);
    return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;

int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  int C[26];
  int S[26][365];
  int T[365];
  int res_do[26];
  int score;
  
  int min_num=100;
  int min_c =0;
  
  
  for(int i=0;i<26;i++){
    cin >> C[i];
    if(min_num>C[i]){
      min_c=i+1;
      min_num=C[i+1];
    }
  }
  
  
  
  int max_num;
  int max_s;
  
  
  for(int j=0;j<26;j++){
    res_do[j]=0;
  }
  
  for(int i=0;i<365;i++){
    max_num = 0;
    max_s = 26;
    for(int j=0;j<26;j++){
      cin >> S[j][i];
      if(max_num<S[j][i]+C[j]*res_do[j]){
        max_num=S[j][i]+C[j]*res_do[j];
        max_s=j;
      }
    }
    //cout << max_s <<":"<<max_num<<endl;
    T[i]=max_s;
    res_do[max_s]=0;
  }
  
  int P[365];
  for(int i=0;i<365;i++){
    P[i]=T[i];
  }
  int pre_score=0;
  
  for(int k=0;k<100;k++){
    score=0;
    for(int j=0;j<26;j++){
      res_do[j]=0;
    }
    for(int i=0;i<365;i++){
      score= score+S[P[i]][i];
      for(int j=0;j<26;j++){
        score =score+(i-res_do[j])*C[j];
      }
      res_do[P[i]]=i;
    }
    if(score>pre_score){
      pre_score=score;
      for(int i=0;i<365;i++){
        T[i]=P[i];
      }
    }
    int bi = 0;
    for(int i=0;i<365;i++){
      if(bi==0){
        P[i]=T[i-1];
        bi = 1;
      }else{
        P[i]=T[i+1];
        bi = 0;
      }
    }
  }
  
  

  
  
  
  
  for(int i=0;i<365;i++){
    cout << T[i]+1 <<endl;
  }
  
  return 0;
}


int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


Measured memory_bytes: 3608