akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


class UnionFind {
public:
	vector<int> s, p, es;
	map<int, int>sizemp;

	UnionFind() {}
	UnionFind(int size) {
		s.resize(size, 0);
		p.resize(size, 0);
		es.resize(size, 0);
		sizemp[1] = size;
		rep(i, 0, size)makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		s[x] = 1;
		es[x] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		x = findSet(x);
		y = findSet(y);
		es[x]++;
		if (x == y)return;
		if (s[x] < s[y])swap(x, y);
		int szx = size(x);
		int szy = size(y);
		sizemp[szx]--;
		sizemp[szy]--;
		sizemp[szx + szy]++;
		if (sizemp[szx] == 0)sizemp.erase(szx);
		if (sizemp[szy] == 0)sizemp.erase(szy);
		p[y] = x;
		s[x] += s[y];
		es[x] += es[y];
	}


	int findSet(int x) {
		if (x == p[x]) {
			return x;
		}
		else {
			return p[x] = findSet(p[x]);
		}
	}

	int size(int x) {
		return s[findSet(x)];
	}
	int esize(int x) {
		return es[findSet(x)];
	}
	int minsz() {
		auto beg = sizemp.begin();
		return beg->first;
	}
};

vector<int>E[101010];
int col[101010];
int fl = 0;
void dfs(int now){
	fore(x, E[now]) {
		if (col[x] == -1) {
			col[x] = 1 - col[now];
			dfs(x);
		}
		else if (col[x] == col[now])fl = 0;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N, M;
	cin >> N >> M;
	UnionFind un = UnionFind(N);
	for (int i = 0; i < M; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		un.unite(u, v);
		E[u].pb(v);
		E[v].pb(u);
	}

	for (int i = 0; i < N; i++)col[i] = -1;

	ll ans = 0;
	ll one = 0;
	ll bi = 0;
	ll ot = 0;
	for (int i = 0; i < N; i++) {
		if (un.size(i) == 1) { one++; continue; }
		if (col[i] != -1)continue;
		fl = 1;
		col[i] = 0;
		dfs(i);
		if (fl)bi++;
		else ot++;
	}


	for (int i = 0; i < N; i++)col[i] = -1;
	for (int i = 0; i < N; i++) {
		if (un.size(i) == 1) { ans += N; continue; }
		ans += one;
		if (col[i] != -1)continue;
		fl = 1;
		col[i] = 0;
		dfs(i);
		if (fl)ans += 2 * bi + ot;
		else ans += bi + ot;
	}
	puts(ans);

	return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
const int INF = 1e9;
#define MAX 100005
int a[MAX];
vector<pair<int, int> > p;
int main(void) {
	int n, ain, zc = 0;
	bool zero, flg = true;
	unsigned long long res = 0;
	cin >> n;
	zero = n % 2 == 0 ? true : false;

	for (int i = 0; i < n; ++i)
	{
		cin >> ain;
		if (ain != 0) {
			if (!a[ain]) {
				a[ain] = 1;
			}
			else {
				a[ain + 1] = 1;
			}
		}
		else {
			++zc;
			if (n % 2 == 0) {
				zero = false;
				break;
			}
			else {
				if (zc == 1) {
					zero = true;
				}
				else if (zc > 1) {
					zero = false;
					break;
				}
			}
		}
	}
	if (zero) {
		int d = n % 2 == 0 ? 1 : 2;
		for (int i = d; i <= n; ++i) {
			if (!a[i]) {
				flg = false;
			}
		}
		if (flg) {
			int c = n / 2;
			res = 1;
			for (int i = 0; i < c; ++i)
			{
				res *= 2;
				if (res > 1'000'000'007) {
					res %= 1'000'000'007;
				}
			}
		}
	}

	cout << res % 1'000'000'007 << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  if(a+b>c+d)
  cout<<"Left"<<endl;
  else if(a+b<c+d)
  cout<<"Right"<<endl;
  else
  cout<<"Balanced"<<endl;

  return 0;
}


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

using namespace std;

int main() {
    vector<int> x;
    int i = 0, n;
    
    while (1) {
        cin >> n;
        x.push_back(n);
        
        if(x[i] == 0) break;

        i++;
    }
    
    for(i = 0; i < x.size(); i++) {
        if(x[i] == 0) break;
        
        cout << "Case " << i+1 << ": " << x[i] << endl;
    }
}

Measured memory_bytes: 1320
n = int(input())

def char(x):
    return chr(x + 97)

lap = 1
m = 26
while n > m:
    n -= m
    lap += 1
    m *= 26

n -= 1
ans = ''
for _ in range(lap):
    ans = char(n % 26) + ans
    n //= 26

print(ans)

Measured memory_bytes: 9184
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            out.println(n * 800 - (n / 15) * 200);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 21204
#include<iostream>
#include<math.h>

using namespace std;

int main(void)
{
	while(1)
	{
		int a,b,c,n;
		if(!(cin>>a>>b>>n))break;
		int ans=0;
		for(int i=0;i<n;i++)
		{
			a%=b;
			a*=10;
			ans+=a/b;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, a[N], ptr, b[N];
bool us[N];
ll k;
main() {
  file("threesum");
  ios;
  cin >> n >> k;
  fo(i, 1, n, 1) cin >> a[i];
  int cur = 1;
  while (!us[cur]) {
    us[cur] = 1;
    cur = a[cur];
    --k;
    if (!k) return !(cout << cur);
  }
  fo(i, 1, n, 1) us[i] = 0;
  while (!us[cur]) {
    us[cur] = 1;
    b[ptr++] = cur;
    cur = a[cur];
  }
  k %= ptr;
  cout << b[k];
  return 0;
}
/**

*/


Measured memory_bytes: 6396
s = input()
ans = 0
i = 0
before = '#'
while(i<len(s)):
    if(s[i]!=before):
        before = s[i]
        i += 1
        ans += 1
    else:
        before = '#'
        i += 2
        ans += 1

if(i!=len(s)):
    ans -= 1

print(ans)

Measured memory_bytes: 3500
import java.util.Objects;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final int p = 3;
        switch (p) {
        case 1:
            P1.p1();
            break;
        case 2:
            P2.answer();
            break;
        case 3:
            P3.answer();
            break;
        }
    }
}

class P3 {
    static void answer() {
        final Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        final int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        final int res = calc(array);
        System.out.println(res);
    }

    static int calc(final int[] array) {
        int max = 0;
        for (int i = 0; i < array.length; i++) {
            if (max > array.length - i) {
                break;
            }
            final int res = measure(array, i);
            max = Math.max(res, max);
        }
        return max;
    }

    private static int measure(final int[] array, final int pos) {
        int times = 0;
        for (int i = pos; i < array.length - 1; i++) {
            if (array[i] >= array[i + 1]) {
                times++;
            } else {
                break;
            }
        }
        return times;
    }

}

class P2 {
    static void answer() {
        final Scanner sc = new Scanner(System.in);
        final int a = sc.nextInt();
        final int b = sc.nextInt();
        final int res = calc(a, b);
        System.out.println(res);
    }

    static int calc(final int a, final int b) {
        final int per = a - 1;
        final int remain = b - 1;
        final int x = remain / per;
        if (remain - (per * x) > 0) {
            return x + 1;
        }
        return x;
    }
}

class P1 {

    static void p1() {
        final Scanner sc = new Scanner(System.in);
        final String yohou = sc.nextLine();
        final String jissai = sc.nextLine();

        final int res = calc(yohou, jissai);
        System.out.println(res);
    }

    static int calc(final String yohou, final String kekka) {
        int res = 0;
        for (int i = 0; i < 3; i++) {
            if (Objects.equals(yohou.charAt(i), kekka.charAt(i))) {
                res++;
            }
        }
        return res;
    }
}

Measured memory_bytes: 49324
import math

x = int(input())

max_num = int(math.sqrt(x * 2))
numlist = [True for i in range(x * 2 + 1)]

for i in range(2, max_num):
    if not numlist[i]:
        continue
    for j in range(i * 2, x * 2 + 1, i):
        numlist[j] = False

numlist[0:x] = [False for i in range(x)]

print(numlist.index(True))


Measured memory_bytes: 6296
uses crt;
var dp,h:array[1..100000] of longint;
    i,j,n,k:longint;
function min(a,b:longint):longint;
begin
    if a<b then exit(a) else exit(b);
end;
begin
    clrscr;
    readln(n,k);
    for i := 1 to n do read(h[i]);
    dp[1]:=0;
    for i := 2 to n do dp[i]:=maxlongint;
    for i:=2 to n do
    for j := i-k to i-1 do if j>0 then dp[i]:=min(dp[i],dp[j]+abs(h[i]-h[j]));
      writeln(dp[n]);
      readln;
end.


Measured memory_bytes: 896
#include <iostream>
using namespace std;
 int main(){
 string S;
 cin >> S;
 int L = S.size();
 string ans = "AC";
 if(S[0] != 'A'){
 ans = "WA";
 }
 int cnt = 0;
 for(int i = 1; i < L; ++i){
 if(isupper(S[i])){
 if(i == 1 || i == L - 1 || S[i] != 'C'){
 ans = "WA";
 }
 ++cnt;
 }
 }
 if(cnt != 1){
 ans = "WA";
 }
 cout << ans << endl;
 return 0;
 }

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

int main() {
    int N,K;
    cin >> N >> K;
    int ans = 0;
    for (int i = 0;i < N;i++) {
        int x;
        cin >> x;
        ans += min(abs(x-K)*2,x*2);
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)

long long f(long long n)
{
    long long res = 0;
    while (n > 0)
    {
        res += n % 10;
        n /= 10;
    }
    return res;
}
double g(long long n)
{
    return (double)(n) / f(n);
}
int main()
{
    vector<long long> res;
    long long base = 1;

    rep(i, 0, 15)
    {
        rep(r, 1, 150)
        {
            res.push_back(base * (r + 1) - 1);
        }
        base *= 10;
    }
    sort(res.begin(), res.end());
    res.erase(unique(res.begin(), res.end()), res.end());

    for (long long i = 0; i < res.size(); ++i)
    {
        for (long long j = i + 1; j < res.size(); ++j)
        {
            if (g(res[i]) > g(res[j]))
            {
                res.erase(res.begin() + i--);
                break;
            }
        }
    }
    long long K;
    cin >> K;
    for (long long i = 0; i < K; ++i)
    {
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
const int mxN=3e3+5,M=1e9+7;
//did u check when n=1?
//is mxN correct?
int dp[mxN][mxN];
int v[mxN],pref[mxN],n;
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>v[i];
        pref[i+1]=pref[i]+v[i];
    }
    for(int i=n-1;i>=0;i--){
        for(int j=i;j<n;j++){
            if(i==j)dp[i][j]=v[i];
            else{
                dp[i][j]=(pref[j+1]-pref[i])-min(dp[i][j-1],dp[i+1][j]);
            }
        }
    }
    cout<<2*dp[0][n-1]-pref[n];
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  rep(i, N) cin >> S[i];

  map<string, int> dic;

  int mx = 0;
  rep(i, N) {
    dic[S[i]]++;
    mx = max(mx, dic[S[i]]);
  }

  vector<string> ans;
  
  // for(const auto& [key, value] : dic) {
  //   if(value==mx) {
  //     ans.push_back(key);
  //   }
  // }

  for(auto itr = dic.begin(); itr != dic.end(); ++itr) {
      if(itr->second==mx) ans.push_back(itr->first);
  }

  sort(ans.begin(), ans.end());

  rep(i, ans.size()) {
    cout << ans[i] << endl;
  }




  return 0;
}

Measured memory_bytes: 28404
def hantei(W,H,x,y,r):
 if x-r < 0:
  return 'No'
 if x+r > W:
  return 'No'
 if y-r < 0:
  return 'No'
 if y+r > H:
  return 'No'
 else:
  return 'Yes'

W,H,x,y,r = map(int,raw_input().split())
print hantei(W,H,x,y,r)

Measured memory_bytes: 4204
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
ll dif[MAXN],k;
int x[MAXN],dp[MAXN][60],ind[MAXN],tind[MAXN],n,m;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",&x[i]);
    scanf("%d %lld",&m,&k);
    for(int i=1;i<=n;++i) dp[i][0]=i;
    for(int i=1;i<=m;++i){
        int tmp;scanf("%d",&tmp);
        swap(dp[tmp][0],dp[tmp+1][0]);
    }
    for(int j=1;((ll)1<<j)<=k;++j){
        for(int i=1;i<=n;++i){
            dp[i][j]=dp[dp[i][j-1]][j-1];
        }
    }
    for(int i=1;i<=n;++i) ind[i]=i;
    for(int j=59;k;--j){
        if(((ll)1<<j)>k) continue;
        k-=(ll)1<<j;
        for(int i=1;i<=n;++i) tind[i]=dp[ind[i]][j];
        for(int i=1;i<=n;++i) ind[i]=tind[i];
    }
    for(int i=1;i<=n;++i) dif[i]=x[ind[i]]-x[ind[i]-1];
    for(int i=2;i<=n;++i) dif[i]+=dif[i-1];
    for(int i=1;i<=n;++i) printf("%lld\n",dif[i]);
    return 0;
}

Measured memory_bytes: 26624
#include <iostream>

using namespace std;

int cut(int n, int r, int s[60]){
	int p, c;
	int temp[60] = {0};

	for(int i = 0;i < r;i++){
		cin >> p >> c;
		for(int j = 0;j <= n;j++){
			temp[j] = s[j];
		}
		for(int j = 0;j < p;j++){
			s[n - p - c + j + 2] = temp[n - p + j + 2];
		}
		for(int j = 0;j < c;j++){
			s[n - c + 1 + j] = temp[n - p - c + j + 2];
		}
	}

	return s[n];
}

int main(){
	int n, r, p, c, s[60];
	while(1){
		cin >> n >> r;
		if(n == 0 && r == 0) break;

		for(int i = 0;i <= n;i++){
			s[i] = i;
		}

		int ans = cut(n, r, s);

		cout << ans << endl;
	}

	return 0;
}

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

s=[0]*8
count=0
ans=0

for i in range(n):
  if a[i]<400:
    s[0]+=1
  elif a[i]<800:
    s[1]+=1
  elif a[i]<1200:
    s[2]+=1
  elif a[i]<1600:
    s[3]+=1
  elif a[i]<2000:
    s[4]+=1
  elif a[i]<2400:
    s[5]+=1
  elif a[i]<2800:
    s[6]+=1
  elif a[i]<3200:
    s[7]+=1
  else:
    count+=1

for j in range(8):
  if s[j]!=0:
    ans+=1

if ans==0:
  print(1,count)
  exit()
else:
  print(ans,ans+count)

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n, m;
  cin >> n >> m;
  n--; m--;
  cout << n * m;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int array[] = {7, 17, 37, 47, 67, 97, 107, 127, 137, 157, 167, 197, 227, 257, 277, 307, 317, 337, 347, 367, 397, 457, 467, 487, 547, 557, 577, 587, 607, 617, 647, 677, 727, 757, 787, 797, 827, 857, 877, 887, 907, 937, 947, 967, 977, 997, 1087, 1097, 1117, 1187, 1217, 1237, 1277, 1297, 1307, 1327, 1367, 1427, 1447, 1487, 1567, 1597, 1607, 1627, 1637, 1657, 1667, 1697, 1747, 1777, 1787, 1847, 1867, 1877, 1907, 1987, 1997};

int main () {
    int n;
    scanf("%d", &n);
    for(int i=0; i< n; i++) {
        printf("%d ", array[i]);
    }
    return 0;
}

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

bool compare(pair<long long, long long> a, pair<long long, long long> b) {
  return a.second > b.second;
}

int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (long long i=0; i<N; i++) cin >> A[i];
  sort(A.begin(), A.end());

  vector<pair<long long, long long>> p(M);
  for (long long i=0; i<M; i++)  {
    long long B, C;
    cin >> B >> C;
    p[i] = make_pair(B, C);
  }
  sort(p.begin(), p.end(), compare);

  // for (long long i=0; i<M; i++)  cout << p[i].first << " " << p[i].second << endl;

  int minitr = 0;
  for (long long i=0; i<M; i++) {
    long long b = p[i].first;
    long long c = p[i].second;

    if (c < A[minitr]) {
      break;
    } else {
      long long cnt = 0;
      for (long long j=minitr; j<N; j++) {
        if (A[j] < c && cnt < b) {
          A[j] = c;
          minitr++;
          cnt++;
        } else {
          break;
        }

        // for (long long i=0; i<N; i++) cout << A[i] << " ";
        // cout << endl;
      }
    }
  }

  long long sum = 0;
  for (long long i=0; i<N; i++) sum += A[i];

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 2560
import heapq

def resolve():
    N = int(input())
    P = list(map(int, input().split()))
    min_p = P[0]
    cnt = 0
    for i in range(0, N):    
        if P[i] <= min_p:
            cnt += 1
            min_p = P[i]
    print(cnt)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 24872
#include <iostream>
using namespace std;
int main(){
 	int cnt=0,n,m,sum=0;
  	cin>>n>>m;
  	int a[n];
  	for(int i=0;i<n;i++){
     	cin>>a[i];
      	sum+=a[i];
    }
  	for(int i=0;i<n;i++){
     	if(a[i]*4*m>=sum){
         	cnt++; 
        }
    }
  	if(cnt>=m){
    	cout<<"Yes";  
    }
  	else cout<<"No";
}

Measured memory_bytes: 3588
// 8クィーン問題
#include<iostream>
#include<cassert>

using namespace std;

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N];

void initialize()
{
    for(int i = 0; i < N; i++)
    {
        row[i] = FREE;
        col[i] = FREE;
    }

    for(int i = 0; i < 2 * N - 1; i++)
    {
        dpos[i] = FREE;
        dneg[i] = FREE;
    }
}

void printBoard()
{
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            if( X[i][j] )
            {
                if( row[i] != j )
                {
                    return;
                }
            }
        }
    }

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            cout << ( ( row[i] == j ) ? "Q" : ".");
        }

        cout << endl;
    }
}

