akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int n = 100, N = 101;
int ans[N][N];

int main() {
    //freopen("input.txt", "r", stdin);
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (j <= n / 2) {
                ans[i][j] = 0;
            } else {
                ans[i][j] = 1;
            }
        }
    }
    a -= 1;
    b -= 1;
    int curRow = 1;
    while (b >= 1) {
        for (int j = 1; j <= n / 2 - 1; ++j) {
            if (0 == b) {
                break;
            }
            if (j % 2 == 1) {
                ans[curRow][j] = 1;
                --b;
            }
        }
        curRow += 2;
    }
    curRow = 1;
    while (a >= 1) {
        for (int j = n / 2 + 2; j <= n; ++j) {
            if (0 == a) {
                break;
            }
            if (j % 2 == 1) {
                ans[curRow][j] = 0;
                --a;
            }
        }
        curRow += 2;
    }
    printf("%d %d\n", n, n);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (ans[i][j] == 1) {
                printf("#");
            } else {
                printf(".");
            }
        }
        printf("\n");
    }
    return 0;
}


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

#define forsn(i,s,n) for(int i = (int)s; i < (int) n;i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for(int i = (int)(n-1); i >= (int) s;i--)
#define dforn(i,n) dforsn(i,0,n)
#define si(a) ((int)(a).size())
#define all(a) a.begin(),a.end()
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
using pii = pair<int,int>;
using ll = long long int;
using vi = vector<int>;


int main(){
        fastio;

        string s;
        cin >> s;
        ll white=0;
        ll res=0;
        dforn(i,si(s)){
            if(s[i]=='W')white++;
            else res+=white;
        }

        cout << res << endl;


        return 0; 
}


Measured memory_bytes: 720
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string s; cin >> s; ll ans = 0;
  
  string now = ""; string before = "";
  
  for(ll i=0; i < ll(s.size()); i++){
    now += s[i];
    if(before != now){
      ans++;
      before = now;
      now = "";
    }
  }
  
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 3768
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

struct edge {
    int time, x, y;
};

