akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
void insertionSort(int A[], int N);
int main(void){
	int n[100];
	int i, r;
	scanf("%d", &i);
	for (r = 0; r < i; r++){
		scanf("%d", &n[r]);
	}
	for (r = 0; r < i; r++){
		if (r != i - 1){ printf("%d ", n[r]); }
		else{
			printf("%d\n", n[r]);
		}


	}
	insertionSort(n, i);

	return 0;
}
	void insertionSort(int A[], int N){
		int i, j, v, r;
		for (i = 1; i < N; i++){
			v = A[i];
			j = i - 1;
			while (j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
				A[j + 1] = v;
			}
			for (r = 0; r < N; r++){
				if (r != N - 1){ printf("%d ", A[r]); }
				else{
					printf("%d\n", A[r]);
				}
			}

		}
		return;
	}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,m,a[N],vis[N];
int l,r;
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>m;
  for(int i=1;i<=m;i++){
    int x;
    string y;
    cin>>x>>y;
    if(y=="WA"){
      a[x]++;
    }else{
      if(vis[x])
        continue;
      vis[x]=1;
      l++;
      r+=a[x];
    }
  }
  cout<<l<<' '<<r<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    if (N % 2 == 1) {
        ll pre = 1;
        ll suf = 2;
        REP(i, 0, M) {
            cout << pre << " " << suf << endl;
            if (pre == 1) {
                pre = N;
            } else {
                pre--;
            }
            if (suf == N) {
                suf = 1;
            } else {
                suf++;
            }
        }
    } else {
        ll num = N / 2 - 1;
        ll pre = 1;
        ll suf = pre + num;
        ll tmp = 0;
        REP(i, 0, (num + 1) / 2) {
            cout << pre << " " << suf << endl;
            pre++;
            suf--;
            tmp++;
            if (tmp == M) {
                break;
            }
        }
        if (tmp < M) {
            pre = N;
            suf = 1 + num + 2;
            REP(i, 0, M - (num + 1) / 2) {
                cout << pre << " " << suf << endl;
                pre--;
                suf++;
            }
        }
    }
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

// string dfs(int level) {
//     if(level == 0) {
//         return string("P");
//     }
//     string s = dfs(level-1);
//     return string("B") + s + string("P") + s + string("B");
// }

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll n,x;
    cin >> n >> x;

    ll count[51], count_p[51];
    count[0] = 1;
    count_p[0] = 1;
    for(int i=1;i<=50;i++) {
        count[i] = count[i-1] * 2 + 3;
        count_p[i] = count_p[i-1] * 2 + 1;
    }

    if(x <= n) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0LL;
    for(int i=n-1;i>=0;i--) {
        x--;
        if(count[i] * 2 + 1 <= x) {
            x -= count[i] * 2 + 2;
            ans += count_p[i] * 2 + 1;
        } else if(count[i] + 1 <= x) {
            x -= count[i] + 1;
            ans += count_p[i] + 1;
        } else if(count[i] <= x) {
            x -= count[i];
            ans += count_p[i];
        }
        // cerr << x << " " << ans << endl;
        if(x <= 0) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//
// C - Digits in Multiplication
//

#include <iostream>
#include <cmath>

using namespace std;
using LL = long long;

int main() {
    LL N;
    cin >> N;
    LL min_ = LONG_MAX;
    for (LL A = 1; A <= sqrt(N); A++) {
        if (N % A) continue;
        LL B = N / A;
        min_ = min(min_, (LL) max(to_string(A).length(), to_string(B).length()));
    }
    cout << min_ << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,n;
    cin>>h>>n;
    vector<P> v(n);
    FOR(i,0,n)cin>>v[i].first>>v[i].second;
    vector<vector<ll>> dp(n+1,vector<ll>(h+1,1e9));
    FOR(i,0,n+1)dp[i][0] = 0;
    //FOR(i,0,h)dp[0][i] = 0;

    FOR(i,1,n+1){
        FOR(j,1,h+1){
            ll dmg = v[i-1].first;
            ll mp = v[i-1].second;
            ll pre = max((ll)0, j-dmg);
            dp[i][j] = min(dp[i-1][j], dp[i][pre] + mp);
        }
    }

    cout<<dp[n][h]<<endl;

}

Measured memory_bytes: 78592
N,K = map(int,input().split())
S = list(input())

if S[K-1] == "A":
    S[K-1] = "a"
elif S[K-1] == "B":
    S[K-1] = "b"
elif S[K-1] == "C":
    S[K-1] = "c"
    
S=''.join(S)
print(S)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
const int N=1e3+5;
char s[N][N];
int n,m,k;
int sx,sy;
int z[N][N];
int ans=1<<30;
typedef pair<int,int>pi;
int dir[4][2]={0,1,1,0,0,-1,-1,0};
queue<pi>q;
bool vis[N][N];
int deep[N][N];
void bfs(){
    q.push(pi(sx,sy));
    vis[sx][sy]=1;
    while(!q.empty()){
        int x=q.front().first,y=q.front().second;
        q.pop();
        ans=min(ans,z[x][y]);
        if(deep[x][y]==k)
            continue;
        for(int i=0;i<4;i++){
            int xx=x+dir[i][0],yy=y+dir[i][1];
            if(xx<=0||yy<=0||xx>n||yy>m||vis[xx][yy]||s[xx][yy]=='#')
                continue;
            vis[xx][yy]=1;
            deep[xx][yy]=deep[x][y]+1;
            q.push(pi(xx,yy));
        }
    }
}
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;i++){
        scanf("%s",s[i]+1);
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(s[i][j]=='S')
                sx=i,sy=j;
            z[i][j]=min(min(i-1,j-1),min(n-i,m-j));
            z[i][j]=(z[i][j]+k-1)/k;
        }
    bfs();
    printf("%d\n",ans+1);
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
    