void recursive(int i)
{
    if( i == N )
    {
        // クィーンの配置に成功
        printBoard();
        return;
    }

    for(int j = 0; j < N; j++)
    {
        // (i, j)が他のクィーンに襲撃されている場合は無視
        if( NOT_FREE == col[j] ||
            NOT_FREE == dpos[i + j] ||
            NOT_FREE == dneg[i - j + N - 1] )
        {
            continue;
        }

        // (i, j)にクィーンを配置する
        row[i] = j;
        col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;

        // 次の行を試す
        recursive(i + 1);

        // (i, j)に配置されているクィーンを取り除く
        row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }

    // クィーンの配置に失敗
}

int main()
{
    initialize();

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            X[i][j] = false;
        }
    }

    int k;

    cin >> k;

    for(int i = 0; i < k; i++)
    {
        int r,c;

        cin >> r >> c;

        X[r][c] = true;
    }

    recursive(0);

    return 0;
}



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

int main() {
  int n,q;
  string S;
  cin>>n>>q>>S;
  vector<int> a(n,0);
  for(int i=0;i<n-1;i++){
    if(S[i]=='A'&&S[i+1]=='C') a[i+1]++;
  }
  vector<int> s(n+1,0);
  for(int i=0;i<n;i++){
    s[i+1]=s[i]+a[i];
  }
  
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    cout<<s[r]-s[l]<<endl;
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define rsort_v(v) std::sort(v.rbegin(), v.rend())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int a, b, c;
int main() {
	in(ll, N, A, B);
	loop(i, N) {
		in(ll, p);
		if (p <= A) ++a;
		else if (p <= B) ++b;
		else ++c;
	}
	out(min({ a, b, c }));
}


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

static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for ( int i = 0; i <= m; i++ ) c[i][0] = 0;
  for ( int j = 1; j <= n; j++ ) c[0][j] = 0;

  for ( int i = 1; i <= m; i++ ) {
    for ( int j = 1; j <= n; j++ ) {
      if ( X[i] == Y[j] ) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }

  return maxl;
}

int main() {
  string s1, s2;
  int n; cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}


Measured memory_bytes: 7120
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <iomanip>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    double ans = 0.0;
    rep(i, 1, n + 1)
    {
        int x = i;
        double c = 1.0;

        while (x < k)
        {
            //cerr << x << "," << n << endl;
            x *= 2;
            c /= 2;
        }
        // cerr << c << endl;
        ans += c;
    }
    cout << std::setprecision(18) << ans / (double)n << 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;
const int INF = 2147483647;
using ll = long long;
// cout << typeid('変数').name() << endl;

bool which(char c){
    bool wh=0;
    if(c=='1') wh=1;
    return wh;
}

int main() {
    int n,k;
    cin >> n >> k;
    vector<double> p(n);
    for (int i=0;i<n;++i){
        double a;
        cin >> a;
        p.at(i) = (a+1)/2;
    }
    vector<double> sum(n+1);
    for(int i=0;i<n;++i){
        sum.at(i+1)+=sum.at(i)+p.at(i);
    }
    double nax = -1.l;
    for(int i=0;i<n-k+1;++i){
        nax = max(nax,sum.at(i+k)-sum.at(i));
    }
    printf("%.10lf",nax);
    return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#include<math.h>
typedef long long int ll;

int main()
{
    ll n, i, temp, z, mx1=0,mx2=0,i1,i2;
    scanf("%lld", &n);
    ll ara[n];
    for(i=0;i<n;i++){
        scanf("%lld", &ara[i]);
        if(ara[i]>mx1){
            mx1 = ara[i];
            i1 = i;
        }
    }
    sort(ara,ara+n);
    for(i=0;i<n;i++){
        if(i==i1) printf("%lld\n", ara[n-2]);
        else printf("%lld\n", ara[n-1]);
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    ll k;
    cin >> k;
    vll p(n);
    rep(i, n) cin >> p[i];
    vll c(n);
    rep(i, n) cin >> c[i];
    ll ans=0;
    rep(i,n){
        vector<pair<ll,ll>> d(n,{-1,-1});
        ll money=0;
        ll koma=i;
        ll maxmoney=0;
        bool flag=false;
        rep(j,k){
            if(d[koma].second!=-1&&!flag){
                ll ltime=j-d[koma].second;
                ll lmoney=money-d[koma].first;
                ll nokori=k-j;
                money+=((nokori/ltime)-1)*lmoney;
                j=k-(nokori%ltime+ltime);
                flag=true;
                if(j!=k){
                    koma=p[koma]-1;
                    money+=c[koma];
                    if(j==0) maxmoney=money;
                    else maxmoney=max(maxmoney,money);
                }
            }else{
                d[koma].first=money;
                d[koma].second=j;
                koma=p[koma]-1;
                money+=c[koma];
                if(j==0) maxmoney=money;
                else maxmoney=max(maxmoney,money);
            }
        }
        maxmoney=max(money,maxmoney);
        if(i==0) ans=maxmoney;
        else ans=max(ans,maxmoney);
    }
    cout<<ans<<endl;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1 << 30;
//const ll INF = 1LL << 60;

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

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> abc(n, vector<int>(3));
  rep(i, n) {
    rep(j, 3) {
      cin >> abc.at(i).at(j);
    }
  }
  vector<vector<int>> dp(n + 1, vector<int>(3, -INF));
  dp.at(0).at(0) = 0;
  dp.at(0).at(1) = 0;
  dp.at(0).at(2) = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) {
          continue;
        }
        chmax(dp.at(i + 1).at(j), dp.at(i).at(k) + abc.at(i).at(j));
      }
    }
  }
  cout << max({dp.at(n).at(0), dp.at(n).at(1), dp.at(n).at(2)}) << endl;
  return 0;
}


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

