akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main() {
  string S[3];
  cin >> S[0] >> S[1] >> S[2];

  int i = 0, j = S[0].size();
  while (j != 0) {
    int n;
    if (S[i][0] == 'a') n = 0;
    if (S[i][0] == 'b') n = 1;
    if (S[i][0] == 'c') n = 2;

    S[i].erase(S[i].begin());
    j = S[n].size();
    i = n;
  }

  if (i == 0) cout << "A" << endl;
  if (i == 1) cout << "B" << endl;
  if (i == 2) cout << "C" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll a,b,q ;
	cin >> a >> b >> q ;
	vll s(a),t(b) ;
	for(auto &i:s) cin >> i ;
	for(auto &i:t) cin >> i ;
	sort(all(s)) ;
	sort(all(t)) ;
	for(int i=0;i<q;i++){
		ll x ; cin >> x ;
		ll ans = INF ;
//		神社→寺、右右、右左、左右、左左
		auto itr = lower_bound(all(s),x) ;
		if(itr!=s.end()){
			auto tmp = lower_bound(all(t),*itr) ;
			if(tmp!=t.end()){
				ans = min(ans,*tmp-x) ;
			}
			if(tmp!=t.begin()){
				tmp-- ;
				ans = min(ans,*itr-x+*itr-*tmp) ;
			}
		}
		if(itr!=s.begin()){
			itr-- ;
			auto tmp = lower_bound(all(t),*itr) ;
			if(tmp!=t.end()){
				ans = min(ans,x-*itr+*tmp-*itr) ;
			}
			if(tmp!=t.begin()){
				tmp-- ;
				ans = min(ans,x-*tmp) ;
			}
		}
//		寺→神社、右右、右左、左右、左左
		itr = lower_bound(all(t),x) ;
		if(itr!=t.end()){
			auto tmp = lower_bound(all(s),*itr) ;
			if(tmp!=s.end()){
				ans = min(ans,*tmp-x) ;
			}
			if(tmp!=s.begin()){
				tmp-- ;
				ans = min(ans,*itr-x+*itr-*tmp) ;
			}
		}
		if(itr!=t.begin()){
			itr-- ;
			auto tmp = lower_bound(all(s),*itr) ;
			if(tmp!=s.end()){
				ans = min(ans,x-*itr+*tmp-*itr) ;
			}
			if(tmp!=s.begin()){
				tmp-- ;
				ans = min(ans,x-*tmp) ;
			}
		}
		cout << ans << endl ;
	}
}


Measured memory_bytes: 2944
import collections
# from collections import deque
# from fractions import gcd # >=Python3.5 # lcm = (a*b)//gcd(a,b)
# from math import gcd # <Python3.5
# from math import sqrt

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

n,m = map(int,input().split())
uf = UnionFind(n)

for i in range(m):
    x,y,z = map(int,input().split())
    uf.union(x,y)

# cnt = collections.Counter(uf.par)

# print(cnt)

# print(len(set(cnt))-1)

tank = set([])
for i in range(1,n+1):
    tank.add(uf.find(i))
print(len(tank))