#define int long long
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x)
#define all(x) ((x).begin(), (x).end())
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(), (x).end())
#define INF 99999999999
#define MOD (int)(1e9)+7
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

int32_t main(){
    int n;
    int a;
    cin >> n >> a;
    vector<int> v;
    v.pb(-1);
    int m=a;
    REP(i, n){
        int b;
        cin >> b;
        m=max(m, b);

        v.pb(b-a);
    }

    int x=n*m;
    vector<vector<int> > dp(n+1, vector<int>(2*x+5));
    dp[0][x]=1;
    REP(i, n+1){
        REP(j, 2*x+1){
            if(i>0){
                if(j-v[i]>=0 && j-v[i]<=2*x){
                    dp[i][j]=dp[i-1][j]+dp[i-1][j-v[i]];
                }
                else{
                    dp[i][j]=dp[i-1][j];
                }
            }
            else{
                if(j!=x) dp[i][j]=0;
            }
        }
    }

    cout << dp[n][x]-1 << endl;
}

Measured memory_bytes: 2304
#include<cstring>
#include<iostream>
#include<cstdlib>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    ll n, k;
    cin >> n >> k;
    ll z = 0;

    z = n % k;
    n = abs(z - k);
    if (z > n) {
        cout << n << endl;
    } else {
        cout << z << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def LI():
  return [int(s) for s in input().split()]
N = int(input())
p_s = LI()

min_j = p_s[0]
count = 1

for i in range(1,N):
  if min_j >= p_s[i]:
    count+=1
    min_j = p_s[i]

print(count)

Measured memory_bytes: 25768
#include <stdio.h>
 
int main(){
    long long int a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    long long int f=a*a+b*b+c*c;
    long long int g=(a*b+a*c+b*c)*2;
    if(f-g>0 && c-a-b>0){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

class path {
  public:
    int num;
    int last;
    vector<bool> judge;
    path(int n) {
        num = 1;
        last = 1;
        judge.resize(n + 1);
        judge[1] = true;
    }

    path(const path &origin) {
        num = origin.num;
        last = origin.last;
        judge = origin.judge;
    }

    bool next(int a) {
        if (judge[a]) {
            return false;
        }
        num++;
        last = a;
        judge[a] = true;
        return true;
    }
};

int main() {
    // source
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n + 1);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = 0;
    queue<path> p;
    path a(n);
    p.push(a);

    while (!p.empty()) {
        path t = p.front();
        p.pop();
        if (t.num == n) {
            ans++;
            continue;
        }

        rep(i, g[t.last].size()) {
            path p_temp = t;
            if (p_temp.next(g[t.last][i])) {
                p.push(p_temp);
            }
        }
    }

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

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {
    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
	int h, w;
	
	while (cin >> h >> w,h || w){
		int map = h * w;
		char f[101][101];
		for (int i = 0; i < h; i++){
			cin >> f[i];
		}
		h = w = 0;
		while (map){
			if (f[h][w] == '>'){
				w++;
			}
			else if (f[h][w] == '<'){
				w--;
			}
			else if (f[h][w] == '^'){
				h--;
			}
			else if (f[h][w] == 'v'){
				h++;
			}
			else if (f[h][w] == '.'){
				break;
			}
			map--;
		}
		if (map == 0){
			cout << "LOOP" << endl;
		}
		else {
			cout << w << ' ' << h << endl;
		}
	}
	
	return (0);
}

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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace

#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
    string s; 
    cin >> s;
    if (s == "SAT") cout << 1 << '\n';
    if (s == "SUN") cout << 7 << '\n';
    if (s == "MON") cout << 6 << '\n';
    if (s == "TUE") cout << 5 << '\n';
    if (s == "WED") cout << 4 << '\n';
    if (s == "THU") cout << 3 << '\n';
    if (s == "FRI") cout << 2 << '\n';
}



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

int main() {
	int n, m; cin >> n >> m;
	vector<int64_t> a(n), b(m);
	for(int64_t& v : a) cin >> v;
	for(int64_t& v : b) cin >> v;
	vector<int64_t> c = convolution(a, b);
	for(int i = 0; i < n + m - 1; ++i) {
		cout << c[i] << " \n"[i == n + m - 2];
	}
	return 0;
}


Measured memory_bytes: 27264
h,w,d,i,f;main(c){for(;scanf(f="%d %d\n",&h,&w)*h;c=printf(f,h,w))for(d=i=h*h+w*w;c;d++)for(h*=d==i;c&&(h++,h<(w=sqrt(d-h*h)));c=h*h+w*w-d);}

Measured memory_bytes: 604
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def can_construct_palindromic_matrix(char_counts, H, W):
    double_placeable_cells = (H >> 1 if W & 1 else 0) + (W >> 1 if H & 1 else 0)
    single_placeable_cell = (H & W) & 1

    counts_mod4 = list(map(lambda x : x % 4, char_counts))
    counts_div4 = list(map(lambda x : x // 4, char_counts))
    if counts_mod4.count(1) + counts_mod4.count(3) > single_placeable_cell:
        return False

    counts_mod4 = list(map(lambda x : 0 if x & 1 else x, counts_mod4))
    if counts_mod4.count(2) > double_placeable_cells or (double_placeable_cells - counts_mod4.count(2)) & 1:
        return False

    return True


def main():
    H, W = get_ln_int_inputs()
    matrix = list()
    for _ in range(H):
        matrix.append(get_ln_inputs()[0])
    
    counts = [0 for _ in range(26)]
    for i in range(H):
        for j in range(W):
            character = matrix[i][j]
            counts[ord(character) - 97] += 1
    
    print("Yes" if can_construct_palindromic_matrix(counts, H, W) else "No")
    return


main()

Measured memory_bytes: 3188
import bisect,collections,copy,heapq,itertools,math,string
import sys
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n, k = M()
A = deque(LI())
ans = deque()
for i in range(k, n):
    if A[i] > A[i-k]:
        print('Yes')
    else:
        print('No')

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


bool check(string b) {
    if (b == "AC") {
        return true;
    }
    else {
        return false;
    }
}

int main() {

    int N, Q;
    string S;

    cin >> N >> Q;
    cin >> S;

    int num[100010] = {0};
    int tmp = 0;
    for (int i=0; i<N-1; i++) {
        if (check(S.substr(i, 2))) {
            tmp++;
        }
        num[i+1] = tmp;
    }

    // for (int i=0; i<N-1; i++) {
    //     cout << num[i] << " ";
    // }
    // cout << endl;


    int l, r;

    for (int i=0; i<Q; i++) {
        cin >> l >> r;
        l--;
        r--;
        cout << num[r] - num[l] << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
import sys
import queue

H,W = map(int,input().split())
white = 0
maze = [['#']*(W+2)]
for y in range(H):
	li = list(input())
	white += li.count('.')
	maze.append(['#'] + li + ['#'])
maze.append(['#']*(W+2))



def check(x,y,n):
	if 1 <= x < W+1 and 1 <= y < H+1:
		if x == W and y == H:
			print (white - n - 1)
			sys.exit()
		elif maze[y][x] == '.':
			maze[y][x] = n
			q.put([x-1,y,n+1])
			q.put([x+1,y,n+1])
			q.put([x,y-1,n+1])
			q.put([x,y+1,n+1])
		else:
			return
	else:
		return

q = queue.Queue()
q.put([1,1,0])
while not q.empty():
	x,y,n = q.get()
	check(x,y,n)

print(-1)


Measured memory_bytes: 3952
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005,M=3009;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,K,m,sum[M][M];
char op[3];
inline int getsum(int ux,int uy,int dx,int dy)
{
	return sum[ux][uy]-sum[dx-1][uy]-sum[ux][dy-1]+sum[dx-1][dy-1];
}
int main()
{
	n=read();K=read();m=K*2;
	for(int i=1;i<=n;i++){
		int x=read(),y=read(); scanf("%s",op);
		if(op[0]=='B') x+=K;
		sum[x%m+1][y%m+1]++;
//		cout<<"add "<<x%m+1<<' '<<y%m+1<<endl;
	}
//	for(int i=1;i<=m;i++,cout<<endl)
//	  for(int j=1;j<=m;j++)
//	    cout<<sum[i][j]<<' ';
	for(int i=1;i<=m;i++)
	  for(int j=1;j<=m;j++)
	    sum[i][j]+=sum[i][j-1];
	for(int i=1;i<=m;i++)
	  for(int j=1;j<=m;j++)
	    sum[i][j]+=sum[i-1][j];
	int ans=0,s6=sum[m][m];
//	cout<<s6<<endl;
	for(int i=1;i<=K;i++)
	{
		for(int j=1;j<=K;j++)
		{
			int s1,s2,s3,s4,s5;
			s1=getsum(i,j,1,1);
			s2=getsum(i+K,j+K,i+1,j+1);
			s3=getsum(m,m,i+K+1,j+K+1);
			s4=getsum(i,m,1,j+K+1);
			s5=getsum(m,j,i+K+1,1);
			ans=max(ans,s1+s2+s3+s4+s5);
			ans=max(ans,s6-s1-s2-s3-s4-s5);
		}
	}
	printf("%d\n",ans);
	return 0;
}
//1 1 B
//1 2 W

Measured memory_bytes: 24832
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> p(n), q(n);
    rep(i,n){
        cin >> p[i];
        --p[i];
        q[p[i]] = i+1;
    }
    vector<ll> a(n), b(n);
    rep(i,n){
        a[i] = 20010 * (i+1);
        b[i] = 20010 * (n-1-i) + q[i];
    }
    rep(i,n) cout << a[i] << " ";
    cout << endl;
    rep(i,n) cout << b[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3956
/*
 *  Language:   C++
 *  Author:     Debajyoti Dasgupta
 */

#include <bits/stdc++.h>

using namespace std;
#define int long long

signed main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a) {
        cout << k << endl;
        return 0;
    }
    k -= a;
    int sum = a;
    if (k <= b) {
        cout << sum << endl;
        return 0;
    }
    k -= b;
    sum -= k;
    cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int a,b,c,fr[11];
int main()
{
    cin>>a>>b>>c;
    fr[a]++;
    fr[b]++;
    fr[c]++;
    if(fr[5]==2 && fr[7]==1)
        cout<<"YES";
    else cout<<"NO";
    return 0;
}


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

int main(){
   bool is_prime[10000000];
   is_prime[0]=is_prime[1]=false;
   for(int i=2;i<10000000;i++)
      is_prime[i]=true;
   for(int i=2;i*i<10000000;i++){
      if(is_prime[i]){
         for(int j=i*i;j<10000000;j+=i){
            is_prime[j]=false;
         }
      }
   }
   while(true){
      int n;
      cin >> n;
      if(n==0)
         break;
      for(int i=n;i!=0;i--){
         if(is_prime[i-8]&&is_prime[i-6]){
            if(is_prime[i-2]&&is_prime[i]){
              cout << i << endl;
              break;
            }
         } 
      }
   }
   return 0;
}

Measured memory_bytes: 12748
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
typedef long long ll;

int n,m,k;
string s,t;
char c;

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

Measured memory_bytes: 256
n = int(input())
results = [input() for i in range(n)]
ac = results.count('AC')
wa = results.count('WA')
tle = results.count('TLE')
re = results.count('RE')

print('AC','x',ac)
print('WA','x',wa)
print('TLE','x',tle)
print('RE','x',re)

Measured memory_bytes: 16200
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	READV(ans);
	READV(N);
	READAR(A,N);
	ll x=0;
	FORI(i,0,N)
	{
		x=max(x,(A[(i+1)%N]-A[i]+ans)%ans);
	}
	cout<<ans-x<<endl;

//-----------------------------------------------------------------------------------------------------------//


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

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

int main()
{
    long int n, a[10000],sum,max,min;
    cin>>n;
    sum = 0;
    min = 1000000;
    max = -1000000;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum += a[i];
        max = (max>a[i])?max:a[i];
        min = (min<a[i])?min:a[i];
    }
    cout<<min<<' '<<max<<' '<<sum<<endl;
    return 0;

}


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

int main() {
    int w, d;
    while (cin >> w >> d, w | d) {
        vector<int> h1(w), h2(d);
        for (int i = 0; i < w; i++) cin >> h1[i];
        for (int i = 0; i < d; i++) cin >> h2[i];
        int ans = 0;
        vector<int> used(100, 0);
        for (int i = 0; i < w; i++) {
            ans += h1[i];
            used[h1[i]]++;
        }
        for (int i = 0; i < d; i++) {
            if (used[h2[i]] > 0)
                used[h2[i]]--;
            else
                ans += h2[i];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int ab(int A, int B){


    if (B % A == 0){
        return A + B;
    }else{
        return B - A;
    }
}

void b(){
    int N,M;
    vector< vector<int> > Aij;
    vector< int > K_list;

    cin >> N >> M;
    for(int i = 0; i < N; i++){
        int K_i;
        cin >> K_i;
        K_list.push_back(K_i);
        Aij.push_back({});
        for(int j = 0; j < K_i; j++){
            int aij;
            cin >>aij;
            Aij[i].push_back(aij);

        }

    }

    set<int> loved(Aij[0].begin(), Aij[0].end());
    for(int i=1; i < N; i++){
        set<int> new_love;
        for(auto x: Aij[i]){
            if (loved.find(x) != loved.end())
                new_love.insert(x);
            }
        loved = move(new_love);
        }

        cout << loved.size();

}


int main(){

    b();

    return 0;

}

Measured memory_bytes: 256
k,a,b=(int(i) for i in input().split())
#print(k,a,b)
if a+1 >= b:
  print(1+k)
else:
  if (k-(a+1))%2==0:
    print(b+(k-(a+1))//2*(b-a))
  else:
    print(b+(k-(a+1))//2*(b-a)+1)

Measured memory_bytes: 3060
//#pragma comment(linker,"/STACK:36777216")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define itoc(c) (char)((int)'0' + c)
#define ctoi(c) (int)(c - '0')
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define emb emplace_back
#define pb push_back

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

const int oo = 1e9;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  bool ok = true;
  for (int i = 1; i <= n; ++i) {
    int a; cin >> a;
    if (a % 2 == 0) {
      if (a % 3 != 0 && a % 5 != 0) {
        ok = false;
        break;
      }
    }
  }
  if (ok) cout << "APPROVED";
  else cout << "DENIED";
  return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
	int a, b;
	while(cin >> a >> b) cout << a + b << endl;
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
  cin >>s ;
  bool nine=true;
  for(int i=1;i<s.size();i++){
    if (s[i]!='9')nine=false;
  }
  int ans=0;
  if (s[0]=='1')ans=1;
  if (s[0]=='2')ans=2;
  if (s[0]=='3')ans=3;
  if (s[0]=='4')ans=4;
  if (s[0]=='5')ans=5;
  if (s[0]=='6')ans=6;
  if (s[0]=='7')ans=7;
  if (s[0]=='8')ans=8;
  if (s[0]=='9')ans=9;
  if (nine)cout << ans+9*(s.size()-1)<<endl;
  else cout << ans+9*(s.size()-1)-1 <<endl;
}

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

struct Drink {
    int p;
    int x;
};

int main() {
    int N, M;
    cin >> N;
    int T[N];
    rep(i, N) cin >> T[i];
    cin >> M;
    vector<Drink> drinks;
    rep(i, M) {
        int p, x;
        cin >> p >> x;
        p--;
        drinks.push_back({p, x});
    }
    //
    int total = 0;
    rep(i, N) {total += T[i];}
    //
    for (auto d : drinks) {
        int ans = total - T[d.p] + d.x;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;

    cout << (X-Z) / (Y+Z) <<endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)n;++i)
#define SZ(a) (int)((a).size())
#define mp make_pair
#define pb push_back
#define F first
#define S second
typedef pair<int,int> PI;
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};


int w,h;
string in[100];
bool vis[100][100];
bool ok = 1;

pair<double,int> dfs(int x,int y){
  int su = 0;
  double we = 0;
  queue<PI> q;
  q.push(mp(x,y));
  int sitamax = -10;
  int sitamin = 1000;
  char ch = in[x][y];
  
  while(!q.empty()){
    int cx = q.front().F;
    int cy = q.front().S;
    q.pop();
    if(vis[cx][cy]) continue;
    ++su;
    we += cy;
    //cout << cx << " " << cy << endl;
    vis[cx][cy]=1;
    rep(i,4){
      int nx = cx + dx[i];
      int ny = cy + dy[i];
      if(min(nx,ny) <0 || ny>=w) continue;
      if(dx[i]==1 && in[nx][ny]!='.' && in[nx][ny] != ch){
        sitamax = max(sitamax,cy);
        sitamin = min(sitamin,cy);
        continue;
      }
      if(vis[nx][ny]) continue;
      if(in[nx][ny]=='.') continue;
      if(in[nx][ny]==ch){
        q.push(mp(nx,ny));
        continue;
      }
      
      if(dx[i]==-1){
        auto a = dfs(nx,ny);
        su += a.second;
        we += a.first * a.second;
      }
    }
  }
  
  ok &= sitamin-0.5 + 1e-6 < we/su && we/su < sitamax +0.5- 1e-6;
  // cout << x << " " << y << " " << su << " " << we/su << endl;
  // cout << ok << endl;
  return mp(we/su,su);
}

void solve(){
  memset(vis,0,sizeof(vis));
  rep(i,h) cin >> in[i];
  in[h]=string(w,'a');
  ok=1;
  rep(i,w){
    if(in[h-1][i]!='.'){
      dfs(h-1,i);
      break;
    }
  }

  cout << (ok?"STABLE":"UNSTABLE") << endl;
}

int main(){
  while(cin >> w >> h, w) solve();
}

Measured memory_bytes: 1256
#include <stdio.h>
#include <inttypes.h>

int N;
int A[271828];

int main(void) {
	int i;
	int makkusu = 0;
	uint64_t kitaeri = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		if (A[i] >= makkusu) {
			makkusu = A[i];
		} else {
			kitaeri += makkusu - A[i];
		}
	}
	printf("%" PRIu64 "\n", kitaeri);
	return 0;
}


Measured memory_bytes: 2488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

ll gcd(ll a, ll b) {
  if(a < b) gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


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

  ll t;
  cin >> t;
  ll a[t],b[t],c[t],d[t];
  rep(i,t) cin >> a[i] >> b[i] >> c[i] >> d[i];
  rep(i,t){
    if(a[i]<b[i] || b[i]>d[i]){
      cout << "No" << endl;
      continue;
    }  
    ll g=gcd(b[i],d[i]);
    ll mg=(a[i]-b[i]+1+(g-1))/g*g;
    //    cout << mg << " " << c[i]-a[i]+1 << endl;
    if(mg<=a[i]-c[i]-1){
      cout << "No" << endl;
    }
    else cout << "Yes" << endl;
    /*    
    bool say=false;
    if(b[i]-c[i]>2*g){
      cout << "No" << endl;
      continue;
    }
    for(ll j=c[i]-a[i]+1;j<b[i]-a[i];j++){
      if(j%g==0){
	//      cout << j << endl;
	cout << "No" << endl;
	say=true;
	break;
      }
      //    if(j==b[i]-a[i]-1) cout << "Yes" << endl;
    }
    if(!say) cout << "Yes" << endl;   */
  }
  

  
  return 0;
    

}


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

const double PI = 3.141592653585;

double r0, total;
double a,b, x;

double GetCapa( double r ) {
  if ( r0 > r ) {
    return total - (a * a * tan(r) * a / 2);
  } else {
    return b * b * tan(PI/2-r) * a / 2;
  }
}

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

  r0 = atan( b/a );
  total = a * a * b;

  double r_lit = 0;
  double r_big = PI/2;
  double rt;

  while ( 1 ) {
    rt = (r_big - r_lit) / 2 + r_lit; 
//    cout << " " << rt << " " << r_big << " " << r_lit <<endl;
    double capa = GetCapa( rt );
//    cout << r0 << " : " << rt << " : " << capa << " " << fabs(capa - x) << endl;
    if ( fabs(capa - x) <= 0.0000001 ) break;
    if (capa > x ) {
      r_lit = rt;
    } else {
      r_big = rt;
    }
  }

  cout << fixed << setprecision(10) << rt/PI*2*90 << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    bool nwse[4] = {0};
    for(unsigned int i = 0; i < s.size(); i++){
        switch(s[i]){
            case 'N': nwse[0] = 1; break;
            case 'W': nwse[1] = 1; break;
            case 'S': nwse[2] = 1; break;
            case 'E': nwse[3] = 1; break;
        }
    }
    if(nwse[0] == nwse[2] && nwse[1] == nwse[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    double N,A,B;
    cin>>N>>A>>B;
    double maxa,mina;
    if(N>A+B){
        mina=0;
        maxa=min(A,B);
    }else {
        mina=A+B-N;
        maxa=min(A,B);
    }
    cout<<maxa<<' '<<mina;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll x, y, z, k;
	cin >> x >> y >> z >> k;
	vector <ll> X, Y, Z;
	for(ll i = 0; i < x; i++){
		ll a;
		cin >> a;
		X.push_back(a);
	}
	for(ll i = 0; i < y; i++){
		ll a;
		cin >> a;
		Y.push_back(a);
	}
	for(ll i = 0; i < z; i++){
		ll a;
		cin >> a;
		Z.push_back(a);
	}
	sort(X.begin(), X.end(), greater<ll>{});
	sort(Y.begin(), Y.end(), greater<ll>{});
	sort(Z.begin(), Z.end(), greater<ll>{});
	set <tuple <ll, ll, ll> > uniq;
	vector <ll> largest;
	priority_queue <tuple <ll, ll, ll, ll> > pq;
	pq.emplace(X[0] + Y[0] + Z[0], 0, 0, 0);
	uniq.insert(make_tuple(0, 0, 0));
	for(ll i = 0; i < k; i++){
		ll sum, xi, yi, zi;
		tie(sum, xi, yi, zi) = pq.top();
		largest.push_back(sum);
		pq.pop();
		if(xi < x - 1){
			ll orig = uniq.size();
			uniq.insert(make_tuple(xi + 1, yi, zi));
			if(uniq.size() > orig) pq.emplace(X[xi + 1] + Y[yi] + Z[zi], xi + 1, yi, zi);
		}
		if(yi < y - 1){
			ll orig = uniq.size();
			uniq.insert(make_tuple(xi, yi + 1, zi));
			if(uniq.size() > orig) pq.emplace(X[xi] + Y[yi + 1] + Z[zi], xi, yi + 1, zi);
		}
		if(zi < z - 1){
			ll orig = uniq.size();
			uniq.insert(make_tuple(xi, yi, zi + 1));
			if(uniq.size() > orig) pq.emplace(X[xi] + Y[yi] + Z[zi + 1], xi, yi, zi + 1);
		}
	}
	for(ll i = 0; i < k; i++){
		cout << largest[i] << '\n';
	}
}

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

int main() {
	int h, w; cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s.at(i);
	}
	vector<vector<bool>> check(h, vector<bool>(w, false));
	vector<vector<int>> d = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };
	long long ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (check.at(i).at(j)) continue;
			int bl = 0, wh = 0;
			if (s.at(i).at(j) == '#') bl++;
			else wh++;
			check.at(i).at(j) = true;
			queue<pair<int, int>> q;
			q.push(make_pair(i, j));
			while (q.size() > 0) {
				auto p = q.front(); q.pop();
				int x = p.first, y = p.second;
				for (auto v : d) {
					int xdash = x + v.at(0), ydash = y + v.at(1);
					if (xdash < 0 || xdash >= h || ydash < 0 || ydash >= w || check.at(xdash).at(ydash) || s.at(xdash).at(ydash) == s.at(x).at(y)) continue;
					if (s.at(xdash).at(ydash) == '#') bl++;
					else wh++;
					check.at(xdash).at(ydash) = true;
					q.push(make_pair(xdash, ydash));
				}
			}
			ans += (long long) bl * wh;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		String[] s=sc.next().split("");

		String prev=s[0];
		int cnt=0;
		for (int i = 1; i < s.length; i++) {


			if(!prev.equals(s[i])) {
				cnt++;
			}

			prev=s[i];
		}

		System.out.println(cnt);
	}

	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

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

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


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

#define ll long long
#define mod 1000000007
#define debug1(x) cerr<<#x<<" : "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main() {
    IOS;
    ll n;
    cin>>n;
    ll a[n];
    ll x=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        x=__gcd(x,a[i]);
    }
    if(x!=1)cout<<"not coprime";
    else{

        map<ll,ll>mp;
        ll flag=0;
        for(ll i=0;i<n;i++){
            if(mp[a[i]]==1 && a[i]!=1){
                flag =1;
                break;
            }
            mp[a[i]]=1;
            for (ll j=2; j<=sqrt(a[i]); j++)
            {
                if (a[i]%j == 0)
                {
                    if (a[i]/j == j){
                        if(mp[j]==1){
                            flag =1;
                            break;
                        }
                        mp[j]=1;
                    }
                    else{
                        if(mp[j]==1 || mp[a[i]/j]==1){
                            flag =1;
                            break;
                        }
                        mp[j]=1;
                        mp[a[i]/j]=1;
                    }
                }
            }
            if(flag){
                break;
            }

        }
        if(!flag)cout<<"pairwise coprime";
        else cout<<"setwise coprime";
    }

    return 0 ;
}


Measured memory_bytes: 11304
#include<bits/stdc++.h>
using namespace std;
int n,k,i;
int a[1050];
int main()
{
    cin>>n>>k;
    while(n!=0)
    {
        a[i]=n%k;
        i++;
        n=n/k;
    }
    //cout<<ans;
    
    cout<<i;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 233
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

ll n;
int bit[sz],tp;
deque<int>a1,a2;

int main()
{
	file();
	read(n);++n;
	while (n) bit[++tp]=n&1,n>>=1;
	drep(i,tp,1) 
	{
		if (bit[i]) a1.push_back(i*2),a2.push_front(i*2);
		if (i!=1&&i!=tp) a1.push_back(i*2-1),a2.push_back(i*2-1);
	}
	printf("%d\n",(int)a1.size()*2);
	rep(i,0,(int)a1.size()-1) printf("%d ",a1[i]);
	rep(i,0,(int)a2.size()-1) printf("%d ",a2[i]);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int x,y;
    scanf("%d%d",&x,&y);
    if((y-2*x)%2==0 && y >= 2*x && y <= 4*x){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
  int height, width;
  cin >> height >> width;

  int squares[height][width] = {};
  for (int h = 0; h < height; ++h) {
    string s;
    cin >> s;
    for (int w = 0; w < width; ++w) {
       if (s[w] == '#') {
	squares[h][w] = 1;
      }
    }
  }

  for (int h = 0; h < height; ++h) {
    for (int w = 0; w < width; ++w) {
      if (squares[h][w] == 1) {
	if (h != 0) {
	  if (squares[h-1][w] == 1) {
	    continue;
	  }
	}
	if (h != height-1) {
	  if (squares[h+1][w] == 1) {
	    continue;
	  }
	}
	if (w != 0) {
	  if (squares[h][w-1] == 1) {
	    continue;
	  }
	}
	if (w != width-1) {
	  if (squares[h][w+1] == 1) {
	    continue;
	  }
	}
	printf("No\n");
	return 0;
      }
    }
  }

  printf("Yes\n");
  
  return 0;
}


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

int main(void)
{
	vector<int> numbers;
	int count, tmp, ans[5000], Max;

	while (cin >> count) {
		if (count == 0) break;
		for (int i = 0; i < 5000; i++) ans[i] = 0;
		Max = -100000;
		for (int i = 0; i < count; i++) {
			cin >> tmp;
			for (int j = 0; j <= i; j++) {
				ans[j] += tmp;
				if (Max < ans[j]) Max = ans[j];
			}
		}
		cout << Max << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1180
#include<cstdio>
#include<cstring>
#include<functional>
#include<algorithm>
#include<iostream>
#define TS 0
#define rep(i,a) for(i=1;i<=a;i++)
using namespace std;
int main(void)
{
	int n,i,j,k;
	int b,f,r,v;
	int bill[5][4][11];
	rep(i,4)rep(j,3)rep(k,10) {
		bill[i][j][k]=TS;
	}
	cin>>n;
	rep(i,n) {
		cin>>b>>f>>r>>v;
		bill[b][f][r]=bill[b][f][r]+v;
	}
	rep(i,4) {
		rep(j,3) {
			rep(k,10) printf("%2d",bill[i][j][k]);
			cout<<endl;
		}
		if(i==4) break;
		else {rep(j,20) cout<<"#";cout<<endl;}
	}
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i,j;
	int n,k;
	cin>>n>>k;
	VI v(n,1);
	for(i=0;i<k;i++){
		int d;
		cin>>d;
		for(j=0;j<d;j++){
			int x;
			cin>>x;
			x--;
			v[x]=0;
		}
	}
	int ans=0;
	for(i=0;i<n;i++) ans+=v[i];
	cout<<ans<<endl;

}

Measured memory_bytes: 3660
import java.util.*;


/**
 * Created by Seiya on 2016/10/16.
 */

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String s = scanner.next();
        int[] a = new int[27];

        for (int i = 0; i < s.length(); i++) {
            a[s.charAt(i) - 'a']++;
        }
        int flag = 0;
        for (int i = 0; i < 27; i++) {
            if(a[i] >= 2)flag = 1;
        }


        if(flag == 1){
            System.out.println("no");
        }else{
            System.out.println("yes");
        }

    } // mainMethod


} // MainClass


Measured memory_bytes: 23380