int main()
{
    int N;
    std::cin >> N;

    std::vector<int> H(N);
    for (int i = 0; i < N; i++) {
        std::cin >> H[i];
    }

    int ans = 0;
    bool shower;
    do {
        shower = false;
        for (int i = 0; i < N; i++) {
            if (H[i] == 0) continue;

            int j;
            for (j = i+1; j < N; j++) {
                if (H[j] == 0) break;
            }

            int n = 1000;
            for (int k = i; k < j; k++) {
                n = std::min(n, H[k]);
            }
            for (int k = i; k < j; k++) {
                H[k] -= n;
            }

            ans += n;
            shower = true;
            break;            
        }
    }while(shower == true);

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[n];
    ll sum=0;
    for(int i=0;i<n;i++)
       {
           cin>>a[i];
           sum+=a[i];
       }
       bool f=false;
       if(sum%2!=0)
       {
           f=true;
       }
    ll fac=4*m;
    sum/=fac;
    if(f) sum++;
    sort(a,a+n);
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]>=sum)
            ans++;
    }
  if(ans>=m)
        cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int n,x;
  cin >> n >> x;
  vector<int> m(n);

  for(int i = 0; i < n; i++){
    int temp;
    cin >> temp;
    x -= temp;
    m[i] = temp;
  }
  
  sort(m.begin(), m.end());

  int ans = n + (x/m[0]) ;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]