Measured memory_bytes: 17124
import java.util.*;
public class Main{
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
        int H = sc.nextInt(),
            W = sc.nextInt(),
            h = sc.nextInt(),
            w = sc.nextInt();
        System.out.println((H-h)*(W-w));
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n,1);
    vector<bool> b(n,false);
    b[0] = true;
    for(int i = 0; i < m; i++){
        int x,y;
        cin >> x >> y;
        x--;y--;
        a[x]--; a[y]++;
        if(b[x]){
            b[y] = true;
            if(a[x] == 0) b[x] = false;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(b[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
long long a[200005],k;
int n;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;++i)
	 cin>>a[i];
	sort(a,a+n);
	long long l=-1e18,r=1e18,m,res;
	while(l<=r)
	{
		m=(l+r)>>1;
		long long tot=0;
		for(int i=0;i<n;++i)
		{
			int lt=0,rt=n-1,mid;
			if(a[i]<0)
			{
				int ans=n;
				while(lt<=rt)
				{
					mid=(lt+rt)>>1;
					if(a[mid]*a[i]<=m) ans=mid,rt=mid-1;
					else lt=mid+1;
				}
				tot+=n-ans;
			}
			else
			{
				int ans=-1;
				while(lt<=rt)
				{
					mid=(lt+rt)>>1;
					if(a[mid]*a[i]<=m) ans=mid,lt=mid+1;
					else rt=mid-1;
				}
				tot+=ans+1;
			}
			if(a[i]*a[i]<=m) --tot;
		}
		if((tot/2)>=k) res=m,r=m-1;
		else l=m+1;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
void out(int a[],int N)
{
    int i;
    for(i=0;i<N;i++)
    {
        if(i>0) printf(" ");
        printf("%d",a[i]);
    }
    printf("\n");
}
void sort(int a[],int N)
{
    int i,j,temp;
    for(i=1;i<N;i++)
    {
        temp=a[i];
        j=i-1;
        while(j>=0&&a[j]>temp)
        {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=temp;
        out(a,N);
    }
}
int main()
{
    int t,N,a[100];
    scanf("%d",&N);
    for(t=0;t<N;t++)
    {
        scanf("%d",&a[t]);
    }
    out(a,N);
    sort(a,N);
}



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

int main() {
  int N;
  cin >> N;
  if(N%10==9){
    cout << "Yes" << endl;
  }
  else if(N/10%9==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int hour, min, sec;
    int in;
    
    scanf("%d", &in);
    
    hour = in / 3600;
    in %= 3600;
    
    min = in / 60;
    in %= 60;
    
    sec = in;
    
    printf("%d:%d:%d\n", hour, min, sec);
    
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b;}
template<class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b;}
template<class T> void drop(const T &x) { std::cout<<x<<endl; exit(0);}
void debug_out() { std::cout << "\n";}
template<class T, class... Args> void debug_out(const T &x, const Args &... args) { std::cout<<x<< " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct InitIO{
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
}init_io;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> C(h);
  rep(i, h) cin >> C[i];
  ll ans = 0;
  for (int bit1 = 0; bit1<(1<<h); ++bit1) {
    for (int bit2 = 0; bit2<(1<<w); ++bit2) {
      vector<string> A = C;
      rep(i, h) {
        rep(j, w) {
          if (bit1 & (1<<i)) A[i][j] = '@';
          if (bit2 & (1<<j)) A[i][j] = '@';
        }
      }
      int cnt = 0;
      rep(i, h) rep(j, w) {
        if (A[i][j] == '#') cnt++;
      }
      if (cnt == k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


class UnionFindTree(object):
    def __init__(self, n):
        import collections
        self.parent = list(range(n))
        self.counts = collections.defaultdict(lambda: 1)
        self.rank = collections.defaultdict(int)

    def root(self, x):
        if x == self.parent[x]:
            return x
        root = self.root(self.parent[x])
        self.parent[x] = root
        return root

    def _merge(self, x, y):
        """
        x to y
        """
        self.parent[x] = y
        self.counts[y] += self.counts[x]
        del (self.counts[x])

    def size(self, x):
        return self.counts[self.root(x)]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self._merge(x, y)
        elif self.rank[x] > self.rank[y]:
            self._merge(y, x)
        else:
            self._merge(x, y)
            self.rank[y] += 1


def combination2(n):
    return int(n * (n - 1) / 2)


N, M = map(int, sys.stdin.readline().rstrip().split(" "))
bridges = []
for _ in range(M):
    A, B = map(int, sys.stdin.readline().rstrip().split(" "))
    bridges.append([A, B])

results = [combination2(N)]
connections = []

# for A, B in reversed(bridges):
#     iA, iB = -1, -1
#     for i, connection in enumerate(connections):
#         if A in connection:
#             iA = i
#         if B in connection:
#             iB = i
#     if iA == -1:
#         connections.append(set([A]))
#         iA = len(connections) - 1
#     if iB == -1:
#         connections.append(set([B]))
#         iB = len(connections) - 1
#     if iA != iB:
#         connections[iA] = connections[iA] | connections[iB]
#         del (connections[iB])
#
#     count = combination2(N)
#     for connection in connections:
#         count -= combination2(len(connection))
#
#     results.append(count)
#
# for result in reversed(results[:-1]):
#     print(result)

results = [combination2(N)]
union_find_tree = UnionFindTree(N)
for A, B in reversed(bridges):
    if union_find_tree.same(A-1, B-1):
        results.append(results[-1])
    else:
        last_result = results[-1] + combination2(union_find_tree.size(A - 1)) + combination2(
            union_find_tree.size(B - 1))
        union_find_tree.union(A - 1, B - 1)
        results.append(last_result - combination2(union_find_tree.size(A - 1)))

for result in reversed(results[:-1]):
    print(result)

exit(0)


Measured memory_bytes: 40656
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<int>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

int popHeap(vector<int>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  int i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

vector<int> ver;
void dfs(const graph &g,int v){
  ver[v]=1;
  for(auto i:g[v]){
    if(ver[i]!=1)continue;
    dfs(g,i);
  }
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n;
  /*if(n==1){
    cout<<"Yes"<<endl;
    cout<<1<<" "<<1<<endl;
    return 0;
  }*/
  for(i=1;i<500;i++){
    if(i*(i+1)/2==n){
      cout<<"Yes"<<endl;
      cout<<i+1<<endl;
      int m=i;
      int p[m][m];
      cnt=1;
      for(i=0;i<m;i++){
        for(j=0;j<m-i;j++){
          p[i][j]=cnt++;
        }
      }
      cout<<m;
      for(i=1;i<=m;i++)cout<<" "<<i;
      cout<<endl;
      for(k=0;k<m;k++){
        cout<<m;
        i=0;j=k;
        while(j!=-1){
          cout<<" "<<p[i][j];
          i++;j--;
        }
        for(j=0;j<m-k-1;j++){
          cout<<" "<<p[k+1][j];
        }
        cout<<endl;
      }
      return 0;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	char b;
	 cin >> b;

	 if (b == 'A')
		 cout << "T" << endl;
	 if (b == 'C')
		 cout << "G" << endl;
	 if (b == 'G')
		 cout << "C" << endl;
	 if (b == 'T')
		 cout << "A" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N,M;
    map<string, int> blue;
    map<string, int> red;
    cin >> N;
    for(int i = 0; i<N; i++) {
        string tmp = "";
        cin >> tmp;
        blue[tmp]++;
    }
    cin >> M;
    for(int i = 0; i<M; i++) {
        string tmp = "";
        cin >> tmp;
        red[tmp]++;
    }

    int res = 0;
    for( auto x : blue) {
        res = max(res , x.second - red[x.first]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ 2025: Eight Princes
// 2017.11.8 bal4u@uu

#include <stdio.h>

long long dp1[10][101][2][2];
long long dp2[10][101][3][3];

int main()
{
	int n, i, j, k;
	long long ans;

	dp1[0][1][0][0] = dp1[1][1][1][1] = 1;
	for (i = 0; i < 9; i++) for (j = 1; j < 100; j++) {
		for (k = 0; k < 2; k++) {
			dp1[i][j+1][k][0] += dp1[i][j][k][0] + dp1[i][j][k][1];
			dp1[i+1][j+1][k][1] += dp1[i][j][k][0];
		}
	}
	dp2[0][1][0][0] = dp2[1][1][1][1] = dp2[1][1][2][2] = 1;
	for (i = 0; i < 9; i++) for (j = 1; j < 100; j++) {
		for (k = 0; k < 3; k++) {
			dp2[i][j+1][k][0] += dp2[i][j][k][0] + dp2[i][j][k][1] + dp2[i][j][k][2];
			dp2[i+1][j+1][k][1] += dp2[i][j][k][0] + dp2[i][j][k][2];
			dp2[i+1][j+1][k][2] += dp2[i][j][k][0] + dp2[i][j][k][1];
		}
	}

	while (scanf("%d", &n) && n > 0) {
		if (n & 1) ans = dp1[8][n][0][0] + dp1[8][n][0][1] + dp1[8][n][1][0];
		else {
			for (ans = 0, i = 0; i < 3; i++) for (j = 0; j < 3; j++)
				if (i*j != 2) ans += dp2[8][n/2][i][j];
		}
		printf("%lld\n", ans * 40320);
	}
	return 0;
}

Measured memory_bytes: 1840
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int a,b,c;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b>>c;
	int ans=a+b+c;
	if (ans>=22) cout<<"bust";
	else cout<<"win";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(long long *)a-*(long long *)b;
}

int main(void){
	int d,w,e[10][10],i,j,k,l,m,n,ans,tmp,soto,naka;
	while(1){
		d=in();
		w=in();
		if(!d) break;
		rep(i,d){
			rep(j,w){
				e[i][j]=in();
			}
		}
		ans=0;
		rep(i,d){
			rep(j,w){
				for(k=i+2;k<d;k++){
					for(l=j+2;l<w;l++){
						tmp=0;
						soto=10;
						naka=0;
						for(m=i;m<=k;m++){
							if(soto>e[m][j]){
								soto=e[m][j];
							}
							if(soto>e[m][l]){
								soto=e[m][l];
							}
						}
						for(m=j;m<=l;m++){
							if(soto>e[i][m]){
								soto=e[i][m];
							}
							if(soto>e[k][m]){
								soto=e[k][m];
							}
						}
						for(m=i+1;m<k;m++){
							for(n=j+1;n<l;n++){
								if(naka<e[m][n]){
									naka=e[m][n];
								}
							}
						}
						if(naka<soto){
							for(m=i+1;m<k;m++){
								for(n=j+1;n<l;n++){
									tmp+=soto-e[m][n];
								}
							}
							if(tmp>ans){
								ans=tmp;
							}
						}
					}
				}
			}
		}
		print(ans);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
    int arr[10000];
    int a,i,b=1;
    cin>>a;
    for(i = 0;i < a;i++){
        cin>>arr[i];
    }
    sort(arr,arr+a);
    for(i = 1;i < a;i++){
        if(arr[i]>arr[i-1]){
            b++;
        }
    }
    cout<<b;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    u_int r, c;
    cin >> r >> c;
    u_int sheet[r+1][c+1];
    for (u_int i = 0; i <= c; i++)
        sheet[r][i] = 0;
    
    for (u_int i = 0; i < r; i++) {
        sheet[i][c] = 0;
        for (u_int j = 0; j < c; j++) {
            cin >> sheet[i][j];
            sheet[i][c] += sheet[i][j];
            sheet[r][j] += sheet[i][j];
        }
    }

    for (u_int i = 0; i < c; i++)
        sheet[r][c] += sheet[r][i];

    for (u_int i = 0; i <= r; i++) {
        for (u_int j = 0; j < c; j++)
            printf("%d ", sheet[i][j]);
        printf("%d\n", sheet[i][c]);
    }
    
    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;


int main(){
  char s;
  cin >> s;
  int ans = (int)s;
  cout << char(s+1) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int K,N,ans;
  cin >> K >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  ans = K-A[N-1]+A[0];

  for(int i=0;i<=N-2;i++){
  if(A[i+1]-A[i]>ans){
     ans = A[i+1]-A[i];
  }
}

cout << K-ans;
return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[100];
    char G[100],H[100];
    cin>>G>>s>>H;
    if(G[0]>='a' && G[0]<='z')
    G[0]-=32;
    if(s[0]>='a' && s[0]<='z')
    s[0]-=32;
    if(H[0]>='a' && H[0]<='z')
    H[0]-=32;
    cout<<G[0]<<s[0]<<H[0];
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[][] x = new int[n][d];
		for(int i = 0; i < n; i++){
		    for(int j = 0; j < d; j++){
		        x[i][j] = sc.nextInt();
		    }
		}

		// 計算
		int result = 0;
		for(int i = 0; i < n - 1; i++){
		    for(int j = i + 1; j < n; j++){
		        double dist2 = 0;
		        for(int k = 0; k < d; k++){
		            dist2 += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
		        }
		        if(sqrt(dist2) - floor(sqrt(dist2)) == 0) result++;
		    }
		}

		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

int main() {

	unsigned int N;
	unsigned int M;
	cin >> N;
	cin >> M;

	unsigned int p;
	string S;
	string AC = "AC";
	string WA = "WA";
	vector<int> num_WA(N, 0);
	unsigned int sum_AC = 0;
	unsigned int sum_WA = 0;

	for (unsigned int i = 0; i < M; i++) {
		cin >> p;
		cin >> S;
		if (S == WA && num_WA[p - 1] >= 0) {
			num_WA[p - 1] += 1;
		}
		else if (S == AC && num_WA[p - 1] >= 0){
			sum_AC += 1;
			sum_WA += num_WA[p - 1];
			num_WA[p - 1] = -1;
		}
	}

	cout << sum_AC << "\t" << sum_WA << endl;

	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main(void) {

    ll N; cin >> N;
    string S[N];
    rep(i,N) cin >> S[i];
    ll m, a, r, c, h;
    m = a = r = c = h = 0;
    rep(i,N) {
        if (S[i][0] == 'M') ++m;
        else if (S[i][0] == 'A') ++a;
        else if (S[i][0] == 'R') ++r;
        else if (S[i][0] == 'C') ++c;
        else if (S[i][0] == 'H') ++h;
    }
    ll ans = pow(m + a + r + c + h, 3) - 3 * (m + a + r + c + h) * (m * m + a * a + r * r + c * c + h * h);
    ans += 2 * (pow(m, 3) + pow(a, 3) + pow(r, 3) + pow(c, 3) + pow(h, 3));
    ans /= 6;
    out(ans);
    


    


    return 0;
}











Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
const int maxn = 300 + 5;
const int mod = 998244353; 

map<pair<string,string>, int> mp;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	for (int mask = 0; mask < (1<<n); mask++){
		string A, B;
		for (int i = 0; i < n; i++)
			if (mask & (1 << i))
				A += s[i];
			else
				B += s[i];
		mp[{A,B}] ++;
	}
	ll answer = 0;
	for (int mask = 0; mask < (1<<n); mask++){
		string A, B;
		for (int i = 0; i < n; i++)
			if (mask & (1 << i))
				A += s[2*n-i-1];
			else
				B += s[2*n-i-1];
		answer += mp[{A,B}];
	}
	cout << answer << endl;
}


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

using namespace std;

typedef double ll;

struct Point
{
    ll x,y;
    Point(){ x = y = 0.0; }
    Point(ll _x, ll _y) : x(_x), y(_y){}

    Point operator+ (Point p)
    {
        return Point(p.x + x, p.y + y);
    }

    Point operator- (Point p)
    {
        return Point(x - p.x, y - p.y);
    }

    ll operator* (Point p)
    {
        return p.x * x + p.y * y;
    }

    Point operator* (ll t)
    {
        return Point(x*t, y*t);
    }

    ll operator~ ()
    {
        return sqrt(x * x + y * y);
    }

    ll operator% (Point p)
    {
        return x * p.y - y * p.x;
    }

};

bool areIntersectSegment(Point a, Point b, Point p, Point q)
{
    Point v1=(b-a);
    Point v2=(q-p);
    double t,t1;
    if( v1 % v2 != 0 )
    {
        t = (double)(( p - a ) % v2) / (double)(v1 % v2);
        t1 = (double)(( a - p ) % v1) / (double)(v2 % v1);
        if( t >= 0.0 && t <= 1.0 && t1 >= 0.0 && t1 <= 1.0) return true;
        else return false;
    }
    else
    {
        // Segment collinear
        if( v1 % v2 == 0 && (p - a) % v1 == 0 )
        {
            t = (double)((p - a)*v1) /  (double)(v1*v1);
            t1 = (double)((p+v2-a)*v1) / (double)(v1*v1);
            //If are in opposite direction
            if( v1 * v2 < 0 )
            {
                if( t1 <= 1.0 && 0.0 <= t ) return true;
            }
            else
            {
                if( t <= 1.0 && 0.0 <= t1 ) return true;
            }
        }
    }
    return false;
}

Point projection(Point p1, Point p2, Point o)
{
    Point a = (p2 - p1);
    Point b = (o - p1);
    double t =( (a * b) / (a * a) );
    if( t < 0.0 ) return p1;
    if( t > 1.0 ) return p2;
    return p1 + a * t;
}

double distanceSegment(Point a, Point b, Point p, Point q)
{
    double minimo = numeric_limits<double>::max();
    Point aux;
    if( !areIntersectSegment(a,b,p,q) )
    {
        minimo = min( minimo, ~(projection(a,b,p)-p) );
        minimo = min( minimo, ~(projection(a,b,q)-q) );
        minimo = min( minimo, ~(projection(p,q,a)-a) );
        minimo = min( minimo, ~(projection(p,q,b)-b) );
        return  minimo;
    }
    return 0.0;
}

int main()
{
    cout << fixed;
    cout.precision(10);
    ios::sync_with_stdio(0); cin.tie(0);
    Point p0,p1,p2,p3,ans;
    Point vec, vec1;
    int q;
    cin >> q;
    while(q--)
    {
        cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
        cout << distanceSegment(p0, p1, p2, p3) << '\n';
    }
    return 0;
}

Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, d, N, ans=0, L, X;
    vector<int> v(3);
    int tmp=0, tmp2;
    string S, S2, S3;
    bool flag=true;
    
    cin >> a >> b;
    tmp = max(a-b, a+b);
    tmp = max(tmp, a*b);
    // ans = a<=b ? a:a-1;

    cout <<tmp <<endl;

    // if(S[1]==S[2] &&(S[0]==S[1] | S[2]==S[3]))
    // 	cout << "Yes" <<endl;
    // else
    // 	cout << "No" <<endl;

    // string S;
    // cin >>S;
    // // cout << S + "pp"<<endl;
    // if(flag)
    // 	puts("Yes");
    // else
    // 	puts("No");
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a <= b && b <= c) {
            System.out.println(a + " " + b + " " + c);
        } else if (a <= c && c <= b) {
            System.out.println(a + " " + c + " " + b);
        } else if (b <= a && a <= c) {
            System.out.println(b + " " + a + " " + c);
        } else if (b <= c && c <= a) {
            System.out.println(b + " " + c + " " + a);
        } else if (c <= a && a <= b) {
            System.out.println(c + " " + a + " " + b);
        } else {
            System.out.println(c + " " + b + " " + a);
        }
        sc.close();
    }
}


Measured memory_bytes: 26184
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
using namespace std;
using u64 = uint64_t;



int main()
{
    string s;
    cin >> s;
    if (s.back() == 's') {
        cout << s << "es";
    }
    else {
        cout << s << "s";
    }
    return 0;
}

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

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

	int N; cin >> N;
	long a[210000];
	int z = 0, in;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (z < a[i]) {
			in = i;
			z = a[i];
		}
	}
	sort(a, a + N);
	if (a[N - 1] == a[N - 2]) {
		for (int i = 0; i < N; i++) {
			cout << a[N-1] << endl;
		}
	}
	else {
		for (int i = 0; i < in; i++) {
			cout << a[N - 1] << endl;
		}
		cout << a[N - 2] << endl;
		for (int i = in+1; i < N; i++) {
			cout << a[N - 1] << endl;
		}
	}
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    string S;
    cin >> S;
    for(int i = 0; i < 3; i++){
        if(S[i] == S[i + 1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 3576
import sys
input = sys.stdin.readline
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
a = Counter(v[::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0] != b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(min(n-a[1][1]-b[0][1], n-a[0][1]-b[1][1]))

Measured memory_bytes: 64988
package main

import (
	"fmt"
	"sort"
)

const inf = 1 << 60

func intsSum(a []int) int {
	res := 0
	for _, v := range a {
		res += v
	}
	return res
}

func chmax(a *int, b int) {
	if *a < b {
		*a = b
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}
	sort.Ints(as)

	if n%2 == 0 {
		s := as[:n/2]
		l := as[n/2:]
		ans := (2*intsSum(l) - l[0]) - (2*intsSum(s) - s[len(s)-1])
		fmt.Println(ans)
	} else {
		ans := -inf
		{
			s := as[:n/2]
			l := as[n/2:]
			chmax(&ans, 2*intsSum(l)-l[0]-l[1]-2*intsSum(s))
		}
		{
			s := as[:(n+1)/2]
			l := as[(n+1)/2:]
			chmax(&ans, 2*intsSum(l)-(2*intsSum(s)-s[len(s)-1]-s[len(s)-2]))
		}
		fmt.Println(ans)
	}
}


Measured memory_bytes: 5504
/*
  "I knew I shouldn't have
   gotten out of bed today."
   - Squidward Tentacles
*/
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<numeric>

#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<unordered_map>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#include<iomanip>
#include<fstream>
#include<chrono>
using namespace std;
using namespace __gnu_pbds;

#define int          long long
#define pii          pair<int,int>
#define vi           vector<int>
#define peque        priority_queue
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define brep(i,s,e)  for(int i=s;i>=e;i--)
#define all(x)       x.begin(),x.end()
#define ball(x)      x.rbegin(),x.rend()
#define mem(x,y)     memset(x,y,sizeof(x))
#define oset         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define VR46         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int dp[3005][9005];

signed main()
{
    VR46 ofstream out("output.txt");
    // auto start = chrono::high_resolution_clock::now();

    // GANDU THODE TEST CASE BNAKE TEST KRLE
    int t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        int n, t;
        cin>>n>>t;
        // vi a(n), b(n);
        vector<pii> ab(n);
        // rep(i,0,n-1) cin>>a[i]>>b[i];
        for(auto &i:ab) cin>>i.ff>>i.ss;

        sort( all(ab) );

        mem( dp,-1 );
        dp[0][0] = 0, dp[0][ ab[0].ff ] = ab[0].ss;

        rep(i,1,n-1)
        {
            rep(j,0,9004) dp[i][j] = max( dp[i][j],dp[i-1][j] );
            rep(j,0,t-1)
            {
                if( dp[i-1][j] != -1 )
                dp[i][ j+ab[i].ff ] = max( dp[i][ j+ab[i].ff ], dp[i-1][j] + ab[i].ss );
            }
        }

        // rep(i,0,n-1)
        // {
        //     rep(j,0,111) cout<<dp[i][j]<<" ";
        //     cout<<"\n";
        // }

        int sol = 0;
        rep(i,0,9004) sol = max( sol,dp[n-1][i] );
        cout<<sol<<"\n";
    }

    // auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout<<"Time taken by function: "<<duration.count()<<" milliseconds"<<endl;
}

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

#define MAX_LENGTH 5000

char input0[MAX_LENGTH], input1[MAX_LENGTH];
int dp[MAX_LENGTH][MAX_LENGTH];

int max(int foo, int bar) {
  if (foo > bar) {
    return foo;
  } else {
    return bar;
  }
}

int lcs(int i, int j) {
  if (i == 0 || j == 0) {
    return 0;
  } else if (dp[i][j] >= 0) {
    return dp[i][j];
  } else if (input0[i - 1] == input1[j - 1]) {
    return dp[i][j] = lcs(i - 1, j - 1) + 1;
  } else {
    return dp[i][j] = max(lcs(i, j - 1), lcs(i - 1, j));
  }
}

int main(void) {
  int i, j, k, len0, len1, lenAns;
  char ans[MAX_LENGTH];

  /* 入力を行う */
  fgets(input0, MAX_LENGTH, stdin);
  len0 = strlen(input0);
  fgets(input1, MAX_LENGTH, stdin);
  len1 = strlen(input1);

  /* DPテーブルの初期化を行う */
  for (i = 0; i < MAX_LENGTH; i++) {
    ans[i] = '\0';
    for (j = 0; j < MAX_LENGTH; j++) {
      dp[i][j] = -1;
    }
  }

  /* DPの計算を行う */
  lenAns = lcs(len0, len1);

  i = len0;
  j = len1;
  k = lenAns;
  while (i > 0 && j > 0) {
    if (input0[i - 1] != input1[j - 1]) {
      if (dp[i - 1][j] > dp[i][j - 1]) {
          i--;
      } else {
          j--;
      }
    } else {
      ans[--k] = input0[i - 1];
      i--;
      j--;
    }
  }

  /* 解答を出力します */
  printf("%s\n", ans);
  return 0;
}


Measured memory_bytes: 98048
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 101;
const int maxw = 10001;

int T[maxn][maxw];
int weight[maxn], value[maxn];

int main()
{
    int n, w;
    cin >> n >> w;
    for(int i = 1; i <= n; i++)
        cin >> value[i] >> weight[i];
    for(int i = 0; i <= n; i++)
        T[i][0] = 0;
    for(int i = 0; i <= w; i++)
        T[0][i] = 0;

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= w; j++)
            if(j - weight[i] >= 0)
                T[i][j] = max(T[i-1][j], T[i - 1][j - weight[i]] + value[i]);
            else
                T[i][j] = T[i-1][j];
    cout << T[n][w] << endl;
    return 0;
}



Measured memory_bytes: 7000
//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <stdio.h>
//#define int long long
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
    #ifdef OnlineJudge
    freopen("commandos.in","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
}
ll S(ll x){ll s = 0;while(x){s += x % 10;x /= 10;}return s;} /// sum of digits.
ll powe(ll a , ll n){if(n == 1)return a;return a * powe(a ,n-1);}
ll com(int n,int m){ll z = 1;for(int i = 0; i < m;i++){z = z * ( n - i) / (i + 1) ;}return z;}
int * LIS_Lengths(vector<int> a) { int* lis = new int[a.size()];int b[a.size()];int maxLength = 1, lowerBound;lis[0] = 1, b[0] = a[0];for (size_t i = 1; i < a.size(); i++) {lowerBound = lower_bound(b, b + maxLength, a[i]) - b;lis[i] = lowerBound + 1;if (lowerBound == maxLength)    b[maxLength++] = a[i];else    b[lowerBound] = a[i];}return lis;}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int dr[] = {0,0,0,1,1,1,-1,-1,-1};
int dc[] ={-1,0,1,-1,0,1,-1,0,1};
/// <<------------------------------------------------------------------------------>>

/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    ll n,m;
    cin >> n >> m;
    vector<pair<int, int> >v;
    loop(n)
    {
        int a,b;
        cin >> a >> b;
        v.push_back({a,b});
    }
    sort(v.begin(), v.end());
    ll cnt = 0;
    for(int i = 0 ;i < n; i++)
    {
        cnt += ll(v[i].S);
        if(cnt >= m)
        {
            cout<<v[i].F;
            break;
        }
    }
}


Measured memory_bytes: 1400
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int T = sc.nextInt();
		long ans = 0;
		long last = -1;
		for(int i=0; i<N; i++) {
			int t = sc.nextInt();
			if(last < t)
				ans += T;
			else
				ans += (T-last+t);
			last = t+T;
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 62972
#include<bits/stdc++.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
#define max1 100001

//long long int mod=1e18 ;



int main(){	
	string s,t;
	cin>>s>>t;
	int n=s.length();
	int m=t.length();
	int dp[n+1][m+1];
	for(int i=0;i<=m;i++){
		dp[0][i]=0;
	}

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


	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-1]==t[j-1]){
				dp[i][j]=1+dp[i-1][j-1];
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	int i=n,j=m;
	string ans="";
	while(i>=0&&j>=0){
	if(dp[i][j]==dp[i-1][j]){
		i=i-1;
	}
	else if(dp[i][j]==dp[i][j-1]){
		j=j-1;
	}
	else{
		i--;
		j--;
		ans=s[i]+ans;
	}
	}
	cout<<ans<<endl;


		
}
	
	
	
	





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

vector<vector<char>> subA(int M, int st_i, int st_j, vector<vector<char>> A) {
    vector<vector<char>> subA(M, vector<char>(M));
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < M; j++) {
            subA[i][j] = A[st_i + i][st_j + j]; 
        }
    }
    return subA;
}

bool fig_match(vector<vector<char>> A, vector<vector<char>> B) {
    bool matched = true;
    int M = A.size();
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < M; j++) {
            if (A[i][j] != B[i][j]) {
                matched = false;
            }
        }
    }
    return matched;
}

int main(){
int N, M; cin >> N >> M;
vector<vector<char>> A(N, vector<char>(N));
vector<vector<char>> B(M, vector<char>(M));
for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
            cin >> A[i][j];
    }
}
for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
            cin >> B[i][j];
    }
}

bool found = false;
for (int i = 0; i < N - M + 1; i++) {
    for (int j = 0; j < N - M + 1; j++) {
        if (fig_match(subA(M, i, j, A), B)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
}
cout << "No" << endl;

}

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

int main() {
  int N;
  int ans = 0;
  string S,s;
  cin >> N >> S;
  rep(i, 1000) {
    int c[3] = {i / 100, (i / 10) % 10, i % 10};
    int f = 0;
    for(int j=0; j<N; j++) {
      if(S[j] == ('0' + c[f])) f++;
      if(f == 3) break;
    }
    if(f == 3) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
import sys

def main():
    n, m = map(int, input().split())
    lines = sys.stdin.readlines()

    cities = {}
    for i in range(m):
        p, y = map(int, lines[i].split())
        if p in cities:
            cities[p].append((i, y))
        else:
            cities[p] = [(i, y)]

    outputs = [None] * m
    for pref, city_list in cities.items():
        city_list.sort(key=lambda x: x[1])
        #print(pref, city_list)
        city_no = 1
        for city in city_list:
            outputs[city[0]] = "{:06d}{:06d}".format(pref, city_no)
            city_no += 1

    for output in outputs:
        print(output)
    return


main()

Measured memory_bytes: 50752
#include <iostream>
#include <cstdio>
#include <cstring>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

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

double dp[105][105];
int stat[105];

int main()
{
	int N, T, L, B;

	while (1 ){
		scanf ("%d %d %d %d", &N, &T, &L, &B );
		if (N == 0 && T == 0 && L == 0 && B == 0 )
			break;
		memset (dp, 0.0, sizeof (dp ) );
		memset (stat, 0, sizeof (stat ) );
		rep (i, L ){
			int in;
			scanf ("%d", &in );
			stat[in] = 1;
		} // end rep
		rep (i, B ){
			int in;
			scanf ("%d", &in );
			stat[in] = 2;
		} // end rep

		dp[0][0] = 1.0;
		for (int i = 0; i < T; i++ ){
			for (int j = 0; j < N; j++ ){
				for (int k = 1; k <= 6; k++ ){
					int next = j+k;
					if (next > N )
						next = 2*N - next;
					if (stat[next] == 2 )
						next = 0;
					if (stat[next] == 1 )
						dp[i+2][next] += 1./6.*dp[i][j];
					else
						dp[i+1][next] += 1./6.*dp[i][j];
				} // end for					
			} // end if
		} // end for

		double res = 0.0;
		for (int i = 0; i <= T; i++ )
			res += dp[i][N];
		printf ("%.9f\n", res );
	} // end while

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI                acos(-1)
#define pb                emplace_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define forr(i, b, e)     for(int i = b; i < e; i++)
#define forg(i, b, e, m)  for(int i = b; i < e; i+=m)
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

typedef long long       ll;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
#define tam 220000
typedef pair<ii,int> iii;
int v[tam];
int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    int n,k,q;
    cin>>n>>k>>q;
    int pos;
    forr(i,0,q)
    {
        
        cin>>pos;
        v[pos]++;
    }
    int tot=0;
    forr(i,0,n+1)
    {
        tot=k-(q-v[i]);
        if (i>0)
        {
            //cout<<tot<<' ';
            if (tot>0)
                cout<<"Yes\n";
            else
                cout<<"No\n";
        }

    }
}
// PLUS ULTRA!


Measured memory_bytes: 1024
_ = input()
L = [int(i) for i in input().split()]
L.sort()
def countSmaller(num, L, exclude):
  counter = 0
  for i in L:
    if i==exclude: continue
    if num<=i: break
    #print(i)
    counter += 1
  return counter
#print(L)
counter = 0
for i in range(len(L)):
  for j in range(i+1, len(L)):
    if L[i]==L[j]: continue
    #print(L[i], L[j], countSmaller(L[i]+L[j], L[j+1:], L[j]))
    counter += countSmaller(L[i]+L[j], L[j+1:], L[j])
print(counter)


Measured memory_bytes: 9184
import math
a, b, h, m = map(int, input().split())

hangle = 360*(h/12+m/(60*12))
mangle = 360*m/60
hm = math.radians(abs(hangle-mangle))

ans = math.sqrt(a**2+b**2-2*a*b*math.cos(hm))

print(ans)

Measured memory_bytes: 9488
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

struct UnionFind {
  std::vector<int> data;
  UnionFind(const int size) : data(size, -1) {}
  int root(const int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(const int x) { return -data[root(x)]; }
  bool same(const int x, const int y) { return root(x) == root(y); }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    else {
      if (data[y] < data[x])
        std::swap(x, y);
      data[x] += data[y];
      data[y] = x;
      return true;
    }
  }
};

int main() {
  // Input
  int N;
  std::cin >> N;
  std::vector<long long> x(N);
  std::vector<long long> y(N);
  for (int i = 0; i < N; ++i)
    std::cin >> x[i] >> y[i];

  // Main

  // UnionFind uf(N);

  int res = IINF;

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (j == i)
        continue;
      // if (x[])
      long long p = x[j] - x[i];
      long long q = y[j] - y[i];

      UnionFind uf(N);

      for (int k = 0; k < N; ++k) {
        for (int l = 0; l < N; ++l) {
          if (l == k)
            continue;

          if (x[l] - x[k] == p and y[l] - y[k] == q)
            uf.unite(l, k);
        }
      }
      std::map<int, bool> mp;
      for (int k = 0; k < N; ++k)
        mp[uf.root(k)] = true;
      chmin(res, (int)mp.size());
    }
  }

  // Output
  if (N == 1)
    std::cout << 1 << std::endl;
  else
    std::cout << res << std::endl;

  return 0;
}


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

int main(){
    int i,tmp,L[3];
    for(i=0;i<3;i++){
        cin >> tmp;
        L[i]=tmp;
    }
    sort(L,L+3);
    int kyori = L[0]+L[1];
    cout<<kyori<<endl;
    return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}


int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = false;
  ll n,p,q;cin>>n>>p>>q;
  vector<ll> a(n),b(n),c(n);
  for(i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];

  ll dp[401][401];
  for(i=0;i<401;i++)
  for(j=0;j<401;j++)dp[i][j]=INF;
  dp[0][0]=0;
  for(i=0;i<n;i++){
    for(j=400;j>=a[i];j--){
      for(o=400;o>=b[i];o--){
        if(dp[j][o]>dp[j-a[i]][o-b[i]]+c[i]){
          dp[j][o]=dp[j-a[i]][o-b[i]]+c[i];
          if(j*q==o*p){
            chmin(res2,dp[j][o]);
          }
        }
      }
    }
  }
  if(res2==INF)cout<<-1<<endl;
  else cout<<res2<<endl;

  return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(void)
{
	char str[1002];
	char op[10], re[1002], temp[1002];
	int q, a, b, i, j;
	
	scanf("%s", str);
	scanf("%d",&q);
	
	for(j=0;j<q;j++){
		int k = 0;
		scanf("%s %d %d",op, &a, &b);
		if(op[2]=='i'){//print
			for(i=a;i<=b;i++){
				putchar(str[i]);
			}
			printf("\n");
		}
		if(op[2]=='v'){//reverse
			for(i=a;i<=(a+b)/2;i++){
				temp[k] = str[i];
				str[i] = str[b-k];
				str[b-k] = temp[k];
				k++;
			}
		}
		if(op[2]=='p'){//replace
			scanf("%s", re);
			for(i=a;i<=b;i++){
				str[i] = re[k];
				k++;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 2112