int main(){
    int N; cin >> N;
    vector<edge> a(N+1);
    a[0] = {0,0,0};
    for (int i = 1; i <= N; i++){
        cin >> a[i].time >> a[i].x >> a[i].y;
    }
    //sort(a.begin(),a.end());
    
    int xx = 0,yy = 0;
    for (int i = 1; i <= N; i++){
        if (abs(xx-a[i].x) + abs(yy-a[i].y) > a[i].time - a[i-1].time){
            cout << "No" << endl;
            return 0;
        } 
        int tmp = - abs(xx-a[i].x) - abs(yy-a[i].y) + (a[i].time - a[i-1].time);
        if (tmp % 2 != 0){
            //cout << tmp << endl;
            cout << "No" << endl;
            return 0;
        }
        xx = a[i].x; yy = a[i].y;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
bool ok[50][30];
int bfs[50];
int v[50];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)
			for(int j=0;j<30;j++)
				ok[i][j]=false;
		int st=0;
		for(int i=0;i<a;i++){
			int b;
			scanf("%d",&b);
			int val=999999;
			for(int j=0;j<b;j++){
				int c;
				scanf("%d",&c);
				val=min(val,c-1);
				ok[i][c-1]=true;
			}
			st=max(st,val);
		}
		int ret=999999;
		for(int i=0;i<a;i++){
			for(int j=st;j<30;j++){
				for(int k=0;k<a;k++){
					v[k]=0;
					bfs[k]=-1;
				}
				priority_queue<pair<int,int> > Q;
				Q.push(make_pair(j,i));
				bfs[i]=j;
				while(Q.size()){
					int day=Q.top().first;
					int at=Q.top().second;
				//	printf("%d %d\n",day,at);
					Q.pop();
					if(v[at])continue;
					v[at]=1;
					for(int k=0;k<a;k++){
						if(v[k])continue;
						for(int l=day;l>=0;l--){
							if(ok[at][l]&&ok[k][l]&&bfs[k]<l){
								bfs[k]=l;
								Q.push(make_pair(l,k));
								break;
							}
						}
					}
				}
				bool dame=false;
				for(int k=0;k<a;k++)if(!v[k])dame=true;
				if(!dame){
					ret=min(ret,j+1);
				//	printf("%d %d\n",i,j);
					break;
				}
			}
		}
		if(ret==999999)printf("-1\n");
		else printf("%d\n",ret);
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

string solve(int r, int l) {
  // cout << "solving " << r << " " << l << endl;
  int sum = r + l;
  if (sum % 2 == 0) {
    string ans = "";
    for (int i = 0; i < r - 1; i++) {
      ans += "0 ";
    }

    ans += to_string(sum / 2);
    ans += " ";
    ans += to_string(sum / 2);
    ans += " ";

    for (int i = 0; i < l - 1; i++) {
      ans += "0 ";
    }

    return ans;
  } else {
    string ans = "";
    for (int i = 0; i < r - 1; i++) {
      ans += "0 ";
    }

    string big = to_string(sum / 2 + 1);
    string small = to_string(sum / 2);

    // cout << "big " << big << endl;
    // cout << "small " << small << endl;
    if (r > l) {
      if (r % 2 == 0) {
        ans += small;
        ans += " ";
        ans += big;
        ans += " ";
      } else {
        ans += big;
        ans += " ";
        ans += small;
        ans += " ";
      }
    } else {
      if (l % 2 == 0) {
        ans += big;
        ans += " ";
        ans += small;
        ans += " ";
      } else {
        ans += small;
        ans += " ";
        ans += big;
        ans += " ";
      }
    }

    for (int i = 0; i < l - 1; i++) {
      ans += "0 ";
    }

    return ans;
  }
}

int main() {
  string S;
  cin >> S;
  vector<pair<int, int>> arr;

  string status = "readR";
  int lCount = 0;
  int rCount = 0;
  for (int i = 0; i < S.size(); i++) {
    char curChar = S[i];
    if (status == "readR") {
      if (curChar == 'R') {
        rCount++;
      } else {
        status = "readL";
        lCount++;
      }
    } else {
      if (curChar == 'L') {
        lCount++;
      } else {
        arr.emplace_back(rCount, lCount);
        rCount = 1;
        lCount = 0;
        status = "readR";
      }
    }
  }
  arr.emplace_back(rCount, lCount);

  for (int i = 0; i < arr.size(); i++) {
    cout << solve(arr[i].first, arr[i].second);
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 1144
#include <stdio.h>
#include <math.h>

int main()
{
  int ho,kaku;
  double x=0,y=0;
  int tmp=90;
  scanf("%d,%d",&ho,&kaku);
  while (!((ho==0) && (kaku==0))){
    x+=ho*cos(M_PI*tmp/180);
    y+=ho*sin(M_PI*tmp/180);
    tmp+=-kaku;
    scanf("%d,%d",&ho,&kaku);
  }
  printf("%d\n%d\n",(int)x,(int)y);
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
# define M_PIl        3.141592653589793238462643383279502884
using namespace std;

typedef long long ll;
typedef long double ld;
#define faster       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  faster;
  ll n,m;
  cin >> n >> m;
  cout << n*m << endl;
  
}

Measured memory_bytes: 3652
N,K=map(int,input().split())
D=input().split()

while 1:

    strN=str(N)
    flag=0
    for n in range(len(strN)):
        if strN[n] in D:
            flag=1
            break
    if flag:
        N+=1
    else:
        print(N)
        exit()


Measured memory_bytes: 39536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iM = int.Parse(sS[1]);
            int iC = int.Parse(sS[2]);
            List<int> lstB = new List<int>();
            sS = System.Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < sS.Length; i++) { lstB.Add(int.Parse(sS[i])); }
            List<List<int>> lstA = new List<List<int>>();
            for (int i = 0; i < iN; i++)
            {
                sS = System.Console.ReadLine().Trim().Split(' ');
                List<int> lstT = new List<int>();
                for (int j = 0; j < sS.Length; j++) { lstT.Add(int.Parse(sS[j])); }
                lstA.Add(lstT);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            for (int i = 0; i < lstA.Count; i++)
            {
                int iSum = iC;
                for (int j = 0; j < lstA[i].Count; j++)
                {
                    iSum += lstA[i][j] * lstB[j];
                }
                if (iSum > 0) { iOut += 1; }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

const int MAX_N = 114514;
int N;
int dp[MAX_N][3];

int main(){
    	cin >> N;
	dp[0][0]=dp[0][1]=dp[0][2]=0;
    	for(int i=1;i<N+1;i++){
		int a,b,c;
		cin>>a>>b>>c;
		dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c;
	}
	printf("%d\n",max(max(dp[N][0],dp[N][1]),dp[N][2]));
	return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> x(m);
  rep(i,m){
    cin>>x[i];
  }
  sort(x.begin(),x.end());
  vector<int> div(m-1);
  rep(i,m-1){
    div[i]=x[i+1]-x[i];
  }
  sort(div.begin(),div.end());
  int ans=0;
  if(n<m){
    rep(i,n-1){
      div.pop_back();
    }
    for(auto p : div){
      ans+=p;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3908
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,cut;
  string S,ss;
  cin >> S;
  N=S.size();
  vector<int> ANS(N);
  for(int i=0;i<N;i++){
    ss=S[i];
    ANS[i]=stoi(ss);
  }
  for(int i=0;i<N-1;i++){
    if(ANS[i]==0&&ANS[i+1]==0){
      ANS[i+1]=1;
      cut++;
    }
    else if(ANS[i]==1&&ANS[i+1]==1){
      ANS[i+1]=0;
      cut++;
    }
  }
  cout << cut << endl;
}

Measured memory_bytes: 896
N = int(input())
S = str(input())
slist = list(S)
max = 0
i = 0
while i < N:
  left = slist[0:i+1]
  right = slist[i+1:N]
  common = list(set(left) & set(right))
  l = len(common)
  if max <= l:
    max = l
  i+=1
print(max)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin >> s;
	
	cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;

	return 0;
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  long long ans = lcm(n, m);
  map<long long, char> mp;
  for (int i = 0; i < n; i++) {
    mp[1 + ans / n * i] = s[i];
  }
  bool ok = true;
  for (int i = 0; i < m; i++) {
    if (mp.count(1 + ans / m * i)) {
      if (mp[1 + ans / m * i] != t[i]) {
        ok = false;
        break;
      }
    }
  }
  if (ok) {
    cout << ans << '\n';
  } else {
    cout << -1 << '\n';
  }
  return 0;
}

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

int main() {
    int ar[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<ar[n];
    
    
 return 0;   
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if (a%2 == 0 || b%2 == 0){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main{
    
	public static void main(String[] $){
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int[] c = new int[26];
		for(int i = 0; i < 26; i++){
			c[i] = sc.nextInt();
		}
		int[][] s = new int[D][26];
		for(int i = 0; i < D; i++){
			for(int j = 0; j < 26; j++){
				s[i][j] = sc.nextInt();
			}
		}
		int[] last = new int[26];
		long satisfact = 0;
		
		for(int i = 0; i < D; i++){
			long max = Integer.MIN_VALUE;
			int sentaku = -1;
			for(int j = 0; j < 26; j++){
				if(max < s[i][j]){
					max = s[i][j];
					sentaku = j;
				}
			}
			satisfact = satisfact + max;
			last[sentaku] = i+1;
			for(int j = 0; j < 26; j++){
				satisfact -= c[j]*((i+1)-last[j]);
			}
			satisfact = Math.max(1000000+satisfact, 0);
			System.out.println(sentaku+1);
		}
	}
} 

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

using namespace std;

constexpr int N = 100000;

set<int> sa, sa_inv, sb, sb_inv;
int ans_a[N + 1];
int ans_b[N + 1];
int ans_c[N + 1];

int main() {
	int n, k, a, b, c, i;

	scanf("%d%d", &n, &k);

	for (i = 0; i < n; i++) {
		sa.insert(i);
		sa_inv.insert(-i);
		sb.insert(i);
		sb_inv.insert(-i);
	}

	for (i = n - 1; i >= 0; i--) {
		c = i;

		if (*sb.rbegin() >= *sa.rbegin()) {
			b = *sb.rbegin();

			// a <= (2 * n + c) - (1 * n + b) - k
			if (sa_inv.lower_bound(-((2 * n + c) - (1 * n + b) - k)) == sa_inv.end()) {
				break;
			}

			a = -(*sa_inv.lower_bound(-((2 * n + c) - (1 * n + b) - k)));
		}
		else {
			a = *sa.rbegin();

			// b <= (2 * n + c) - (0 * n + a) - k - n
			if (sb_inv.lower_bound(-((2 * n + c) - (0 * n + a) - k - n)) == sb_inv.end()) {
				break;
			}

			b = -(*sb_inv.lower_bound(-((2 * n + c) - (0 * n + a) - k - n)));
		}

		sa.erase(a);
		sa_inv.erase(-a);
		sb.erase(b);
		sb_inv.erase(-b);

		ans_a[i] = 0 * n + a + k;
		ans_b[i] = 1 * n + b + k;
		ans_c[i] = 2 * n + c + k;
	}

	if (i >= 0) {
		printf("-1\n");
		return 0;
	}

	for (i = 0; i < n; i++) {
		printf("%d %d %d\n", ans_a[i], ans_b[i], ans_c[i]);
	}

	return 0;
}

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

int main()
{
	int n, m;
	cin >> n >> m;

	vector<vector<int>> tree(n+1);
	for (int i = 0; i < m; ++i) {
		int x, y, z;
		cin >> x >> y >> z;

		tree[x].push_back(y);
		tree[y].push_back(x);
	}

	vector<bool> check(n+1, false);
	int ret = 0;
	for (int i = 1; i <= n; ++i) {
		if (check[i]) {
			continue;
		}
		++ret;

		queue<int> next;
		next.push(i);
		check[i] = true;
		while (!next.empty()) {
			int f = next.front();
			for (auto& t : tree[f]) {
				if (check[t]) {
					continue;
				}
				next.push(t);
				check[t] = true;
			}
			next.pop();
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 6520
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  ll n,p = 0;
  cin >> n >> p;
  ll res = 0;
  res = 1;
  if(n == 1)res = p;
  else{
    for(int i = 2;i <= sqrt(p) + 1;i++){
      int now = 0;
      while(p % i == 0){
        p /= i;
        now++;
      }
      res *= pow(i,now / n);
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
h,w,k=map(int,input().split())
board=[list(input()) for _ in range(h)]
acum=[[0]*w for _ in range(h)]

def count(x1,y1,x2,y2): #事前に求めた2次元累積和を用いて左上の点が(x1,y1)、右下の点(x2,y2)の長方形に含まれる1の個数を数える
  ret=acum[y2][x2]
  if x1!=0:
    ret-=acum[y2][x1-1]
  if y1!=0:
    ret-=acum[y1-1][x2]
  if x1!=0 and y1!=0:
    ret+=acum[y1-1][x1-1]
  return ret

for i in range(h): #2次元累積和により左上の点が(0,0)、右下の点が(j,i)の長方形に含まれる1の個数を数える
  for j in range(w):
    if board[i][j] == '1': # ''をつける！
      acum[i][j]+=1
    if i!=0:
      acum[i][j]+=acum[i-1][j]
    if j!=0:
      acum[i][j]+=acum[i][j-1]
    if i!=0 and j!=0:
      acum[i][j]-=acum[i-1][j-1]

ans = 10**18
for i in range(2**(h-1)):
  cnt = 0
  list = []
  flag = format(i,'b')[::-1]
  for j in range(len(flag)):
    if flag[j] == '1': # ''をつける！
      cnt += 1
      list.append(j)
  list.append(h-1)
  x1 = 0
  for x2 in range(w-1): #x1(最初は0)とx1+1の間からx=w-1とx=wの間までの区切り方をそれぞれ確かめる
    y1 = 0
    for y2 in list: #長方形のブロックの右下の点のy座標の候補をすべて試す
      if count(x1,y1,x2,y2) > k: #ある横の区切り方の下で、どのように縦を区切ってもブロックに含まれる1の個数がKより大きくなるとき、条件を満たす切り分け方は存在しない
        cnt += 10**18
      if count(x1,y1,x2,y2) <= k and count(x1,y1,x2+1,y2) > k: #ある位置でブロックを区切ると1の個数がK以下になるが、区切る位置を1つ進めると1の個数がKより大きくなるとき、その位置で区切る必要がある
        cnt += 1
        x1 = x2+1 #ある位置x2で区切ったとき、次からはx2+1を長方形のブロックの左上の点のx座標として見ればよい
        break
      y1 = y2+1 #(いま見ているブロックの右下の点のy座標)+1が次に見るブロックの左上の点のy座標に等しくなる
  y1 = 0
  for y2 in list:
    if count(x1,y1,w-1,y2) > k: #最後に縦で区切った位置以降で、あるブロックに含まれる1の個数がKより大きくなるとき、条件を満たすような区切り方は存在しない
      cnt += 10**18
      break
    y1 = y2+1
  ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 50140
class UnionFind():
    # 作りたい要素数nで初期化
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズ
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
uni = UnionFind(N)
for _ in range(M):
    a, b, d = map(int, input().split())
    uni.Unite(a-1, b-1)
    graph[a-1].append((d, b-1))
    graph[b-1].append((-d, a-1))

INF = 10**14
A = [INF]*N
def bfs(start):
    q = [start]
    A[start] = 0
    while q:
        qq = []
        for p in q:
            for d, np in graph[p]:
                if A[np] == INF:
                    A[np] = A[p] + d
                    qq.append(np)
                elif A[np] != A[p]+d:
                    return False
        q = qq
    return True

root = set()
for i in range(N):
    root.add(uni.Find_Root(i))

ok = True
for r in root:
    ok = ok and bfs(r)

print("Yes" if ok else "No")

Measured memory_bytes: 67404
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m,a,b,sum,ans=0;
int main()
{
	scanf("%d %d",&n,&m);
	if(n%3==0||m%3==0||(n+m)%3==0)
	{
		printf("Possible\n");
		return 0;
	}
	printf("Impossible\n");
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
s = 0
for i in range(n):
  if i == 0:
    s += a[i]
  elif i == n-1:
    s += a[i-1]
  else:
    s += min(a[i-1],a[i]) 
print(s)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
int len=0,t;
char a[105];
bool pd(int k) {
	for(int i=0;i<k;i++)
	{
		if(a[i]=='C')
		{
			t=i;
			return true;
		}
	}
	return false;
}
bool pd1(int k1) {
	for(int i=t;i<k1;i++)
	{
		if(a[i]=='F')
		{
			return true;
		}
	}
	return false;
}
int main() {
	scanf("%s", a);
	len=strlen(a);
	if(pd(len) && pd1(len))
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
//	printf("%d", t);
	return 0;
} 

Measured memory_bytes: 128
#include <iostream>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;

signed main() {
  int n; cin >> n;
  ll tmp = 1;
  for(int i = 1; i <= n; i++) {
    tmp = tmp*i%MOD;
  }
  cout << tmp << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main(){
    int n, s = 0, o = 0, temp, ans = 0;
    cin >> n;
    for (int i = 0; i < n;i++){
        cin >> temp;
        if(temp%2) o++;
        else s++;
    }
    if(s==0){
        ans = pow(3, o) - 1;
    }
    else{
        ans = pow(3, s) * pow(3, o) - pow(2, s);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())

if b - a + 1 <= k:
    for i in range(a, b + 1):
        print(i)
    quit()
lst1 = list(range(a, a + k))
lst2 = list(range(b - k + 1, b + 1))
lst = list(set(lst1 + lst2))
lst.sort()
print(*lst, sep='\n')

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    ll n, k;
    ll cnt[100100];
    fill(cnt, cnt + 100010, 0);
    cin >> n >> k;
    imfor(i, n) {
        ll a, b;
        cin >> a >> b;
        cnt[a] += b;
    }
    ll pos = 1;
    ll tmp = 0;
    while (1) {
        tmp += cnt[pos];
        if (tmp >= k) {
            break;
        }
        pos++;
    }
    cout << pos << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

double Mcos(double k){return cos(k*atan(1.0)*4/180);}

void monmo(){
    
}

int main() {
    int l,r,d;
    int c=0;
    cin>>l>>r>>d;
    for(int i=l;i<=r;i++){
        if(i%d==0)c++;
    }
    cout<<c;
}


Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

int cups[3] = {1,0,0};

void swapCup(char c1, char c2) {
    int temp = cups[c1-'A'];
    cups[c1-'A'] = cups[c2-'A'];
    cups[c2-'A'] = temp;
}

int main() {
    char c1, c2, c3;
    while(cin >> c1 >> c2 >> c3) {
        swapCup(c1, c3);
    }
    REP(i,3) {
        if (cups[i]) {
            cout << (char)('A' + i) << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1132
#include<iostream>
int main() {
	std::string s, t;
	int count = 0;
	std::cin>>s>>t;
	for (int i = 0; i < s.length(); i++)
		if (s[i] == t[i])
		{
			count++;
		}
	std::cout<<count<<std::endl;
}

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

static const int Max = 1000;
static const int Vmax = 10000;

int n, s, A[Max], B[Max], T[Vmax + 1];

int solve(){
  int ans = 0;

  bool V[Max];

  for(int i = 0; i < n; i++){
    B[i] = A[i];
    V[i] = false;
  }
  sort(B, B + n);

  for(int i = 0; i < n; i++){
    T[B[i]] = i;
  }
  for(int i = 0; i < n; i++){
    if(V[i]) continue;

    int cur = i, S = 0, m = Vmax, an = 0;

    while(1){
      V[cur] = true;
      an++;

      int v = A[cur];

      m = min(m, v);
      S += v;
      cur = T[v];

      if(V[cur]) break;
    }
    ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
  }

  return ans;
}

int main(){
  cin >> n;

  s = Vmax;
  for(int i = 0; i < n; i++){
    cin >> A[i];
    s = min(s, A[i]);
  }
  int ans = solve();
  
  cout << ans << endl;

  return 0;
}
   



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n;

	cin >> n;

	int ma = -1;
	int mi = INT_MAX;
	int *x = new int();

	int i;

	rep(i, n) {
		cin >> *x;

		Max(ma, *x);
		Min(mi, *x);
	}

	Out(ma - mi);

	delete x;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
// Problem https://atcoder.jp/contests/arc094/tasks/arc094_a

int solver(int A,int B,int C){
    int result;
    // inputCheck
    // cout << A << " " << B << " " << C << endl;
    result=0;
    // 戦略:下限まで操作すればよい。下限はまず3つの数の最大値がターゲットになる
    int dataMax=0;
    dataMax=max(A,max(B,C));// 同じ値へ合わせる3つの値の最大値を求める
    int remainValue=0;
    remainValue = (dataMax-A)+(dataMax-B)+(dataMax-C);
    // 操作によって埋められる値は両方とも2だけなので、埋めるべき値は偶数
    if(remainValue%2 == 0){
        // 偶数の場合は先に求めたremainValueを2で割ると回数になる
        result = remainValue / 2;
    }
    else{
        // もし奇数であれば(下限の値+1)まで埋めるとすれば解決する
        // 現remainValue(奇数)に3を足せば偶数になる
        // ここでは丁寧にdataMax+1まで埋めるとして計算する
        remainValue=(dataMax+1-A)+(dataMax+1-B)+(dataMax+1-C);
        result=remainValue / 2;
    }
    return result;
}

int main(void){
    int answer;
    answer=0;
    int A,B,C;
    cin >> A >> B >> C;
    answer=solver(A,B,C);
    cout << answer << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = []

for i in range(n):
    a.append(list(map(int, input().split())))

b = []
for i in range(m):
    b.append(int(input()))

for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    ll n,a,b,ans=0;cin>>n>>a>>b;
    vector<ll> x(n);
    rep(i,n)cin>>x[i];

    for(int i=0;i < n-1;i++)
    {
        if((x[i+1]-x[i])*a>b){
            ans+=b;
        }else{
            ans+=(x[i+1]-x[i])*a;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;

	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			string s;
			cin >> s;
			if (s == "snuke") {
				cout << (char)('A' + w) << h+1 << endl;
				return 0;
			}
		}
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//最大公約数
long long GCD(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(GCD(b, a%b));
   }
}
//最小公倍数
long long LCM(long long a, long long b)
{
   return a * b / GCD(a, b);
}
int main() {
  int N,M;
  cin >> N >> M;
  string S,T;
  cin >> S >> T;
  int gcd = GCD(N,M);
  int n = N/gcd;
  int m = M/gcd;
  for(int i=0; i<gcd; i++){
    if(S[n*i] != T[m*i]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << LCM(N,M) << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N, C;
    cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C));
    rep(i, C) {
        rep(j, C) {
            cin >> D[i][j];
        }
    }
    vector<vector<int>> c(N, vector<int>(N));
    rep(i, N) {
        rep(j, N) {
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    vector<vector<int>> A(3, vector<int>(C, 0));
    rep(k, C) {
        rep(i, N) {
            rep(j, N) {
                A[(i + j) % 3][k] += D[c[i][j]][k];
            }
        }
    }
    int ans = 1e9;
    rep(i, C) {
        rep(j, C) {
            if (i == j) continue;
            rep(k, C) {
                if (i == k || j == k) continue;
                ans = min(ans, A[0][i] + A[1][j] + A[2][k]);
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1280
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;
typedef pair<int, int> P;

bool pairCompare(const P &p1, const P &p2)
{
    return p1.second < p2.second;
}

int main(void)
{
    int N, M;
    int ans = 0;
    int pos;

    cin >> N >> M;
    vector<P> v;
    vector<int> bridge;

    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        v.push_back(P(a, b));
    }

    sort(v.begin(), v.end(), pairCompare);

    ans = 1;
    // between pos - 1 and pos is broken
    pos = v[0].second;

    for (int i = 1; i < M; i++)
    {
        if (pos <= v[i].first)
        {
            pos = v[i].second;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n,d; cin >> n >>d;
    int can = d*2+1;
    cout << (n-1) / can + 1 << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <set>
#include <cmath>
using namespace std;

struct Edge;
typedef vector<vector<Edge> > G;

const int INF = (1<<28);

struct Edge {
  int to, cost;
};

struct State {
  int v, cost;
  bool operator < (const State &s) const {
    return cost > s.cost;
  }
};

void addEdge(int a, int b, int c, G *_g) {
  G &g = *_g;
  if(g.size() < max(a,b)+1) g.resize(max(a,b)+1);
  g[a].push_back((Edge){b, c});
  g[b].push_back((Edge){a, c});
}

vector<int> dijkstra(const G &g, int v) {
  vector<int> res(g.size(), INF);
  priority_queue<State> que;
  State s = {v, 0};
  res[v] = 0;
  que.push(s);
  while(!que.empty()) {
    s = que.top();
    que.pop();
    if(s.cost > res[s.v]) continue;
    for(int i = 0; i < g[s.v].size(); ++i) {
      const Edge &e = g[s.v][i];
      int ncost = s.cost + e.cost;
      if(ncost >= res[e.to]) continue;
      res[e.to] = ncost;
      que.push((State){e.to, ncost});
    }
  }
  return res;
}


int main() {
  int n, w;
  while(cin >> n >> w && (n|w)) {
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    vector<int> S(n+1);
    S[0] = 0;
    for(int i = 0; i < n; ++i) {
      S[i+1] = S[i] + a[i];
    }

    G g;
    for(int i = 0; i < n; ++i) {
      for(int j = i+1; j <= n; ++j) {
        int cost;
        int s = S[j] - S[i];
        if(j == n) {
          cost = max(0, s - w);
        } else {
          cost = abs(s - w);
        }
        addEdge(i, j, cost, &g);
      } 
    }

    int V = g.size();
    vector<int> v = dijkstra(g, 0);
    static int tc = 0;
    cout << "Case " << ++tc << ": " << v[n] << endl;

  }
  return 0;
}

Measured memory_bytes: 17116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	char a; cin >> a;
	if(isupper(a))
		cout<<"A\n";
	else
		cout<<"a\n";
	
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3684
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,m = map(int,readline().split())
*x, = map(int,readline().split())
*y, = map(int,readline().split())

MOD = 10**9+7

dx = [i-j for i,j in zip(x[1:],x)]
rx = 0
for i in range(n-1):
    rx += dx[i]*(i+1)%MOD*(n-i-1)%MOD

dy = [i-j for i,j in zip(y[1:],y)]
ry = 0
for i in range(m-1):
    ry += dy[i]*(i+1)%MOD*(m-i-1)%MOD

print(rx*ry%MOD)








Measured memory_bytes: 25732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
typedef long long ll;
//
int main(){
    int n;cin>>n;
    if(n>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

    const ll N = 1e2 + 7;
    const ll mod = 1e9 + 7;
    const ll inf = 1e9;

ll a , b , n , x , y , mx;

ll f(){
    ll f1 = a * x / b;
    return f1;
}

void solve(){
    cin >> a >> b >> n;
    if(b == 1){
        cout << 0;
        return;
    }
    cout << a * (min(n , b) - (n >= b)) / b;
}

int main(){
    TIME
    int tt = 1;
    //cin >> tt;
    while(tt --){
            solve();
    }
}

/**

**/


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

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; }

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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int N;
    cin>>N;
    int ans = 0;
    rep(i,N){
        int x;
        cin>>x;
        if(x%2!=0&&(i+1)%2!=0) ans++;
    }
    cout<<ans<<endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector <vector<char>> vec1(H, vector<char>(W));
  
  for (int i = 0 ; i < H ; i++ ){
    for (int j = 0 ; j < W ; j++ ){
      cin >> vec1.at(i).at(j);
    }
  }
  
  vector <vector<char>> vec2(H * 2, vector<char>(W));
  for ( int i = 0 ; i < H * 2 ; i++ ){
    for ( int j = 0 ; j < W ; j++ ){
        vec2.at(i).at(j) = vec1.at(i/2).at(j);
      cout << vec2.at(i).at(j) ;
      }
    cout << endl;
  }
}
  
  

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int H,W;

  while(cin >> H >> W){
    if(H==0&&W==0){
      break;}
    for(int i=0; i<H; i++){

      for(int j=0; j<W; j++){
	if(i==0||i==H-1||j==0||j==W-1){
	cout <<"#";
	}
	else cout << ".";
	  }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152
while True:
    a,op,b=map(str,input().split())
    a=int(a)
    b=int(b)
    if op=="?":
        break
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    else:
        print(int(a/b))




Measured memory_bytes: 5596
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)

def main():
    pass_num = input()
    for i in range(3):
        if pass_num[i] == pass_num[i + 1]:
            print("Bad")
            exit()

    print("Good")
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 4212
#include <iostream>
#include <string>
int main(){
    std::string str,ans;

    std::cin>>str;

    for(int i=0;i<str.length();++i){
        if(str[i]=='0'||str[i]=='1'){
            ans+=str[i];
        }else{
            if(ans.empty()){
                

            }else{
                ans.erase(ans.size()-1);
            }

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

#define set fixed << setprecision(6)
#define square pow(x, 2)
#define triangle x * sqrt(pow(h, 2) + pow(x / 2, 2)) / 2

int main() {
	double x, h;
	while (1) {
		cin >> x >> h; if (x == 0 && h == 0) break;
		cout << set << square + 4 * triangle << endl;
	}
	return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
#define ll long long
int n,m;

int a[100];
int main()
{
    cin>>n>>m;
    int x,y;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        a[x]++;
        a[y]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<a[i]<<endl;
    }

    return 0;
}


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

long inv(int a, int m) {
    long i = 1, j = 0;
    for(int b = m; a > 1; swap(i, j), swap(a, b)) {
        j = (j + b / a * (m - i)) % m;
        b %= a;
    }
    return i;
}
int p = 1e9 + 7;
long f[2222222] = {1};
long co(int a, int b) { return f[a + b] * inv(f[a] * f[b] % p, p) % p; }
int main() {
    int r, c, s, d;
    cin >> r >> c >> s >> d;
    for(int i = 0; i < s + d + 3; i++)
        f[i + 1] = f[i] * (i + 1) % p;
    cout << (co(s + 1, d + 1) + co(r, c) + p - co(s + 1, c) + p -
             co(r, d + 1)) %
                p
         << endl;
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
     
using namespace std;
typedef long long ll;
const int nmax=200001; 
vector<int> V[nmax];
ll count1[nmax];
int N,Q;
ll ans[nmax];
void print_vector_int(vector<int> & S){
    int i,n;
    n = S.size();
    for(i=0;i<n;i++){
        if (i != 0) {
            cout << " ";
        }
        cout << S[i];
    }
    cout << endl;
}

void DFS(vector<int> *Tree,int start,int p){
    int i,n;
    // cout << "I am " << start << endl;
    if (p>=0){
        count1[start] += count1[p];
    }
    n = Tree[start].size();
    for(i=0;i<n;i++){
        if (Tree[start][i] != p){
            DFS(Tree,Tree[start][i],start);
        }
    }
    if (p<0){
        for(i=1;i<=N;i++){
            if(i!=1){
                cout << " ";
            }
            cout << count1[i];
        }
        cout << endl;
    }
}

void solve(){
    DFS(V,1,-1);
}

int main() {
    int i,j; 
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> Q; 
    // cout << N << " " << Q << endl;
    i=0; 
    for(i=1; i<= N-1; i++){
        int x,y;
        cin >> x >> y;
        V[x].push_back(y);
        V[y].push_back(x);
    }
    //for(i=1; i<= N; i++){
    //    cout << i << " ";
    //    print_vector_int(V[i]);
    //}
    for(i=1;i<=N;i++){
        count1[i] = 0;
    }
    for(i=1;i<=Q;i++){
        int p,q;
        cin >> p >> q;
        count1[p] = count1[p] + q;
    }
    solve();
}


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


const int maxn = 1e3+10;
const int hi[4] = {1, -1, 0, 0};
const int hj[4] = {0, 0, 1, -1};
string s[maxn];

typedef pair<int,int> II;
int f[maxn][maxn];
bool mark[maxn][maxn];

void bfs(int n,int m) {
	queue<II> q;
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			if (s[i][j] == '#') {
				q.push(II(i,j));
				mark[i][j] = true;
			}
		}
	}

	while (!q.empty()) {
		II u = q.front();
		q.pop();

		for(int i=0;i<4;i++) {
			int x1 = u.first + hi[i];
			int y1 = u.second + hj[i];
			if (x1 >=0 && y1 >= 0 && x1 < n && y1 < m && !mark[x1][y1]) {
				mark[x1][y1] = true;
				q.push(II(x1,y1));
				f[x1][y1] = f[u.first][u.second] + 1;
			}
		}
	}

	int res = 0;
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) res = max(res, f[i][j]);
	}
	cout << res;

}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = 0;
	int m = 0;
	cin >> n >> m;
	for(int i=0;i<n;i++) cin >> s[i];
	bfs(n, m);
	return 0;
}


Measured memory_bytes: 11008
#include<bits/stdc++.h>
#define fi first
#define se second
#define Mp make_pair
#define pb push_back
#define rep(i, j, k) for (int i = (j); i <= (k); i++)
#define per(i, j, k) for (int i = (j); i >= (k); i--)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> PII;
typedef vector<int> VI;

const int N = 603;
int n,m,G[N][N],tot[N];
db ans,E[N],preE[N];

db calcE(){
    memset(E,0,sizeof(E));
    per(i,n-1,1){
        per(j,n,i+1) E[i]+=(db)G[i][j]/tot[i]*E[j];
        E[i]++;
    }
    return E[1];
}
db calcOneE(int x){
    db ret=0;
    rep(i,x+1,n) if(G[x][i]) ret+=(db)G[x][i]/tot[x]*E[i];
    return ret;
}

int main(){
    scanf("%d%d",&n,&m);
    rep(i,1,m){int x,y; scanf("%d%d",&x,&y); G[x][y]++; tot[x]++;}
    ans=calcE(); //printf("%.10f\n",ans);
    rep(i,1,n){
        db mn=0x3f3f3f3f3f; int id;
        tot[i]--;
        rep(j,i+1,n) if(G[i][j]){
            G[i][j]--;db val=calcOneE(i); if(val<mn) mn=val,id=j; G[i][j]++;
        }
        G[i][id]--; ans=min(ans,calcE()); G[i][id]++;
        tot[i]++;
    }
    /*
    rep(i,1,n) rep(j,i+1,n){
        if(G[i][j]){
            G[i][j]--,tot[i]--;
            ans=min(ans,calcE(i));
            G[i][j]++,tot[i]++;
        }
    }
    */
    printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int n,x,ans;
priority_queue<int>pq;
map<int,int>pos;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		pos[x]=i%2;
		pq.push(-x);	
	}
	for(int i=1;i<=n;i+=2)
	{
		if(!pos[-pq.top()])ans++;
		pq.pop();
		if(!pq.empty())pq.pop();
	}
	printf("%d",ans);
}

Measured memory_bytes: 5496