def euclid(a,b):
  x=max(a,b)
  y=min(a,b)
  z=x%y
  if z!=0:
    return euclid(y,z)
  else:
    return y
g=euclid(A[0],A[1])
for i in range(2,len(A)):
  g=euclid(A[i],g)
print(g)

Measured memory_bytes: 14224
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>
#include<cmath>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
char str[26];
std::map<char,int> M ;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  cin >> N ;
   int t[N] ;
   int x[N] ;
   int y[N] ;

   REP(i,N){
    cin >> t[i] ;
    cin >> x[i] ;
    cin >> y[i] ;
   }
   REP(i,N){
    if(t[i] < (x[i]+y[i]) )
    {
      cout << "No" << endl ;
      return 0 ;
    }
    t[i] -= (x[i] + y[i]) ;
    if( t[i] %2 ==0){
    }else{

      cout << "No" << endl ;
      return 0 ;
    }


   }

      cout << "Yes" << endl ;
  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}



Measured memory_bytes: 1408
#include <iostream>
//#include <fstream>

using namespace std;

int main()
{
/*
æ 1 iK¿à	 10 m3ÜÅ	 î{¿à 1150 ~
æ 2 iK¿à	 10 m3´ß 20 m3ÜÅ	 1 m3 ½è 125 ~
æ 3 iK¿à	 20 m3´ß 30 m3ÜÅ	1 m3 ½è 140 ~
æ 4 iK¿à	 30 m3´ßª	 1 m3 ½è 160 ~
*/

//	cut here before submit 
//	freopen ("testcase.waterbill", "r", stdin );
	int n, m;

	while (cin >> n && n != -1 ){
		int res = 1150;
		
		if (n > 10 ){
			if (n <= 20){
				m = n - 10;
				res += m*125;
			}else if (n > 20 && n <= 30 ){
				res += 1250;
				m = n - 20;
				res += m*140;
			}else { //if (n > 30 )
				res += 1250;
				res += 1400;
				m = n - 30;
				res += m*160;
			} // end if
		} // end if
		cout << (4280 - res) << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
let main = (standardInput) => {
    let lenghtList = standardInput.split(' ');
    let varticalLength = parseInt(lenghtList[0]);
    let horizonLength = parseInt(lenghtList[1]);

    console.log(varticalLength * horizonLength + ' ' + 2 * (varticalLength + horizonLength));
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));



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

struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<string, int> SP;
#define rep(i, n) for(int i = 0; i < n; ++i)

const int INF = 1e9 + 7;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

// int binary_search(vector<int> S, int t, int n){
//     int lb = 0, ub = n;
//     while (ub - lb > 1) {
//         int mid = (lb + ub) / 2;
//         if (S[mid] >= t) {
//             ub = mid;
//         }
//         else {
//             lb = mid;
//         }
//     }

//     return ub;
// }

// int main(){
//     cin.tie(0);
//     ios::sync_with_stdio(false);
//     // vvvi V (50, vvi(50, vi(2500)));

//     int N;
//     cin >> N;

//     vector<int> A(N), S(N);
//     rep(i, N-1){
//         cin >> A[i];
//     }

//     // cout << "end input" << endl;

//     S = A;
//     sort(S.begin(), S.end());

//     rep(i, N){
//         cout << N - binary_search(S, A[i], N) << endl;
//     }

//     return 0;
// }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // vvvi V (50, vvi(50, vi(2500)));

    int N;
    cin >> N;

    vector<int> A(N+1);
    rep(i, N-1){
        int tmp;
        cin >> tmp;
        A[tmp]++;
    }

    rep(i, N){
        cout << A[i+1] << endl;
    }

    return 0;
}

