akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<vector<int>> c(3, vector<int> (3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c.at(i).at(j);
        }
    }
    vector<int> check1(3);
    vector<int> check2(3);
    vector<int> check3(3);
    vector<int> check4(3);
    for(int i = 0; i < 3; i++){
        check1.at(i) = c.at(i).at(0) - c.at(i).at(1);
        check2.at(i) = c.at(i).at(0) - c.at(i).at(2);
        check3.at(i) = c.at(0).at(i) - c.at(1).at(i);
        check4.at(i) = c.at(0).at(i) - c.at(2).at(i);
    }
    int check = 0;
    if(check1.at(0) - check1.at(1) != 0 || check1.at(0) - check1.at(2) != 0) check++;
    if(check2.at(0) - check2.at(1) != 0 || check2.at(0) - check2.at(2) != 0) check++;
    if(check3.at(0) - check3.at(1) != 0 || check3.at(0) - check3.at(2) != 0) check++;
    if(check4.at(0) - check4.at(1) != 0 || check4.at(0) - check4.at(2) != 0) check++;
    if(check == 0) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;


int cnt_digits(long N) {
	int digits = 0;

	while (N > 0) {
		N /= 10;
		digits++;

	}

	return digits;

}

int main(void) {
	long N;
	cin >> N;

	int ans = cnt_digits(N); // 1*N=N max(cnt_digits(1),cnt_digits(N))=cnt_digits(N)

	for (long A = 1; A*A <= N; ++A) {
		if (N%A != 0) continue;
		const long B = N / A;

		const long cur = max(cnt_digits(A), cnt_digits(B));

		if (ans > cur) {
			ans = cur;

		}

	}

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

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static String[][] map;
	static boolean[][] al;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		ArrayList<String> list = new ArrayList<String>();
		TreeMap<String, ArrayList<Integer>> map = new TreeMap<String, ArrayList<Integer>>();
		while(stdIn.hasNext()) {
			String name = stdIn.next();
			int number = stdIn.nextInt();
			
			int tmp = Collections.binarySearch(list, name);
			if(tmp >= 0) {
				ArrayList<Integer> a = map.get(name);
				a.add(number);
				map.put(name, a);
			}
			else {
				list.add((tmp+1)*-1,name);
				ArrayList<Integer> aaa = new ArrayList<Integer>();
				aaa.add(number);
				map.put(name, aaa);
			}
		}
		for(int i = 0; i < list.size(); i++) {
			ArrayList<Integer> tmp = map.get(list.get(i));
			System.out.println(list.get(i));
			Collections.sort(tmp);
			System.out.print(tmp.get(0));
			for(int j = 1; j < tmp.size(); j++) {
				System.out.print(" "+ tmp.get(j));
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 20264
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    ll k;
    cin >> k;
    for(int i=0;i<s.size();i++){
        int c;
        c = s[i]-'a';
        if(26-c<=k&&s[i]!='a'){
            k-=(26-c);
            s[i]='a';
        }
    }
    int cc = k%26;
    int aa = s[s.size()-1]-'a';
    aa+=cc;
    aa %= 26;
    s[s.size()-1]=aa+'a';
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int n;
int a[210];
int main(){
  cin>>n;
  for(int i=0;i<2*n;i++){
    cin>>a[i];
  }
  sort(a,a+2*n);
  int ans=0;
  for(int i=0;i<2*n;i+=2){
    ans+=a[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    string str,aans="";
    cin>>str;
    for(i=0;i<str.length();i++)
    {
        if(str[i]=='B')
        {
            if(aans.length())aans.pop_back();
        }
        else aans+=str[i];
    }
    cout<<aans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
  int i, a[3] = {0, 0, 0}, now = 0;
  char s[3][110];
  for(i = 0; i < 3; ++i) scanf("%s", s[i]);
  while( 1 ) {
    if(a[now] == strlen(s[now])) {
      printf("%c", now + 'A');
      return 0;
    }
    now = s[now][a[now]++] - 'a';
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define mod 998244353

// 区間の和を計算するBIT, 1-indexed
template<typename T>
struct BIT{
    using F = function<T(T, T)>;
    using INV = function<T(T)>;
    BIT(int N, T unit, F f, INV inv) : value(N+1, unit), unit(unit), f(f), inv(inv) {}

    T sum(int i, int j) {
        if(i > j) return unit;
        if(i == 0) return sum(j);
        return f(sum(j), inv(sum(i-1)));
    }

    void add (int k, T x) {
        for (; k < value.size(); k += k & -k) value[k] = f(value[k], x);
    }
  
  T sum(int k) {
        T res = unit;
        for (; k > 0; k -= k & -k) res = f(res, value[k]);
        return res;
    }

private:
    vector<T>value;
    const F f;
    const T unit;
    const INV inv;
};

int main() {
    int N;
    cin >> N;
    vector<int>x(N);
    vector<int>y(N);
    vector<pair<int, int>> elements(N);
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
    }

    // y座標を 1-indexed で圧縮後, x座標でソート
    vector<int> copyY(y);
    sort(copyY.begin(), copyY.end());
    map<int, int> mp;
    for (int i = 0; i < N; ++i) {
        mp[copyY[i]] = i + 1;
    }
    for (int i = 0; i < N; ++i) {
        y[i] = mp[y[i]];
        elements[i] = make_pair(x[i], y[i]);
    }
    sort(elements.begin(), elements.end());

    // 2の累乗計算
    ll modPow[N+1];
    modPow[0] = 1;
    for (int i = 1; i < N+1; ++i) {
        modPow[i] = modPow[i-1] * 2 % mod;
    }

    ll ans = modPow[N] + mod - 1;
    ans %= mod;
    ans = ans * N % mod;

    BIT<int> tree(N, 0, plus<int>(), [](int a){ return -a;});
    sort(y.begin(), y.end());

    for (int i = 0; i < N; ++i) {
        // 左にi個, 右にN-i-1個の点
        int yi = elements[i].second;
        // vector y には自分自身も含まれていることに注意
        auto iter1 = lower_bound(y.begin(), y.end(), yi);
        int low = distance(y.begin(), iter1);
        // 下にlow個, 上にN-low-1個の点

        int lowOver = tree.sum(yi);
        tree.add(yi, 1);

        // 左下にlowOver個, 左上にi-lowOver個の点
        ans = ans + mod + mod + mod + mod;
        ans = ans - modPow[low] - modPow[N-low-1] - modPow[i] - modPow[N-i-1] + 4;
        ans = ans + modPow[lowOver] + modPow[i-lowOver] + modPow[low - lowOver] + modPow[N-low-1-i+lowOver] - 4;
        ans %= mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 15872
_,*A=*$<;101.times{|x|101.times{|y|a=A.map{|s|i,j,k=s.split.map &:to_i;[k,(i-x).abs+(j-y).abs]};K,D=a.max;a.all?{|k,d|k==[K+D-d,0].max}&&p(x,y,K+D)}}

Measured memory_bytes: 1788
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    al = []
    od = [10**18]
    for i in range(n):
        a = int(ipt())
        al.append(a)
        if i&1:
            od.append(a)
    al.sort()
    od.sort()
    ans = 0
    oi = 0
    for i,ai in enumerate(al):
        if ai == od[oi]:
            if i&1 == 0:
                ans += 1
            oi += 1
    print(ans)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 82200
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<ll>x,y;
int n,m,k;
ll low_bs(int l,int r,ll val,vector<ll>&v)
{
    ll ans=1e17;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(v[mid]<=val)
        {
            ans=v[mid];
            l=mid+1;
        }
        else
            r=mid-1;
    }
    return ans;
}
ll high_bs(int l,int r,ll val,vector<ll>&v)
{
    ll ans=1e17;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(v[mid]>=val)
        {
            ans=v[mid];
            r=mid-1;
        }
        else
            l=mid+1;
    }
    return ans;
}
ll dif(ll a)
{
    if(a<0)
        return a*-1;
    return a;
}
ll solve1(ll a)
{
    ll ans=1e18;
    ll p=low_bs(0,n-1,a,x);
    ll q=low_bs(0,m-1,p,y);
    ans=min(ans,dif(p-a)+dif(p-q));
    q=high_bs(0,m-1,p,y);
    ans=min(ans,dif(p-a)+dif(p-q));
    p=high_bs(0,n-1,a,x);
    q=low_bs(0,m-1,p,y);
    ans=min(ans,dif(p-a)+dif(p-q));
    q=high_bs(0,m-1,p,y);
    ans=min(ans,dif(p-a)+dif(p-q));
    return ans;
}
ll solve2(ll a)
{
    ll ans=1e18;
    ll p=low_bs(0,m-1,a,y);
    ll q=low_bs(0,n-1,p,x);
    ans=min(ans,dif(p-a)+dif(p-q));
    q=high_bs(0,n-1,p,x);
    ans=min(ans,dif(p-a)+dif(p-q));
    p=high_bs(0,m-1,a,y);
    q=low_bs(0,n-1,p,x);
    ans=min(ans,dif(p-a)+dif(p-q));
    q=high_bs(0,n-1,p,x);
    ans=min(ans,dif(p-a)+dif(p-q));
    return ans;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);

    cin>>n>>m>>k;

    for(int i=0; i<n; i++)
    {
        ll a;
        cin>>a;
        x.push_back(a);
    }
    for(int i=0; i<m; i++)
    {
        ll a;
        cin>>a;
        y.push_back(a);
    }
    while(k--)
    {
        ll a;
        cin>>a;
        ll ans=min(solve1(a),solve2(a));
        cout<<ans<<endl;
    }


    return 0;
}


Measured memory_bytes: 5592
/*フロイド法(AIZU_vol2_0200)*/
import java.util.*;

class Main{
    
    public static void main(String[] args){   //メイン     
	
	String str1,str2;
	int INF=100000000;
	int SIZE=3002;  //配列サイズ
	int i,j,k,l;
	int n,m;    //線路の情報の数n,駅の数m
	int a,b;    //線路がつなぐ二つの駅a,b
	int p,q,r;  //出発駅p,到着駅q,出力する値r
	int[][] cost,time;  //料金cost[][],移動時間time[][]
	cost = new int[SIZE][SIZE];
	time = new int[SIZE][SIZE];

	Scanner in = new Scanner(System.in);  //入力のやつ

	while(true){  //無限ループ

	    n=in.nextInt();
	    m=in.nextInt();

	    //cost,timeを初期化
	    for(i=1;i<m+1;i++){
		for(j=1;j<m+1;j++){
		    cost[i][j]=INF;
		    time[i][j]=INF;
		}
	    }

	    //終了条件
	    if(n==0 && m==0)break;

	    //データの入力
	    for(i=0;i<n;i++){

		a=in.nextInt();
		b=in.nextInt();
		cost[a][b]=in.nextInt();
		time[a][b]=in.nextInt();

		cost[b][a]=cost[a][b];
		time[b][a]=time[a][b];
	    }

	    //ワーシャルフロイド法で最小コスト、最短時間を求める
	    for(i=1;i<m+1;i++){
		for(j=1;j<m+1;j++){
		    for(k=1;k<m+1;k++){
			cost[j][k]=Math.min(cost[j][k],cost[j][i]+cost[i][k]);
			time[j][k]=Math.min(time[j][k],time[j][i]+time[i][k]);
		    }
		}
	    }

	    l=in.nextInt();

	    //データの出力
	    for(i=0;i<l;i++){

		p=in.nextInt();
		q=in.nextInt();
		r=in.nextInt();

		if(r==1){
		    System.out.println(time[p][q]);
		} else {
		    System.out.println(cost[p][q]);
		}
	    }
	}

    }
	

}

Measured memory_bytes: 176844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;


int main(){
    int N, K; cin >> N >> K;

    vector<int> cnt(200010,0);
    rep(i,N){
        int A; cin >> A;
        cnt[A]++;
    }

    sort(cnt.begin(), cnt.end(), greater<int>());

    int ans = N;
    rep(i,K) ans -= cnt[i];

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll N, A, B; cin >> N >> A >> B;
	ll X[100001] = {};
	ll sum = 0;
	rep(i, 0, N) {
		cin >> X[i];
		if (i >= 1) {
			sum += min(A*(X[i] - X[i - 1]), B);
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int gcd(int a, int b);

int main(void)
{
	int a, b;
	
	while (scanf("%d %d", &a, &b) != EOF){
		printf("%d %d\n", gcd(a, b), a / gcd(a, b) * b);
	}
	
	return (0);
}

int gcd(int a, int b)
{
	int tmp, tmp2;
	
	if (a < b){
		tmp = a;
		a = b;
		b = tmp;
	}
	
	while (a % b != 0){
		tmp2 = b;
		b = a % b;
		a = tmp2;
	}
	
	return (b);
}

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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1e5+5,MOD=1e9+7;
inline int mod(int x){return x<MOD?x:x-MOD;}
set<int>st[3];
int n,nxt[MAXN],f[MAXN];
char s[MAXN];
int main() {
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=1;i<=n;++i){
		bool flag=(s[1]!=s[2]);
		if(flag)for(int i=3;i<=n;i+=2)if(s[i]!=s[1]){flag=0;break;}
		if(flag)for(int i=4;i<=n;i+=2)if(s[i]!=s[2]){flag=0;break;}
		if(flag)return puts("1"),0;
	}
	for(int i=1,sum=0;i<=n;++i){if(s[i]=='a')sum=(sum+1)%3;else sum=(sum+2)%3;st[sum].insert(i);}
	nxt[n]=n+1;for(int i=n-1,p=n+1;i>=1;--i){if(s[i]==s[i+1])p=i+1;nxt[i]=p;}
	//for(int i=1;i<=n;++i)cout<<nxt[i]<<" ";cout<<endl;
	f[0]=1;
	for(int i=0,sum=0;i<n;(sum+=((s[++i]=='a')?1:2))%=3){
		//下一位是a
		if(s[i+1]=='a')f[i+1]=mod(f[i+1]+f[i]);
		else{
			int t=(sum+1)%3;
			set<int>::iterator it=st[t].lob(nxt[i+1]);
			if(it!=st[t].end())f[*it]=mod(f[*it]+f[i]);
		}
		//下一位是b
		if(s[i+1]=='b')f[i+1]=mod(f[i+1]+f[i]);
		else{
			int t=(sum+2)%3;
			set<int>::iterator it=st[t].lob(nxt[i+1]);
			if(it!=st[t].end())f[*it]=mod(f[*it]+f[i]);
		}
	}
	//for(int i=1;i<=n;++i)cout<<f[i]<<" ";cout<<endl;
	int ans=f[n];
	for(int i=n,sum=0;i>1;--i){
		(sum+=((s[i]=='a')?1:2))%=3;
		if(sum==0)ans=mod(ans+f[i-1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
  double l;
  cin >> l;
  
  double base = l/double(3);
  double ans = base * base * base;
  
  cout << fixed;
  cout << setprecision(7) << ans << endl;
  
  return 0;
}


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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

struct Chain {
	vector<int> nodes;
	set<int> marked; // INDEX of marked nodes
};

int n, q;
vector<int> G[100005];
int parent[100005];
int ts[100005]; // treesize
int heavy[100005]; // heavy child
int dep[100005]; // depth
int chainof[100005]; // chain id
vector<Chain> chains; // HLD-chains

int progress = 0;

void dfs(int n) {
	//cout << "DFS " << n << " " << ++progress << " " << ::n << endl;
	ts[n] = 1;
	dep[n] = n == 1 ? 1 : dep[parent[n]] + 1;
	for (int h : G[n]) {
		dfs(h);
		ts[n] += ts[h];
		if (!heavy[n] || ts[h] > ts[heavy[n]]) heavy[n] = h;
	}
}

void hld(int n, int chain = -1) {
	//cout << "HLD " << n << ++progress << " " << ::n << endl;
	if (n == 1) {
		chain = chainof[n] = chains.size();
		chains.push_back(Chain());
		chains[chain].marked.insert(0); // root node is always marked
	}
	//cout << n << " belongs to chain " << chain << endl;
	chainof[n] = chain;
	chains[chainof[n]].nodes.push_back(n);
	if (heavy[n]) hld(heavy[n], chain);
	for (int h : G[n]) if (h != heavy[n]) {
		chainof[h] = chains.size();
		chains.push_back(Chain());
		hld(h, chainof[h]);
	}
}

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);

	while (true) {
		cin >> n >> q; if (!n && !q) break;

		// reset
		chains.clear();
		rep(i, 1, n + 1) {
			G[i].clear();
			parent[i] = ts[i] = dep[i] = chainof[i] = heavy[i] = 0;
		}
		chains.push_back(Chain());

		parent[1] = 0;
		rep(i, 2, n + 1) { cin >> parent[i]; G[parent[i]].push_back(i); }

		dfs(1);
		hld(1);

		ll acc = 0;

		rep(i, 0, q) {
			string op; int v;
			cin >> op >> v;
			//cout << op << " " << v << flush << endl;

			if (op[0] == 'M') {
				Chain& chain = chains[chainof[v]];
				chain.marked.insert(dep[v] - dep[chain.nodes.front()]);
				//cout << "Inserted " << (dep[v] - dep[chain.nodes.front()]) << " to chain " << chainof[v] << endl;
			} else if (op[0] == 'Q') {
				int cnode = v;
				//cout << "Chain: " << chainid << ", size: " << chains[chainid].nodes.size() << endl;
				while (true) {
					int chainid = chainof[cnode];
					Chain& chain = chains[chainid];
					//cout << "Chain " << chainid << ", Node " << cnode << endl;
					//getchar();
					auto it = chain.marked.upper_bound(dep[cnode] - dep[chain.nodes.front()]);
					if (it != chain.marked.begin()) {
						acc += chain.nodes[*prev(it)];
						//cout << "Is: " << chain.nodes[*prev(it)] << endl;
						break;
					}
					cnode = parent[chain.nodes.front()];
				}
			}
		}

		cout << acc << endl;
	}
}



Measured memory_bytes: 38692
using System;

namespace A___Favorite_Sound
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = int.Parse (input[0]);
            var b = int.Parse (input[1]);
            var c = int.Parse (input[2]);
            if (b / a > c)
            {
                Console.WriteLine (c);
            }
            else
            {
                Console.WriteLine (b / a);
            }
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(){
    int h,w;
    int i,t;
    while(1){
        scanf("%d %d", &h, &w);
        if(h==0 && w==0)break;
        for(i = 0;i < h;i++){
            for(t = 0;t < w;t++){
                if((i+t)%2)
                    printf(".");
                else
                    printf("#");
            }
            puts("");
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ll N, M; cin >> N >> M;
    priority_queue<ll> pq;
    for (int i = 0; i < N; ++i) {
        ll a; cin >> a;
        pq.push(a);
    }
    for (int i = 0; i < M; ++i) {
        ll highest = pq.top(); pq.pop();
        pq.push(highest / 2);
    }
    ll min_sum = 0;
    while (!pq.empty()) {
        min_sum += pq.top(); pq.pop();
    }
    cout << min_sum << endl;
    return 0;
}


Measured memory_bytes: 4292
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
 		
int main() {

int N;
cin>>N;
vec(A);
int maxi=0;
fx(N){
	vecp(A);
	maxi=max(maxi,A.at(x));
}
//sorts(A)
int mini=1000000000;
int minimum;
fx(N){
	if(A.at(x)!=maxi&&abs(A.at(x)-(maxi/2))<mini){
		mini=abs(A.at(x)-(maxi/2));
		minimum=A.at(x);
	}
}

cout<<maxi<<' '<<minimum<<endl;
	
	
}

Measured memory_bytes: 892
from itertools import combinations

def f(s):
    n, x = list(map(int, s.split()))
    return len(tuple(filter(lambda it: sum(it) == x,
                            combinations(range(1, n+1), 3))))

while True:
    s = input()
    if s == "0 0":
        break
    print(f(s))

Measured memory_bytes: 7840
using System;

namespace abc076_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());
            int ret = 1;
            for (int i = 0; i < n; i++)
            {
                if (ret < k) ret *= 2;
                else ret += k;
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define EPS (1e-8)
#define x p.real()
#define y p.imag()
using namespace std;
typedef complex <double> point;
struct po{
  point p;
  double l;
  po(){x=y=l=0;};
  po(double a,double b,double c){x=a,y=b,l=c;}
  po(point a,double b){p=a,l=b;}
};
int n;
po bal[10];
double Abs(po a){return (a.x*a.x+a.y*a.y+a.l*a.l);}

po get_po(po a,po b){
  if(a.l>b.l) swap(a,b);
  double D=Abs(po(a.p-b.p,0));
  if(a.l*a.l+D<=b.l*b.l)return a;
  
  double t=(a.l*a.l+D-b.l*b.l)/(2*sqrt(D));
  point vec=b.p-a.p;
  vec=(vec/abs(vec))*t+a.p;
  return po(vec,sqrt(a.l*a.l-t*t));
}

po BinarySearch(double l,po b){
  double L=0,Y,R=l,h;
  int cnt=100;
  while(cnt--){
    Y=(L+R)/2;
    h=sqrt(l*l-Y*Y);
    if(Abs(po(b.x,Y-b.y,h))-b.l*b.l<=EPS) R=Y;
    else L=Y;
  }
  return po(0,Y,h-EPS);
}

bool check(po a){
  for(int i=0;i<n;i++)
    if(Abs(po(a.p-bal[i].p,a.l))-bal[i].l*bal[i].l>EPS)return 0;
  return 1;
}

double solve(){
  if(n==1)return bal[0].l;
  double res=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++){
      po a=get_po(bal[i],bal[j]);
      for(int k=0;k<n;k++){
	point p=bal[i].p-a.p,q=bal[k].p-a.p;
	q=q*conj(p)/abs(p);
	po b=BinarySearch(a.l,po(q,bal[k].l));
	b.p=b.p*p/abs(p)+a.p;
	if(check(b)) res=max(res,b.l);
      }
    }
  return res;
}


int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++) cin>>bal[i].x>>bal[i].y>>bal[i].l;
    printf("%.8f\n",solve());
  }
  return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	int a, b, c;
	double s, l, h, d;
	cin >> a >> b >> c;

	d = (acos(-1.0) * c) / 180.0;
	s = a * b * sin(d) / 2.0;
	l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(d));
	h = b * sin(d);

	printf("%lf\n%lf\n%lf\n", s, l, h);

	return 0;
}


Measured memory_bytes: 3436
#include <stdio.h>

int main(void){
    int ma[3000],mi[3000];
    int a=-1, b=-1, c=0, i;
    while (!(a == 0 && b == 0)){
        scanf("%d %d", &a, &b);
        if (a > b){ma[c]=a,mi[c]=b;}
        else {ma[c]=b,mi[c]=a;}
        c++;
    }
    for(i=0;i<c-1;i++) printf("%d %d\n",mi[i],ma[i]);
}



Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N; 
  cin >> N;

  vector<int> L(N);
  REP(i, N) cin >> L[i];

  sort(ALL(L));

  int ans = 0;
  REP(i, N) FOR(j, i+1, N){
    int t = lower_bound(ALL(L), L[i]+L[j])-L.begin()-1;
    if(t <= j) continue;
    ans += t-j;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#include<map>
#include<queue>
#define Max 9
int gg[Max]={1,2,3,4,5,6,7,8,0}, s[Max];

int ff[4][2] = {0,-1,1,0,0,1,-1,0};
int sum;
struct node
{
	int a[Max];
	int step;
};
map<int ,int >m;


int bfs()
{
	node tt;
	memcpy(tt.a,s,sizeof(s));
	tt.step = 0;
	queue<node > q;
	q.push(tt);
	while(!q.empty())
	{
		node star = q.front();
		q.pop();
		int i;
		for(i = 0;i<9;i++)
			if(star.a[i]==0)
				break;
		int y = i/3;
		int x = i%3;
		for(i = 0;i<4;i++)
		{
			int tx = x + ff[i][0];
			int ty = y + ff[i][1];
			if(tx >= 0&&ty>=0&&ty<3&&tx<3)
			{
				node end;
				memcpy(end.a,star.a,sizeof(star.a));
				int k = ty*3+tx;
				swap(end.a[k],end.a[y*3+x]);
				int sum1 = 0;
				for(int j = 0;j<9;j++)
					sum1 = sum1*10+end.a[j];
				if(!m[sum1])
				{
					m[sum1] = sum++;
					end.step = star.step+1;
					if(memcmp(end.a,gg,sizeof(gg))==0)
						return end.step;
					q.push(end);
				}
			}
		}
	}
}
int main()
{
	int i,j;

	while(~scanf("%d",&s[0]))
	{
		m.clear();
		int k = s[0];
		sum = 1;
		for(i = 1;i<9;i++)
		{
			scanf("%d",&s[i]);
			k = k*10+s[i];
		}
		m[k] = sum++;
		if(memcmp(s,gg,sizeof(gg))==0)
			printf("0\n");
		else printf("%d\n",bfs());
		
	}	
	return 0;
} 


Measured memory_bytes: 11668
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}


void MAIN() {
    LL A, B;
    scanf("%lld%lld", &A, &B);
    if (A > B) swap(A, B);
    LL lo = 0, hi = B;

    while (hi - lo > 1) {
	LL mid = (lo + hi) / 2;
	if (mid * mid < A * B) lo = mid;
	else hi = mid;
    }

    LL ans = lo + lo;
    if (A < B) ans--;
    if (lo * (lo + 1) >= A * B) ans--;
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

S = list(input().strip())
S_count = []
len_S = len(S)

if S[0] == '>':
    S_count.append(0)

loc_index = 0
for i in range(len_S - 1):
    if S[i] != S[i+1]:
        S_count.append(i + 1 - loc_index)
        loc_index = i + 1

S_count.append(len_S - loc_index)

if len(S_count) % 2 != 0:
    S_count.append(0)


def value(x0, x1):
    v = 0
    x_max = max(x0, x1)
    x_min = min(x0, x1)
    for j in range(x_max):
        v += j+1
    for k in range(x_min):
        v += k
    return v


result = 0
left = 0
right = 1
for g in range(len(S_count) // 2):
    result += value(S_count[left], S_count[right])
    left += 2
    right += 2

print(result)



Measured memory_bytes: 89820
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

#include <cmath>
#include <cstdio>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

const double PI = 3.14159265358979;

int main()
{
	int A, B, H, M;
	cin >> A >> B >> H >> M;

	double hx = A * cos(2 * PI * (H + M / 60.0) / 12 );
	double hy = A * sin(2 * PI * (H + M / 60.0) / 12);
	double mx = B * cos(2 * PI * M / 60);
	double my = B * sin(2 * PI * M / 60);

	double ans = sqrt((hx - mx) * (hx - mx) + (hy - my) * (hy - my));

	printf("%.20lf\n", ans);

	return 0;
}


Measured memory_bytes: 4052
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
count = 0
ans = 0

X = i()

if X >= 30:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 61732
def test():

	formula = input().split()
	stack = []

	for element in formula:

		if element == '+':

			a = stack.pop()
			b = stack.pop()
			stack.append(b+a)

		elif element == '-':

			a = stack.pop()
			b = stack.pop()
			stack.append(b-a)
			

		elif element == '*':

			a = stack.pop()
			b = stack.pop()
			stack.append(b*a)

		else:
			stack.append(int(element))


	print(stack.pop())

if __name__ == "__main__":
	test()



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

int main() {
  int N;
  cin >> N;
  vector<int> length(N);
  for (int i=0; i<N; ++i) {
    cin >> length[i];
  }
  sort(length.begin(), length.end(), greater<int>());
  int other_total = 0;
  for (int i=1; i<N; ++i) {
    other_total += length[i];
  }
  if (other_total <= length[0]) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <atcoder/lazysegtree>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;
namespace ac = atcoder;

struct S{
    int zero, one, size;
    ll rev;
    S(){}
    S(int _zero, int _one, int _size, ll _rev) : zero(_zero), one(_one), size(_size), rev(_rev) {}
};

S op (S a, S b) { return S(a.zero+b.zero, a.one+b.one, a.size+b.size, a.rev+b.rev+1LL*a.one*b.zero); }
S e () { return S(0, 0, 0, 0); }
S mapping (int f, S x) { if(f == 1) return S(x.one, x.zero, x.size, 1LL*x.one*x.zero-x.rev); else return x; }
int compositoin(int f, int g) { return f^g; }
int id () { return 0; }

int main () {
    int n, q; cin >> n >> q;
    vector<S> da(n);
    rip(i,n,0) {
        int a; cin >> a;
        da[i] = S(a^1, a, 1, 0);
    }
    ac::lazy_segtree<S, op, e, int, mapping, compositoin, id> lst(da);
    vector<ll> ans(0);
    rip(i,q,0) {
        int t, l, r; cin >> t >> l >> r;
        --l;
        if(t == 1) {
            lst.apply(l, r, 1);
        }
        else {
            auto now = lst.prod(l, r);
            ans.push_back(now.rev);
        }
    }
    rip(i,ans.size(),0) printf("%lld\n", ans[i]);
}

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

int main() {
 int N, S1, S2, sum1 = 0, sum2 = 0, S = 100000;
 cin >> N;
 for (int i = 1; i < N / 2 + 1; i++) {
   S1 = N - i;
   S2 = i;
    while (S1 > 0) {
    sum1 += S1 % 10;
    S1 /= 10;
    }
    while (S2 > 0) {
    sum2 += S2 % 10;
    S2 /= 10;
    }
    if (S > sum1 + sum2) {
    S = sum1 + sum2;
    }
    sum1 = 0;
    sum2 = 0;
  }
 cout << S << endl;
}


Measured memory_bytes: 256
//Referece, #8034764 

#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
const long long int mod = 1e9 + 7;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl

Vi l(2000);
int main(){
    int N;
    int res = 0;
    cin >> N;
    l.rs(N);
    rep(i,0,N) cin >> l[i];
    sort(l.begin(),l.end());
    rep(i,0,N-2){
        rep(j,i+1,N-1){
            //一番短いものl[i]と、二番目に短いものl[j]でペアを固定する。
            //三番目にくるものは、l[i]+l[j]よりも小さくないといけない。
            auto itr = lower_bound(l.begin(),l.end(), l[i]+l[j]);
            int a = itr-l.begin();//0からここまでのlが使える。
            //cout << a << endl;
            res += (a-(j+1));
        }
    }
    cout << res << endl;

}



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int A, B, T;
    cin >> A >> B >> T;
    printf("%lld\n", T / A * B);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

int main()
{
  string s; 
  int sum = 0;
  while(cin>>s)
  {
    if (s=="-") return 0;
    int a; cin>>a;
    rep(i,a)
    {
      int b; cin>>b;
      sum += b;
    }
    sum %=s.size();
    cout << s.substr(sum, s.size()-sum) << s.substr(0, sum) << "\n";
    sum = 0;
  }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



int niz[200005];

int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin >> n >> k;
    ff(i,0,n - 1)cin >> niz[i];
    ff(i,k,n-1){
        if(niz[i] > niz[i - k])cout << "Yes\n";
        else cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 4436
import sys
sys.setrecursionlimit(10**9)


N = int(input())
to = [[] for _ in range(N)]

for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u, v = u - 1, v - 1
    to[u].append([v, w])
    to[v].append([u, w])


def dfs(v, color):
    for nv, w in to[v]:
        if color[nv] == -1:
            color[nv] = color[v] ^ (w % 2)
            dfs(nv, color)


def main():
    color = [-1] * N
    color[0] = 0
    dfs(0, color)
    print(*color, sep='\n')


if __name__ == "__main__":
    main()

Measured memory_bytes: 84480
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<pii> que;

char A[110][110];
bool visited[110][110];
int dist[110][110];
int gx[] = {-1,0,0,1};
int gy[] = {0,-1,1,0};

bool chk(int x,int y,int n,int m){
    if(x<=0||y<=0||x>n+1||y>m+1)return true;
    return false;
}

void bfs(int st1,int st2,int n,int m)
{
    que.push(pii(st1,st2));
    visited[st1][st2] = true;
    dist[1][1] = 1;

    while(!que.empty())
    {
        int x = que.front().first;
        int y = que.front().second;

        que.pop();

        for(int i=0;i<4;i++)
        {
            int nx = x +gx[i];
            int ny = y +gy[i];
            if(chk(nx,ny,n,m))continue;
            if(!visited[nx][ny]&&A[nx][ny]=='.'){
                que.push(pii(nx,ny));
                visited[nx][ny] = true;
                dist[nx][ny] = dist[x][y]+1;
            }
        }
    }

    return ;
}


int main()
{
    int n,m,k,a,b,x,y;
    ll sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n>>m;

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin>>A[i][j];

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            dist[i][j] = INF;

    bfs(1,1,n,m);

    if(!visited[n][m]){
        cout<<"-1\n"; return 0;
    }

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(A[i][j]=='#')cnt++;

    cout<<n*m-(dist[n][m])-cnt<<"\n";

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],i,sum = 0;
    for(i = 0;i < n;i++)
    {
        cin>>a[i];
        sum += a[i];

    }
    sort(a,a+n);
    sum -= a[n-1];
    if(sum>a[n-1])
        cout<<"Yes\n";
    else
        cout<<"No\n";
   return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)

const int N = ((int)1e5) + 5;

int n;
int arr[N];
long long int ans;

int main ()
{
	scanf("%d",&n);
	memset(arr, -1, sizeof arr);
	for (int i = 1; i <= n; i++)
		scanf("%d",&arr[i]);
	for (int i = 1; i <= n; i++)
	{
		if (arr[i] == 0)
			continue;
		if (arr[i] % 2 == 0)
		{
			if (arr[i - 1] == 1 && (arr[i + 1] % 2 == 1))
			{
				arr[i] -= 2;
				arr[i + 1]--;
				arr[i - 1] = 0;
				ans += 2;
				ans += arr[i] / 2;
				arr[i] = 0;
				continue;
			}
			if (arr[i - 1] == 1 && (arr[i + 1] % 2 == 0))
			{
				arr[i] -= 1;
				arr[i - 1] = 0;
				ans += 1;
				ans += arr[i] / 2;
				arr[i] = 1;
				continue;
			}
			ans += arr[i] / 2;
			arr[i] = 0;
			continue;
		}
		else
		{
			ans += arr[i] / 2;
			arr[i] = 1;
			if (arr[i - 1] == 1)
			{
				arr[i] = 0;
				arr[i - 1] = 0;
				ans++;
				continue;
			}
			if (arr[i + 1] % 2 == 1)
			{
				arr[i] = 0;
				arr[i + 1]--;
				ans++;
				continue;
			}
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double x[200];
double y[200];
double ux[100];
double uy[100];
double mx[100];
double my[100];
double sx[100];
double sy[100];
double PI=acos(-1);
int ans[200];
double Abs(double a){double ret=max(a,-a);if(ret>PI)ret=2*PI-ret;return ret;}
double dist(double x,double y){return sqrt(x*x+y*y);}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)ans[i]=0;
		for(int i=0;i<a;i++)scanf("%lf%lf",x+i,y+i);
		int u,m,s;
		double du,dm,ds;
		scanf("%d%d%d%lf%lf%lf",&u,&m,&s,&du,&dm,&ds);

		du=PI*du/360;
		dm=PI*dm/360;
		ds=PI*ds/360;
		for(int i=0;i<u;i++){
			scanf("%lf%lf",ux+i,uy+i);
		}
		for(int i=0;i<m;i++){
			scanf("%lf%lf",mx+i,my+i);
		}
		for(int i=0;i<s;i++){
			scanf("%lf%lf",sx+i,sy+i);
		}
		for(int i=0;i<b;i++){
			double w,r;
			scanf("%lf%lf",&w,&r);
			w=PI*w/180;
			if(w>PI)w-=2*PI;
			for(int j=0;j<a;j++){
				bool ok=false;
				if(dist(x[j],y[j])<r&&Abs(atan2(y[j],x[j])-w)<du){
					ok=true;
				}
				for(int k=0;k<u;k++){
					if(dist(x[j]-ux[k],y[j]-uy[k])<r&&Abs(atan2(y[j]-uy[k],x[j]-ux[k])-w)<du)ok=false;
				}
				for(int k=0;k<m;k++){
					if(dist(x[j]-mx[k],y[j]-my[k])<r&&Abs(atan2(y[j]-my[k],x[j]-mx[k])-w)<dm)ok=false;
				}
				for(int k=0;k<s;k++){
					if(dist(x[j]-sx[k],y[j]-sy[k])<r&&Abs(atan2(y[j]-sy[k],x[j]-sx[k])-w)<ds)ok=false;
				}
				if(ok)ans[j]++;
			}
		}
		int val=0;
		for(int i=0;i<a;i++){
			val=max(val,ans[i]);
		//	printf("%d\n",ans[i]);
		}
		if(val==0)printf("NA\n");
		else{
			bool f=true;
			for(int i=0;i<a;i++){
				if(val==ans[i]){
					if(!f){printf(" ");}
					f=false;
					printf("%d",i+1);
				}
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 1148
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    var t = 0L
    var a = 0L
    repeat(N) {
        val (T, A) = nextLongList()
        val n = Math.max((t + T - 1) / T, (a + A - 1) / A).coerceAtLeast(1)
        t = T * n
        a = A * n
    }
    println(t + a)
}

Measured memory_bytes: 37864
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    
    if(S=="RRS" or S=="SRR") cout << 2;
    
    else if(S=="RRR") cout << 3;
    
    else if(S=="SSS") cout << 0;

    else cout << 1;
    
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> a(h), b(h);
    rep1(i, h){
        cin >> a[i];
    }
    ll res = 0, ans = 0;
    for (int bit = 0; bit < (1<<h+w); ++bit) {
        b = a;
        res = 0;
        for (int i = 0; i < h+w; ++i) {
            if (bit & (1 << i)){
                if (i < h){
                    rep1(j, w) b[i][j] = '.';
                }
                else{
                    rep1(j, h) b[j][i-h] = '.';
                }
            }
        }
        rep1(i, h){
            rep1(j, w){
                if (b[i][j] == '#') res++;
            }
        }
        if (res == k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    use std::collections::HashSet;

    let n: u32 = read();
    let s: String = read();
    let mut ans = 0;
    for i in 0..n {
        let set_prefix: HashSet<_> =
            s[0..(i as usize)].chars().collect();
        let set_suffix: HashSet<_> =
            s[(i as usize)..].chars().collect();
        let size_intersection =
            set_prefix.intersection(&set_suffix).count();
        if ans < size_intersection {
            ans = size_intersection;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int a,b;
  cin >> a >> b;
  int temp;
  if(b < 10){
    temp = a*10+b;
  }else if(b < 100){
    temp =a*100+b;
  }else{
    temp = a*10+1;
  }
  int temp2 = (int)sqrt(temp);
  if(temp2*temp2 == temp){
    cout << "Yes" << endl;
  }else{
    ++temp2;
    if(temp2*temp2 == temp){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;

int main() 
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    int ans = 0;
    for(auto v : h) if (v >= k) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {

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

	for (int i = 1; i < 200; i++) {
		for (int j = 0; j < N; j++) {
			if (A[j] % 2 != 0) {
				printf("%d", i-1);
				i = 300;
				break;
			}
			A[j] /= 2;
		}

	}







}


void  bubbleSort(char number[]) {
	for (int i = 0; i < strlen(number); i++)
		for (int j = i + 1; j < strlen(number); j++)
			if ((int)number[i] > (int)number[j]) {
				char tmp = number[i];
				number[i] = number[j];
				number[j] = tmp;
			}
}

Measured memory_bytes: 128
n = int(input())
t_state, x_state, y_state = 0, 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    d = abs(x - x_state) + abs(y - y_state)
    td = t - t_state
    if  td < d or td%2 != d%2:
        print("No")
        exit()
    t_state, x_state, y_state = t, x, y
print("Yes")

Measured memory_bytes: 46056