akhauriyash/Code-Regression huggingface dataset:
/*  ex7_3
    B30095    */
#include <stdio.h>
#include <stdlib.h>

void print_compressed(char ** grid, int rows, int cols);

int main(void){
    int rows, cols, isRowEmpty, isColEmpty, i, j;
    char ** grid;
    
    scanf("%d %d", &rows, &cols);
    
    // memory allocation
    grid = (char **)malloc(rows * sizeof(char *));
    for(i = 0; i < rows; i++){
        grid[i] = (char *)malloc(cols * sizeof(char));
    }

    // input grid
    for(i = 0; i < rows; i++){
        for(j = 0; j < cols; j++){
            scanf(" %c", &(grid[i][j]));
        }
    }

    print_compressed(grid, rows, cols);

    // memory deallocation
    
    for(i = 0; i < rows; i++){
        free(grid[i]);
    }
    free(grid);

    return 0;
}


void print_compressed(char ** grid, int rows, int cols){
    int isRowEmpty, isColEmpty, i, j;

        // substitue empty rows with whitespaces
    for(i = 0; i < rows; i ++){
        isRowEmpty = 1;
        
        // check if the row is empty
        for(j = 0; j < cols; j++){
            if(grid[i][j] == '#') {
                isRowEmpty = 0;
            }
        }

        // fill in empty rows with whitespaces
        if(isRowEmpty){
            for(j = 0; j < cols; j++){
                grid[i][j] = ' ';
            }
        }
    }

    // substitue empty columns with whitespaces
    for(j = 0; j < cols; j ++){
        isColEmpty = 1;
        
        // check if the column is empty
        for(i = 0; i < rows; i++){
            if(grid[i][j] == '#') {
                isColEmpty = 0;
            }
        }

        // fill in empty columns with whitespaces
        if(isColEmpty){
            for(i = 0; i < rows; i++){
                grid[i][j] = ' ';
            }
        }
    }


    // print compressed result
    for(i = 0; i < rows; i++){
        isRowEmpty = 1;

        for(j = 0; j < cols; j++){
            if(grid[i][j] == '#') isRowEmpty = 0;
            if(grid[i][j] != ' ') printf("%c", grid[i][j]);
            
        }

        if(!isRowEmpty) printf("\n");  // new line should not be printed when the row is empty
    }
}

Measured memory_bytes: 1580
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define int long long
#define pb push_back
#define ld long double
#define endl "\n";
#define deb1(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define printclock cerr << "Time : " << 1000 * (ld)clock() / (ld)CLOCKS_PER_SEC << "ms\n";
#define vii vector<int>
#define pii pair<int, int>
#define prec(n) fixed << setprecision(n)
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define MOD LLONG_MAX
#define INF 1000000007
inline void get(vector<int> &arr, int n)
{
    int a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        arr.push_back(a);
    }
}
inline void print(vector<int> &arr, int n)
{
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    cout << endl;
}
/*----------------------------------TEMPLATE------------------------------------*/

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    fast;
    int t;
    t = 1;
    while (t--)
    {
        int n;
        cin >> n;
        vii v;
        get(v, n);
        vector<vii> dp(n+1, vii(n+1, 0));
        for (int i = n - 1; i >= 0; i--)
        {
            for (int j = i; j < n; j++)
            {
                if(i==j)
                {
                    dp[i][j] = v[i];
                }
                else
                {
                    dp[i][j] = max(v[i] + dp[i][j] - dp[i+1][j], v[j] + dp[i][j] - dp[i][j-1]);
                }
            }
        }
        cout << dp[0][n-1] << endl;
    }
    printclock;
    return 0;
}

Measured memory_bytes: 73628
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <complex>
#include <stdio.h>
#include <unordered_set>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL MAXN = 100 + 1;
const LL MAXS = 100 + 1;
const LL MAXT = 100 + 1;

void ok()
{
	cout << "YES";
	exit(0);
}

void bad()
{
	cout << "NO";
	exit(0);
}

int n;
VVI g;
VCH used;
VI grundy;

void dfs(int v)
{
	used[v] = 1;
	VI h;
	for (auto i : g[v])
		if (used[i] == 0)
		{
			dfs(i);
			h.push_back(grundy[i]);
		}
	
	for (auto i : h)
		grundy[v] ^= (i + 1);

	++grundy[v];
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	cin >> n;
	g.resize(n);
	int u, v;
	FOR(i, 0, n - 1)
	{
		cin >> u >> v;
		--u; --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	used.assign(n, 0);
	grundy.assign(n, 0);

	dfs(0);
	if (grundy[0] > 1)
		cout << "Alice";
	else
		cout << "Bob";


	return 0;
}

Measured memory_bytes: 14080
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
long long int gcd(long long int a,long long int b);

int main (void){
        int N;
        long long int X,ans;
        long long int pos[100000];
        scanf("%d",&N);
        scanf("%lld",&X);
        scanf("%lld\n",&pos[0] );
        ans=abs(pos[0]-X);
for (int i = 1; i < N; i++) {
  scanf("%lld\n",&pos[i] );
  ans=gcd(abs(pos[i]-X),ans);
  if (ans==1) {
    printf("1\n" );
            return 0;
  }
}
printf("%lld\n",ans );
        return 0;
}


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

  return b;
}