Measured memory_bytes: 3964
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
int main(){
  int n;
  cin>>n;
  vll a(n);
  
  REP(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int x=n/2;
  cout<<a[x]-a[x-1]<<endl;
}


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

int main()
{
  int N,M ;  //N=[1,3] M=[0,5] 
  cin>>N>>M ;
  /*情報が0の場合(M==0)かつ、N=1のとき*/
  if(N==1&&M==0){
    cout<<0<<endl ;
    return 0 ;
  }
  
  vector<char>ans(N,'*') ; //ansは求める整数,10進数でN桁、0は一桁とする
  for(int i=0;i<M;i++){
    int s ;
    char c ;
    cin>>s>>c ;
    if(ans.at(s-1)=='*') ans.at(s-1)=c ;
    else if(ans.at(s-1)!=c){
      cout<<-1<<endl ;
      return 0 ;
    }
  }
  
  /*その数字が2桁以上で、先頭が0*/
  if(N>=2&&ans.at(0)=='0'){
    cout<<-1<<endl ;
    return 0 ;
  }
  /*先頭が未定*/
  if(ans.at(0)=='*') ans.at(0)='1' ;
    
  for(int i=0;i<N;i++){
    if(ans.at(i)=='*') ans.at(i)='0' ;
    cout<<ans.at(i) ;
  }
  
  return 0 ;
}

Measured memory_bytes: 256
using System;

public class Program
{
	public static void Main(string[] args)
	{
		var ss = new StreamScanner();
		//---------------------------------
		while (true)
		{
			var y = ss.Next<int>();
			var x = ss.Next<int>();

			if (x == 0 && y == 0)
			{
				break;
			}

			for (int j = 0; j < y; j++)
			{
				for (int i = 0; i < x; i++)
				{
					if (j % 2 == 0 && i % 2 == 0)
					{
						Console.Write("#");
					}
					else if (j % 2 == 0 && i % 2 == 1)
					{
						Console.Write(".");
					}
					else if (j % 2 == 1 && i % 2 == 0)
					{
						Console.Write(".");
					}
					else if (j % 2 == 1 && i % 2 == 1)
					{
						Console.Write("#");
					}

				}
				Console.WriteLine("");
			}
			Console.WriteLine("");
		}

		/*
		//????????????int, double, string?????????????????£????????????
		int i = ss.Next<int>();
		double d = ss.Next<double>();
		string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		int[] array = ss.Next<int>(10);
		*/
		//---------------------------------
	}
}



public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 9836
n,m=map(int,input().split())
h=list(map(int,input().split()))
anslist=[1]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1]:
    anslist[b-1]=0
  elif h[a-1]==h[b-1]:
    anslist[a-1]=0
    anslist[b-1]=0
  else:
    anslist[a-1]=0
  #print(anslist)
print(anslist.count(1))

Measured memory_bytes: 20148
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定
 
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL
 
int main(void) {
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a;
        cin >> a;
        n -= a;
    }
    if (n < 0) cout << "-1" << endl;
    else cout << n << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define MOD 1000000007

using namespace std;

#define N 2097152

ll mat[22][22];
ll dp[21][N+5];

ll get(ll i, ll mask, ll &n)
{
    if(i == n)
        return 1;
    if(dp[i][mask]!=-1)
        return dp[i][mask];
    ll ans = 0;  
    for(ll j=0;j<n;j++)
    {
        if(mat[j][i] == 0)
            continue;
        //cout<<"ex at "<<i+1<<" "<<j+1<<"\n";    
        if((1LL<<j)&mask)
            ans+=get(i+1,mask^((1LL<<j)),n), ans%=MOD;
    }
    
    return dp[i][mask] = ans;
}

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   for(ll i=0;i<n;i++)
        for(ll j=0;j<n;j++)
            cin>>mat[i][j];
   memset(dp,-1,sizeof(dp));
           
   cout<<get(0,(1LL<<n) - 1,n);           
   
   return 0;
}

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

int main() {
  int N;
  cin>>N;
  int x;
  int ans=0,aans=0;
  vector<int>b(10);
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
    x=a[i]/400;
    if(x<8)b[x]=1;
    else b[8]++;
  }
  for(int i=0;i<8;i++)ans=ans+b[i];
  cout<<max(ans,1)<<" ";
  cout<<ans+b[8]<<endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define INF (1<<29)
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;