Measured memory_bytes: 896
#include <stdio.h>
int main(){
	int x,y,z,t;
	scanf("%d%d%d",&x,&y,&z);
	x=x^y,y=x^y,x=x^y;
	x=x^z,z=x^z,x=x^z;
	printf("%d %d %d\n",x,y,z);
}

Measured memory_bytes: 128
open System

let inputs = stdin.ReadLine().Split(' ')
//

//------------------------------------------------
let N = inputs.[0] |> int64
let A = inputs.[1] |> int64
let B = inputs.[2] |> int64

let isEven x = (x % 2L) = 0L

let f a b = (b - a) / 2L

let solve a b =
    if isEven (b - a) then
        f a b
    else // Odd
        let m1 = (f a (b-1L)) + a
        let m2 = (f (a+1L) b) + (N-b+1L)
        //
        min m1 m2

solve A B |> printfn "%d"

Measured memory_bytes: 14040
#include<stdio.h>
#define LEN 100000
int main(){

  int i,mid,left,right,n,q,s[LEN],t[LEN],count=0;
  
  scanf("%d",&n);

  for(i=0;i < n ; i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  for(i = 0;i < q ; i++){
    scanf("%d",&t[i]);
     left = 0;
     right = n;
    
    while(left < right){
      mid = (left + right) / 2;
      if (s[mid] == t[i]){
	count++;
      break;
      }
      else if(t[i]<s[mid]){
	  right = mid;
	}
      else if(t[i]>s[mid]){
	  left = mid + 1;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}
    



Measured memory_bytes: 2276
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

signed main() {
	ll a, b, c, k;
	cin >> a >> b >> c;
	cin >> k;
	ll ans = 0;
	while (a >= b) {
		++ans;
		b *= 2;
	}
	while (b >= c) {
		++ans;
		c *= 2;
	}
	if (ans <= k)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        StringBuilder sb = new StringBuilder();
        char[] data = line.toCharArray();
        for(int i=0; i<data.length; i++){
            if(Character.isUpperCase(data[i])) {
                sb.append(Character.toLowerCase(data[i]));
            } else if(Character.isLowerCase(data[i])) {
                sb.append(Character.toUpperCase(data[i]));
            } else {
                sb.append(data[i]);
            }
        }
        System.out.println(new String(sb));
    }
}



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


int main(){
    int n,l; cin >> n >> l;
    vector<int> c(n);
    rep(i,n){
        c[i] = l+i;
    }
    vector<int> a(n);
    a = c;
    rep(i,n){
        a[i] = abs(a[i]);
    }

    int num;

    int b;
    rep(i,n){
        if(i==0){
            b = a[i];
            num = i;
        }else{
            if(b > a[i]){
                b = a[i];
                num = i;
            }
        }
    }
    int sum=0;
    rep(i,n){
        if(i!=num){
            sum+=c[i];
        }
    }
    cout << sum << endl;


}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

vector<ll> tree[100010];
vector<ll> cost[100010];
bool reached[100010];
ll depth[100010];

void dfs(int v, ll d) {
  reached[v] = true;
  depth[v] = d;
  rep(i, tree[v].size()) {
    if(!reached[tree[v][i]]) {
      dfs(tree[v][i], d + cost[v][i]);
    }
  }
}

signed main() {
	ll n;
  cin >> n;
  rep(i, n - 1) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    tree[a].pb(b);
    cost[a].pb(c);
    tree[b].pb(a);
    cost[b].pb(c);
  }
  ll q, k;
  cin >> q >> k;
  k--;
  dfs(k, 0);
  rep(i, q) {
    ll x, y;
    cin >> x >> y;
    x--, y--;
    cout << depth[x] + depth[y] << endl;
  }
	return 0;
}

Measured memory_bytes: 18304
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k=map(int, readline().rstrip().split())

    mod = 10**9+7
    a=0
    z=0
    ans=0
    n+=1
    for i in range(1,n+1):
        a+=i
        z+=(n-i+1)
        cnt=z-a+1
        if i>=k:
            ans+=cnt
            ans%=mod
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16180
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	vector<pair<int, int> > ans;
	int ma = 0, mi = 0,ab=0,abss=0,ai=0;
	REP(i, N) {
		cin >> A[i];
		ma = max(ma, A[i]);
		mi = min(mi, A[i]);
		if (ab < abs(A[i])) {
			ab = max(ab, abs(A[i]));
			abss = A[i];
			ai = i+1;
		}

	}
	if (ma >= 0 && mi >= 0) {
		REP(i, N - 1) {
			ans.push_back(make_pair(i + 1, i + 2));
		}
	}
	else if(ma<=0 && mi<=0){
		for (int i = N; i > 1;i--) {
			ans.push_back(make_pair(i, i - 1));
		}
	}
	else if (abss >= 0) {
		eFOR(i, 1, N) {
			if (ai != i)ans.push_back(make_pair(ai, i));
		}
		REP(i, N - 1) {
			ans.push_back(make_pair(i + 1, i + 2));
		}
	}
	else {
		eFOR(i, 1, N) {
			if (ai != i)ans.push_back(make_pair(ai, i));
		}
		for (int i = N; i > 1; i--) {
			ans.push_back(make_pair(i, i - 1));
		}
	}

	cout << ans.size() << endl;
	REP(i, ans.size()) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, -1, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int D,N;cin>>D>>N;
  int T[D];FOR(i,0,D)cin>>T[i];
  int A[N],B[N],C[N];
  FOR(i,0,N)cin>>A[i]>>B[i]>>C[i];
  ll dp[D][N];
  CLR(dp);
  FOR(i,0,N){
    if(T[0]>=A[i]&&T[0]<=B[i]){
      dp[0][i]=0;
    }
  }
  ll ans=0;
  FOR(i,0,D-1){
    FOR(j,0,N){
      if(dp[i][j]==-1)continue;
      // i+1日目にkをきる
      FOR(k,0,N){
        if(T[i+1]>=A[k]&&T[i+1]<=B[k]){
          dp[i+1][k]=max(dp[i+1][k],dp[i][j]+abs(C[j]-C[k]));
          ans=max(ans,dp[i+1][k]);
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3400
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

#define MAX_N 1000000
#define MAX_M 1000000
#define MAX_K 1000000
#define INF 1000000

int A[MAX_M];
int B[MAX_M];
int C[MAX_K];
int D[MAX_K];

vector<int> G_fr[MAX_N];
vector<int> G_bl[MAX_N];

int group[MAX_N];

struct UnionFind {

  vector<int> par;
  vector<int> rank;
  UnionFind(int N) : par(N), rank(N) {

    for (int i = 0; i < N; i++) {
      par[i] = i;
      rank[i] = 0;
    }
    
  }

  int find(int x) {
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x, int y) {

    int rx = find(x);
    int ry = find(y);
    
    if (rx == ry) return;

    if (rank[rx] < rank[ry]) {
      par[rx] = ry;
    }
    else if (rank[rx] > rank[ry]) {
      par[ry] = rx;
    }
    else {
      par[ry] = rx;
      rank[rx]++;
    }
  }

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


int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, M, K;
  cin >> N >> M >> K;

  UnionFind uf(N);
  
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;

    A[i] = --a;
    B[i] = --b;
    
    G_fr[ A[i] ].push_back(B[i]);
    G_fr[ B[i] ].push_back(A[i]);
   
    uf.unite(A[i], B[i]);
    
  }

  for (int i = 0; i < K; i++) {
    int c, d;
    cin >> c >> d;

    C[i] = --c;
    D[i] = --d;

    G_bl[ C[i] ].push_back(D[i]);
    G_bl[ D[i] ].push_back(C[i]);
    
  }

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

  map<int, int> mp;
  
  for (int i = 0; i < N; i++) {

    int gid = uf.find(i); //parent
    group[i] = gid;
      
    if( mp.find(gid) == mp.end() ) {
      mp[gid] = 1;
    }
    else {
      mp[gid]++;
    }
    
  }


  /*
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    cout << "Group:" << itr->first << ", Count:" << itr->second << endl;
  }
  */
  
  for (int i = 0; i < N; i++) {
    int gid = uf.find(i);

    int count = mp[gid];

    //cout << "Person = " << i << endl;
    //cout << " group = " << gid << endl;
    
    // 直接の友達を引く
    int n_fr = G_fr[i].size();
    count = count - n_fr;
    //cout << " friend = " <<  n_fr << endl;

    // ブロック対象が同じグループなら引く
    //int n_bl = G_bl[i].size();
    //cout << " block = " << n_bl << endl;
    //count = count - n_bl;
    
    for(int j = 0; j < G_bl[i].size(); j++) {
      int gid_bl = uf.find( G_bl[i][j] );
      if (gid_bl == gid) count--;
    }
    

    // 自分を引く
    count--;

    // display
    
    cout << count;
    if(i != N-1) cout << " ";
    
  }

  cout << endl;
  
  return 0;
  
}


Measured memory_bytes: 64256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int ans = 0;
    for(int i = 1; i < n; i++){
        int cnt = 0;
        
        for(char c='a'; c<='z'; c++){
            bool left = false, right = false;
            
            for(int j = 0; j<i; j++){
                if(s[j] == c){
                    left= true;
                }
            }
            for(int j = i; j<n; j++){
                if(s[j] == c){
                    right= true;
                }
            }
            if(left&&right){
                cnt++;
            }
        }
        if(ans<cnt){
            ans = cnt;
        }
    }
    cout << ans << endl;
}


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

flag = True
ans = 0
for i in range(1, N):
    if S[i] == S[i-1]:
        ans += 1
    if K != 0:
        if flag:
            if S[i-1] != S[i]:
                flag = False
                ans += 1
        else:
            if S[i-1] != S[i]:
                flag = True
                ans += 1
                K -= 1
print(ans)

Measured memory_bytes: 4084
use std::cmp;

fn main(){
  loop {
    let nm: Vec<usize> = read_vec();
    let n = nm[0];
    let m = nm[1] as u32;

    if n == 0 && m == 0 { break; }
    
    let mut d: Vec<u32> = vec![0];
  
    for _ in 0 .. n {
      d.push(read());
    }

    let mut d2: Vec<u32> = Vec::new();
    
    for i in 0 .. n+1 {
      for j in 0 .. n+1 {
        let t = d[i] + d[j];
        if t <= m {
          d2.push(t);
        }
      }
    }

    d2.sort();

    let mut ans: u32 = 0;
    
    for i in 0 .. d2.len() {
      let t = bsearch(&d2, m-d2[i]);
      ans = cmp::max(ans, t + d2[i]);
    }
    
    println!("{}", ans);
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}

fn bsearch(v: &Vec<u32>, x: u32) -> u32 {
  let mut l: usize = 0;
  let mut r: usize = v.len();
  
  loop {
    if l + 1 == r { break; }
    let m = (l + r) / 2;
    if v[m] <= x {
      l = m;
    } else {
      r = m;
    }
  }
  v[l]
}



Measured memory_bytes: 10668
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Abc169D
    {
        public static void Main()
        {
            var n = long.Parse(Console.ReadLine());
            List<int> degree = Factorize(n);
            if (!degree.Any())
            {
                Console.WriteLine(0);
                return;
            }

            var max = degree.Max();
            int m = 3;
            int x = 1;
            var s = new int[max + 1];
            for (int i = 1; i <= max; i++)
            {
                if (m <= i)
                {
                    x++;
                    m = (x + 1) * (x + 2) / 2;
                }
                s[i] = x;
            }
            Console.WriteLine(degree.Sum(i => s[i]));
        }

        static List<int> Factorize(long n)
        {
            var factors = new List<int>();
            for (long i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    int degree = 1;
                    while ((n /= i) % i == 0)
                        degree++;
                    factors.Add(degree);
                }
            }
            if (n != 1)
                factors.Add(1);
            return factors;
        }
    }
}

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

int main() {
	
	vector<char> sec(4);
	
	for(int i=0; i<4; i++){
		
		cin >>sec.at(i);
		
	}
	
	if(sec.at(0)==sec.at(1)||sec.at(1)==sec.at(2)||sec.at(2)==sec.at(3)){
		
		cout <<"Bad" <<endl;
		
	}
	else{
		
		cout <<"Good" <<endl;
		
	}

}

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

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	map < string, int > cnt;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		++cnt[s];
	}
	cout << "AC" << " x " << cnt["AC"] << '\n';
	cout << "WA" << " x " << cnt["WA"] << '\n';
	cout << "TLE" << " x " << cnt["TLE"] << '\n';
	cout << "RE" << " x " << cnt["RE"] << '\n';
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
  int N;
  cin >> N;

  char S[305][305];
  rep(i,N) rep(j,N) cin >> S[i][j];

  int ans = 0;
  int j=0;
  rep(i,N){
      rep(k,N){
        REP(l,k+1,N){
          if(S[(i+k)%N][(j+l)%N] != S[(i+l)%N][(j+k)%N])
            goto dbreak;
        }
      }
      ans++;
      dbreak:
        ;
  }

  cout << ans * N << endl;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int P,Q,R,sum1,sum2,sum3,sum,num;
	cin>>P>>Q>>R;
	sum1=P+Q;
	sum2=P+R;
	sum3=R+Q;
	if(sum1>sum2)
	sum=sum2;
	else
	sum=sum1;
	if(sum>sum3)
	num=sum3;
	else
	num=sum;
	cout<<num<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=100005,mod=1e9+7;
int fact[N];
int add(int x,int y)
{
  x+=y;
  if(x>=mod) x-=mod;
  return x;
}
int mult(int x,int y)
{
  ll tmp=(ll)x*y;
  if(tmp>=mod) tmp%=mod;
  return tmp;
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  fact[0]=1;
  rep(i,1,N)
    fact[i]=mult(fact[i-1],i);
  int n,m;
  cin>>n>>m;
  int ans=0;
  if(n<m) swap(n,m);
  if(n==m)
    {
      ans=mult(fact[n],fact[n]);
      ans=mult(ans,2);
    }
  else if(n-m==1)
    ans=mult(fact[n],fact[m]);
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 640
#include<stdio.h>
int QX[145];
int QY[145];
int X[3]={-1,0,1};
int Y[3]={ 0,1,0};
int main(){
  char s[14];
  int n,m[14][14]={{0}};
  int q,r,c,i,j,k;
  while(scanf("%s",s)!=EOF){
    for(i=0;i<12;i++)m[0][i+1]=s[i]-'0';
    for(i=1;i<12;i++){
      scanf("%s",s);
      for(j=0;j<12;j++)m[i][j+1]=s[j]-'0';
    }
    c=0;
    for(i=0;i<12;i++){
      for(j=1;j<13;j++){
	if(m[i][j]==1){
	  q=0;
	  QX[0]=j;
	  QY[0]=i;
	  r=1;
	  c++;
	  m[i][j]=0;
	  while(q!=r){
	    for(k=0;k<3;k++){
	      if(m[QY[q]+Y[k]][QX[q]+X[k]]==1){
		QY[r]=QY[q]+Y[k];
		QX[r]=QX[q]+X[k];
		r++;
		m[QY[q]+Y[k]][QX[q]+X[k]]=0;
	      }
	    }
	    q++;
	  }
	}
      }
    }
    printf("%d\n",c);
  }return 0;
}

Measured memory_bytes: 540
A,B,C = [int(i) for i in input().split()]
if A == B == C and not A&1:
    print(-1)
    exit()
c = 0
while not (A&1 or B&1 or C&1):
    A,B,C = (B+C)//2, (A+C)//2, (A+B)//2
    c += 1
print(c)

Measured memory_bytes: 9184
#include<stdio.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void Radix32(int *a,const int sz)
{
  int x,shift=0,elem[0400],temp[sz];
  while(shift<040)
  {
    int bucket[0400]={0};
    rep(i,sz){x=(a[i]>>shift)&0377;bucket[x]++;temp[i]=a[i];}
    elem[0]=0;rep(i,0377)elem[i+1]=elem[i]+bucket[i];
    rep(i,sz){x=(temp[i]>>shift)&0377;a[elem[x]]=temp[i];elem[x]++;}
    shift+=010;
  }
}
int main(void){int N=IN(),A[N];long sum=0;rep(i,N){A[i]=IN();}Radix32(A,N);rep(i,N-1){sum+=A[N-1-(i+1)/2];}return printf("%ld\n",sum),0;}

Measured memory_bytes: 3132
#include<stdio.h>
#include<queue>
int n;
int m;
std::priority_queue<int> pq;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        int x;
        scanf("%d",&x);
        pq.push(x);
    }
    for(int i=0;i<m;i++){
        int price=pq.top();pq.pop();
        price/=2;
        pq.push(price);
    }
    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=pq.top();
        pq.pop();
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 892
#include <cstring>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <map>
#include <iostream>
#include <string>
using namespace std;
typedef long long int lli;
typedef pair<int,int> P;
const int INF=100000000;
const long long int INF_=1000000000000000000;

inline int f(int x){
	if(x==0) return 1;
	else return 0;
}

int main(){
	int H,W,N;
	while(cin >> H >> W >> N&&H){
		vector<vector<int> > g(H,vector<int>(W));
		vector<vector<int> > c(H,vector<int>(W));
		for(int i=0; i<H; ++i){
			for(int j=0; j<W; ++j){
				cin >> g[i][j];
			}
		}
		c[0][0]=N-1;
		for(int i=1; i<W; ++i){
			if(c[0][i-1]%2==0) c[0][i]=c[0][i-1]/2;
			else if(g[0][i-1]==0) c[0][i]=(c[0][i-1]-1)/2;
			else c[0][i]=(c[0][i-1]+1)/2;
		}
		for(int i=1; i<H; ++i){
			if(c[i-1][0]%2==0) c[i][0]=c[i-1][0]/2;
			else if(g[i-1][0]==0) c[i][0]=(c[i-1][0]+1)/2;
			else c[i][0]=(c[i-1][0]-1)/2;
		}
		for(int i=1; i<H; ++i){
			for(int j=1; j<W; ++j){
				if(c[i][j-1]%2==0) c[i][j]+=c[i][j-1]/2;
				else if(g[i][j-1]==0) c[i][j]+=(c[i][j-1]-1)/2;
				else c[i][j]+=(c[i][j-1]+1)/2;
				if(c[i-1][j]%2==0) c[i][j]+=c[i-1][j]/2;
				else if(g[i-1][j]==0) c[i][j]+=(c[i-1][j]+1)/2;
				else c[i][j]+=(c[i-1][j]-1)/2;
			}
		}
		for(int i=0; i<H; ++i) for(int j=0; j<W; ++j) g[i][j]=(c[i][j]%2==0?g[i][j]:f(g[i][j]));
		
		{
			int y=0,x=0;
			while(y!=H&&x!=W){
				if(g[y][x]==0) ++y;
				else ++x;
			}
			cout << y+1 << ' ' << x+1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 8992
class UnionFind:
    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.rank = [1]*n
    
    def root(self, x):
        if x == self.p[x]:
            return x
        self.p[x] = y = self.root(self.p[x])
        return y
    
    def unite(self, x, y):
        px = self.root(x); py = self.root(y)
        if px == py:
            return 0
        rx = self.rank[px]; ry = self.rank[py]
        if ry < rx:
            self.p[py] = px
        elif rx < ry:
            self.p[px] = py
        else:
            self.p[py] = px
            self.rank[px] += 1
        return 1

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

N,M = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(M)]
count = 0
for i in range(M):
    a,b = AB[i]
    union_find = UnionFind(N+10)
    for j in range(M):
        if i == j:
            continue
        union_find.unite(AB[j][0],AB[j][1])
    if not union_find.same(a,b):
        count += 1
print(count)

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

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

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

int main(){
  ll N,M;
  string s,t;
  cin >> N >> M >> s >> t;

  if(s[0] != t[0]){
    cout << "-1" << endl;
    return 0;
  }
  ll l;
  if(N >= M) l = lcm(N,M);
  else l = lcm(M,N);

  ll s_width = l / M;
  ll t_width = l / N;

  bool frag = true;
  ll sw = 0, tw = 0;
  while(sw<N && tw<M){
    if(s[sw] != t[tw]){
      frag = false;
    }
    sw += s_width;
    tw += t_width;

  }
  if(frag) cout << l << endl;
  else cout << "-1" << endl;
  return 0;
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
	string n;
	while(cin >> n){
		if(cin.eof()) break;
		int it=0;
		string a="",b="",c="";
		while(n[it]!='+') a+=n[it++];it++;
		while(n[it]!='=') b+=n[it++];it++;
		while(it<n.size()) c+=n[it++];

		reverse(a.begin(),a.end());
		reverse(b.begin(),b.end());
		reverse(c.begin(),c.end());


		int ans=-1;

		rep(d,10){
			string ca=a,cb=b,cc=c;
			rep(i,ca.size()) if(ca[i]=='X') ca[i]=d+'0';
			rep(i,cb.size()) if(cb[i]=='X') cb[i]=d+'0';
			rep(i,cc.size()) if(cc[i]=='X') cc[i]=d+'0';

			if(d==0&&ca.size()>=2&&ca[ca.size()-1]=='0') continue;
			if(d==0&&cb.size()>=2&&cb[cb.size()-1]=='0') continue;
			if(d==0&&cc.size()>=2&&cc[cc.size()-1]=='0') continue;

			string sum="";
			int carry=0,m=cc.size();
			rep(i,m){
				int cur=carry;
				if(i<ca.size()) cur+=(ca[i]-'0');
				if(i<cb.size()) cur+=(cb[i]-'0');
				carry=cur/10;
				sum+=(cur%10+'0');
			}
			if(carry==0&&sum==cc){
				ans=d;
			}
		}
		if(ans==-1)
			cout << "NA" << endl;
		else
			cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
N=int(input())
A=sorted(list(map(int,input().split())))

import bisect
i=-1
bunshi=A[i]
target=A[i]/2
tarp=bisect.bisect_left(A,target)
diff=10**9+1
if tarp-1>=0:
  diff=abs(target-A[tarp-1])
if abs(target-A[tarp])<diff:
  print(bunshi,A[tarp])
else:
  print(bunshi,A[tarp-1])


Measured memory_bytes: 14428
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int s = sc.nextInt();
    if(s==1 || s==2){
      System.out.print(4);
      return;
    }
    int a=s;
    int b=s;
    int count=1;
    while(a!=4){
      if(b%2==0){
      	a=b/2;
      }else{
      	a=3*b+1;
      }
      b=a;
      count++;
    }
    System.out.print(count+3);
  }
}

Measured memory_bytes: 35592
def fact(y, x1, x2):
	island[y] = island[y][:x1] + "0" + island[y][x2:]
	if island[y-1][x1:x2] == "1":
		fact(y-1, x1, x2)
	if island[y+1][x1:x2] == "1":
		fact(y+1, x1, x2)
	if island[y][x1-1:x2-1] == "1":
		fact(y, x1 - 1, x2 - 1)
	if island[y][x1+1:x2+1] == "1":
		fact(y, x1 + 1, x2 + 1)

while True:
	island = []
	for _ in xrange(12):
		island.append(raw_input())
	
	island.insert(0, "00000000000000")
	island.append("00000000000000")
	for i in xrange(12):
		island[i+1] = "0" + island[i+1] + "0"
	
	count = 0
	for i in xrange(12):
		for j in xrange(12):
			if island[i+1][j+1:j+2] == "1":
				fact(i+1, j+1, j+2)
				count += 1
		
	print count
	try:
		raw_input()
	except EOFError:
		break

Measured memory_bytes: 6276
#include <iostream>
#include <algorithm>

inline void fastin(int &num) {
    bool neg = false;
    int c;
    num = 0;
    c = getchar_unlocked();
    if (c == '-') {
        neg = true;
        c = getchar_unlocked();
    }
    for (; (c > 47 && c < 58); c = getchar_unlocked()) num = num * 10 + c - 48;
    if (neg) num *= -1;
}

inline void fastout(int n) {
    int N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar_unlocked('0');
}

int main(){
    int n, c, k; fastin(n); fastin(c); fastin(k);
    int t[n];
    for (int i = 0; i < n; ++i) fastin(t[i]);

    std::sort(t, t + n);

    int ans = 0;
    int beg = 0;
    while (beg < n){
        int end = beg;
        while (end - beg + 1 < c && t[end + 1] - t[beg] <= k){
            ++end;
            if (end == n - 1) break;
        }
        ++ans; beg = end + 1;
        /*
        if (beg == n - 1){
            ++ans; break;
        }
        */
    }
    fastout(ans);
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int n,a_max1,a_max2,b_max1,b_max2,a1,a2,b1,b2,x,y;
int main(){
     cin>>n;
   for(int i=1;i<=n/2;i++)
   {
     cin>>x>>y;
     a[x]++;
     if(a[x]>a_max1)
     {
     	a_max1=a[x];a1=x;
     }
     else
     if(a[x]>=a_max2)
     {
     	a_max2=a[x];a2=x;
     }
	 b[y]++;
	 if(b[y]>b_max1)
     {
     	b_max1=b[y];b1=y;
     }
  else
     if(b[y]>=b_max2)
     {
     	b_max2=b[y];b2=y;
     }
   }
   //cout<<a1<<" "<<a2<<a_max1<<" "<<a_max2<<endl;
    //cout<<b1<<" "<<b2<<b_max1<<" "<<b_max2<<endl;
  if(a1!=b1)cout<<n-a_max1-b_max1;
  else cout<<n-max(a_max1+b_max2,a_max2+b_max1);

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int k, a, b;
    cin >> k >> a  >> b;
    int x = a / k;
    if (a % k != 0) x++;
    if (a <= x * k && b >= x * k){
        out("OK");
    }
    else out("NG");
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X, Y; cin >> X >> Y;
  if(X < Y) cout << X << endl;
  else if(X == Y) cout << -1 << endl;
  else {
    if(X % Y == 0) cout << -1 << endl;
    else cout << X << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import bisect


n = int(input())
x = list(map(int, input().split()))
l = int(input())
q = int(input())
info = [list(map(int, input().split())) for i in range(q)]


#logテーブルを作成する
log_table = [[0]*n for i in range(17)]
for i in range(n):
    log_table[0][i] = bisect.bisect_right(x, x[i] + l) - 1
for j in range(1, 17):
    for i in range(n):
        log_table[j][i] = log_table[j-1][log_table[j-1][i]]

#二分探索で解を求める
def solve(_from, to, day):
    pos = _from
    i = 0
    while day:
        if day // 2 > 0:
            if day % 2 == 1:
                pos = log_table[i][pos]
            i += 1
            day = day // 2
        else:
            if day % 2 == 1:
                pos = log_table[i][pos]
            break
    if to <= pos:
        return True
    else:
        return False

#クエリに答える
for i in range(q):
    ok = n - 1
    ng = 0
    start, goal = info[i]
    start -= 1
    goal -= 1
    if start > goal:
        start, goal = goal, start
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if solve(start, goal, mid):
            ok = mid
        else:
            ng = mid
    print(ok)

Measured memory_bytes: 107544
# B: TAKOYAKI FES
N = int(input())
D = [int(d) for d in input().split()]
deli_list = [x*y for x in D for y in D]

# sum of diagonal 
self_comb = sum(D[i]*D[i] for i in range(N))

# (sum of 2D-Table - sum of diagonal) / 2
ans = int(((sum(deli_list)-self_comb)/2))
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
char c;
char s1[200],s2[200];
int t1,t2;
int f=0;

bool check(int s)
{
    for (int i=0; i<t1; ++i)
        if (s1[(s+i)%t1]!=s2[i])
            return 0;
    return 1;
}

int main()
{
    while (1)
    {
        scanf("%c",&c);
        if (c=='\n') break;
        s1[t1++]=c;
    }
    while (1)
    {
        scanf("%c",&c);
        if (c=='\n') break;
        s2[t2++]=c;
    }
    for (int i=0; i<t1; ++i)
        if (check(i)) f=1;
    if (f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}
    


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int a[10];
	int i,j;
	for(i=0; i<3; i++) {
		scanf("%d",&a[i]);
	}
	int sum=1;
	int b[3];
	b[0]=a[0];
	int t=1;
	for(i=1; i<3; i++) {
		for(j=0; j<=i; j++) {
			if(a[j]==a[i]&&i!=j) {
				break;
			}
			if(i==j) {
				sum++;
			}
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    string s1, s2;
    cin>>s1>>s2;
    for(int i = 0; i < sz(s1); i++){
        if(s1[i]!=s2[i]){
            cout<<"No\n";
            return;
        }
    }
    cout<<"Yes\n";
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3648
//https://blog.csdn.net/hesorchen
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define endl "\n"
#define lowbit(a) (a & (-a))
#define INF 0x3f3f3f3f
#define MAX 1010
#define mod 1000000007
#define PI 3.1415926
#define test_ printf("*************\n");

int main()
{
    int a, b;
    char c;
    scanf("%d %c %d", &a, &c, &b);
    if (c == '+')
        cout << a + b << endl;
    else
        cout << a - b << endl;
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    int a[3];
    rep(i,3)    cin>>a[i];
    sort(a,a+3);
    int k;
    cin>>k;
    while(k>0){
        k--;
        a[2]*=2;
    }
    cout<<a[0]+a[1]+a[2]<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
A,B=[],[]
for i in range(n):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
ans=0
for i in range(n):
  a,b=A[-(i+1)],B[-(i+1)]
  ans+=((a+ans-1)//b+1)*b-(a+ans)
print(ans)

Measured memory_bytes: 11040
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	int n; cin >> n;
	string s; cin >> s;
	vvi dp(n+1,vi(n+1,0));
	rep2(i,1,n+1)rep2(j,1,n+1){
		if(s[i-1]==s[j-1]) dp[i][j] = min(abs(i-j),dp[i-1][j-1]+1);
	}
	int ans = 0;
	rep(i,n+1)rep(j,n+1) ans = max(ans,dp[i][j]);
	cout << ans << endl;
}




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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
//ユークリッドの互除法
int gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}
int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    ll N,X;
    cin >>N>>X;

    vector<ll> x(N);
    rep(i,N) cin >> x[i];
    ll ans=abs(x[0]-X);
    repd(i,1,N) ans=gcd(ans,abs(x[i]-x[i-1]));
    
    //-----------------------------------

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

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

int main()
{
int N;
int A;
int B;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> A;
	cin >> B;

	if( N * A > B )
		cout << B << endl;
	else
		cout << N * A << endl;

	return 0;
}






Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a,b,c,x;
  scanf("%d %d %d",&a,&b,&c);
  if(a>=1 && b>=1 && c>=1 && a<=10000 && b<=10000 && c<=10000)
  {
    if(a<b)
    {
      if(b<c)printf("%d %d %d\n",a,b,c);
      else if(b>c && a<c)printf("%d %d %d\n",a,c,b);
      else printf("%d %d %d\n",c,a,b);
    }
    else if(a>b)
    {
      if(a<c)printf("%d %d %d\n",b,a,c);
      else if(a>c && b<c)printf("%d %d %d\n",b,c,a);
      else printf("%d %d %d\n",c,b,a);
    }
  }
  return 0;
}

Measured memory_bytes: 596
// #include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
void solve(){
    int n;
    string s;
    cin>>n;
    map<string,int> m;
    while(n--) {
      cin>>s;
      m[s]++;
    }
    cout << "AC x "<<m["AC"]<< "\n";
    cout << "WA x "<<m["WA"]<< "\n";
    cout << "TLE x "<<m["TLE"]<< "\n";
    cout << "RE x "<<m["RE"]<< "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
} 

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INT(a) int((a)+1e-9)
#define SUPpl 100002

typedef long long ll;

int i,j,k,l;
int pl;
ll ps[SUPpl*2];
ll sps[SUPpl*2+1];
ll re;
int rei=0,rej=0,rek=0;

void decideK(){
	int ak=j;
	int bk=l;
	while(bk-ak>1){
		k = (ak+bk)/2;
		if( sps[k]-sps[j] ==sps[l]-sps[k] ) {ak=k;bk=k;break;}
		if( sps[k]-sps[j] < sps[l]-sps[k] ) ak=k;
		if( sps[k]-sps[j] > sps[l]-sps[k] ) bk=k;
	}
	if(min(sps[ak]-sps[j],sps[l]-sps[ak]) >= min(sps[bk]-sps[j],sps[l]-sps[bk])) k=ak;
	else k=bk;
}

void decideJK(){
	int aj=i;
	int bj=l;
	while(bj-aj>1){
		j = (aj+bj)/2;
		decideK();
		if( sps[j]-sps[i] ==min(sps[k]-sps[j],sps[l]-sps[k]) ) {aj=j;bj=j;break;}
		if( sps[j]-sps[i] < min(sps[k]-sps[j],sps[l]-sps[k]) ) aj=j;
		if( sps[j]-sps[i] > min(sps[k]-sps[j],sps[l]-sps[k]) ) bj=j;
	}
	j=aj;
}

void decideIJK(){
	re=0;
	for(i=0;i<pl;i++){
		l=i+pl;
		decideJK();
		if(re<sps[j]-sps[i]){
			re=sps[j]-sps[i];
			rei=i;rej=j;rek=k;
		}
	}
}

int main(){
	cin >> pl;
	REP(pi,pl) cin>>ps[pi];
	REP(pi,pl) ps[pi+pl]=ps[pi];
	REP(pi,pl*2) sps[pi+1]=sps[pi]+ps[pi];

	decideIJK();
	cout<<re<<endl;

	return 0;
}

Measured memory_bytes: 4292
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  string S; cin>>S;
  int w; cin>>w;
  REP(i,S.length()) {
    if(i % w == 0) cout	<< S[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256