int mpow(int a,int x);
int m_inv(int n){return mpow(n,mod-2);}

int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
    int N;
    cin>>N;
    map<int,int> mp;
    rep(i,N){
    	int a;
    	cin>>a;
    	mp[a]=1-mp[a];
    }
    int ans=0;
    for(auto itr=mp.begin();itr!=mp.end();++itr){
    	ans+=itr->second;
    }
    cout<<ans<<endl;
}

int mpow(int a,int x){
	int ans=1;
	while(x>0){
		if(x%2==1) (ans*=a)%=mod;
		(a*=a)%=mod;
		x>>=1;
	}
	return ans;
}

Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<queue>
using namespace std;

int main(){
    int n,t[100],m,p,x;
    int sub[100];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    cin>>m;
    int sum=0;
    for(int i=0;i<n;i++) sum+=t[i];
    for(int i=0;i<m;i++){
        cin>>p>>x;
        int sub=t[p-1]-x;
        int ans=sum-sub;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 888
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
	int n, m, z = 0;
	ll a[200005] = {}, b[200005] = {}, k;
	cin >> n >> m >> k;
	for (int i = 1 ; i <= n ; i++) cin >> a[i];
	for (int i = 1 ; i <= m ; i++) cin >> b[i];
	for (int i = 1 ; i <= n ; i++) a[i] += a[i - 1];
	for (int i = 1 ; i <= m ; i++) b[i] += b[i - 1];
	for (int i = 0 ; i <= n ; i++) {
		if (a[i] <= k) {
			int l = 0, r = m + 1;
			while (l + 1 < r) {
			 	int x = (l + r) / 2;
				if (a[i] + b[x] <= k) {
					l = x;
				}
				else {
					r = x;
				}
			}
			z = max(z, i + l);
		}
	}
	cout << z;
}

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

#define PI acos(-1.0)
#define INF 2e9
#define INFLL 9e18
#define EPS 1e-9
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll a[300000],b[300000],c[300000];


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(0);
    cout << fixed;
    //freopen("a.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll t,cnt=0,ans=0,i,n,j,k;
    cin >> n;
    for(i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    for(i=0;i<n-2;i++){
        for(j=i+1;j<n-1;j++){
            if(a[i]==a[j])continue;
            ans+=(a[i]+a[j]);
            for(k=j+1;k<n;k++){
                if(a[i]==a[k]||a[j]==a[k])continue;
                if(a[k]<ans)cnt++;
            }
            ans=0;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

inline bool read(){
	char ch[10];
	while( ch[0] = (char)getchar(), ch[0] < '0' || ch[0] > '9' );
	for( int i = 1; i <= 3; ++i ) ch[i] = (char)getchar();
	for( int i = 0; i <= 1; ++i )
		if( ch[i] == ch[ i+1 ] && ch[ i+1 ] == ch[ i+2 ] ) return 1;
	return 0;
}

int main(){
	puts( read() ? "Yes" : "No" );
	return 0;
}

Measured memory_bytes: 128