akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

struct UnionFind {
    
    vector<int> par;

    // n要素で初期化
    UnionFind(int n) {
        par.assign(n, -1);
    }

    // 木の根を求める
    int find_root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = find_root(par[x]);
    }

    // xとyの属する集合を併合
    bool merge(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    // xとyが同じ集合に属するか判定
    bool is_same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    int size(int x) {
        return -par[find_root(x)];
    }
};

int main() {

    int n, m;
    cin >> n >> m;

    UnionFind UF(n);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        UF.merge(a, b);
    }

    int ans = 0;
    for(int i = 0; i < n; i++) {
        ans = max(ans, UF.size(i));
    }

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

Measured memory_bytes: 4052
#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define REPR(i,n) for (int i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)

const int MAX = 310;

int N;
ld dp[MAX][MAX][MAX];

ld solve (int c1, int c2, int c3) {
  int sum = c1 + c2 + c3;
  if (sum == 0) return 0;
  if (dp[c1][c2][c3] > 0) return dp[c1][c2][c3];
  ld ret = 1.0*N;
  if (c1) ret += solve(c1-1, c2, c3) * c1;
  if (c2) ret += solve(c1+1, c2-1, c3) * c2;
  if (c3) ret += solve(c1, c2+1, c3-1) * c3;
  return dp[c1][c2][c3] = ret/sum;
}

int main () {
  cin >> N;
  int n1 = 0, n2 = 0, n3 = 0, n;
  REP (i, N) {
    cin >> n;
    n1 += (n==1); n2 += (n==2); n3 += (n==3);
  }
  cout << setprecision(12) << solve(n1, n2, n3) << endl;
}

Measured memory_bytes: 450816
cnt = 0
n = int(raw_input())
A = [int(raw_input()) for _ in range(n)]
G = [1] if n < 5 else [1, 4]
while G[-1]*3+1 <= n/3: G.append(G[-1]*3+1)
if n > 256: G.append(n/10*9+G[-1]%2+1)
G.reverse()

def insersionSort(g):
	global cnt
	for i in range(g, n):
		v = A[i]
		j = i - g
		while j >= 0 and A[j] > v:
			A[j+g] = A[j]
			j = j - g
			cnt += 1
		A[j+g] = v

def shellSort():
	for g in G:
		insersionSort(g)

shellSort()
print len(G)
print " ".join(map(str, G))
print cnt
print "\n".join(map(str, A))

Measured memory_bytes: 127116
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n, v, p;
    ll m;
    cin >> n >> m >> v >> p;
    int w = n - v;
    ll a[n]; for (auto &ai:a) cin >> ai;
    sort(a, a+n, greater<ll>());
    int cnt=p;
    ll rui[n+1], prev = a[p-1];
    rui[0] = 0;
    for (int i=0; i<n; i++) rui[i+1] = rui[i] + a[i];
    while (true) {
        while (cnt < n && a[cnt] == prev) cnt++;
        if (cnt == n || a[p-1] > a[cnt] + m || rui[cnt] - rui[p-1] - a[cnt] * (cnt - p + 1) > w*m)
            break;
        prev = a[cnt];
        cnt++;
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vs= vector<string>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define INF (100000000)
int dp[2][10005][2];
int N;
int T[10001];
int solve(){
  for(int i=0;i<2;i++)
    for(int j=0;j<10005;j++)
      for(int k=0;k<2;k++)
	dp[i][j][k]=INF;
  dp[0][0][0]=0;
  for(int i=0;i<N;i++){
    int no=i%2;
    int ne=(i+1)%2;
    for(int k=0;k<=N;k++){
      dp[ne][k+1][0]=min(dp[no][k][0],dp[no][k][1]+T[i]);
      dp[ne][k][1]=min(dp[no][k][0]+T[i],dp[no][k][1]);
      //      printf("%d %d\n",dp[ne][k+1][0]
      dp[no][k][0]=INF;
      dp[no][k][1]=INF;
    }
  }
  return min(dp[0][N/2][0],dp[0][N/2][1]);
}
int main(){
  scanf("%d",&N);
  for(int i=1;i<N;i++){
    scanf("%d",&T[i]);
  }
  printf("%d\n",solve());
}

Measured memory_bytes: 1384
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  set<int> d;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    d.insert(x);
  }
  cout << d.size() << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#define max 2000000

int h,A[max+1];

void	swap( int  *a , int  *b ){
	int	temp ;	/* テンポラリ-の変数（入れ物）を用意 */

	temp = *a ;	/* a 番地の中の数字を temp にコピ－する */

	*a = *b ;	/* a 番地の中に b 番地の数字をコピ－する */

	*b = temp ;	/* b 番地の中に temp の数字をコピ－する */
			/* これで a 番地 b 番地の中の数字が入れ替わります */
}

void maxHeapify(int i){
  int l,r,largest;
  l = 2*i;
  r = 2*i+1;

  if(l<=h&&A[l]>A[i])largest = l;
  else largest  = i;
  if(r<=h && A[r] > A[largest])largest = r;

if(largest != i){
  swap(&A[i],&A[largest]);
  maxHeapify(largest);
}
}


int main(){
int i;
  scanf("%d",&h);

  for(i=1;i<=h;i++){
    scanf("%d",&A[i]);
  }

  for(i=h/2;i>=1;i--){
    maxHeapify(i);
  }

  //printf("%d",A[1] );
  for(i=1;i<=h;i++){
    printf(" %d",A[i]);
  }
  printf("\n" );

  return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  set<int> st;
  int n; cin>>n;
  repi(i,0,n){
    int t;
    cin >>t;
    st.insert(t);
  }
  if(st.size()==n){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 9600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int n;
		int[] a =new int[53];
		Arrays.fill(a,0);
		Scanner scan = new Scanner(System.in);
		n=scan.nextInt();
		
		for(int i=1;i<=n;i++)
		{
			int su;
			String mrk;
			mrk=scan.next();
			su=scan.nextInt();
			if(mrk.equals("H"))
				su=su+13;
			if(mrk.equals("C"))
				su=su+26;
			if(mrk.equals("D"))
				su=su+39;
			a[su]=1;
		}
		for(int i=1;i<53;i++)
		{
			if(a[i]==1) 
				continue;
			if(i<=13)
				System.out.println("S "+i);
			if(13<i&&i<=26)
				System.out.println("H "+(i-13));
			if(26<i&&i<=39)
				System.out.println("C "+(i-26));
			if(39<i)
				System.out.println("D "+(i-39));
		}
		
	}
}

Measured memory_bytes: 26152
import sys
def dfs(n,c):
    if Ans[n] == -1:
        Ans[n] = c
        for m,w in Data[n]:
            if w % 2 == 0:
                dfs(m,c)
            else:
                dfs(m,1-c)
    elif Ans[n] == c:
        return
    else:
        return

sys.setrecursionlimit(100000)
N = int(input())
Data = []
Ans  = [-1] * N
for i in range(N):
    Data.append([])
for i in range(N-1):
    u,v,w = map(int,input().split())
    Data[u-1].append([v-1,w])
    Data[v-1].append([u-1,w])
dfs(0,0)

for a in Ans:
    print(a)

Measured memory_bytes: 85208
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
typedef unsigned int uint;
typedef long long ll;

int main() {
	ll  A, B,C,D;
	scanf("%lld%lld%lld%lld", &A, &B,&C,&D);
	ll divC, divD, divCD,bai;

	ll a = C;
	ll b = D;
	if (a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	b = (C*D) / b;
	//printf("%lld", b);
	
	divC = B / C - (A-1) / C;
	divD = B / D - (A-1) / D;
	divCD = B / b - (A-1) / b;



	printf("%lld", (B-A+1)-(divC + divD - divCD));

	
	



}


/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    vector<ll> a{8,7,6,5,4,3,2,1};
    PRINT(a[x/200-2]);
}


Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void foo(string S) {
  char current = S[25];
  set<char> st;
  st.insert(current);
  for (long i = 24; i >= 0; i--) {
    for (auto it: st) {
      if (it > S[i]) {
        cout << S.substr(0, i) << it << endl;
        return;
      }
    }
    st.insert(S[i]);
  }
  cout << -1 << endl;
}

void bar(string S) {
  cout << S;
  unordered_set<char> st;
  for (auto it: S) st.insert(it);
  for (char c = 'a'; c <= 'z'; c++) {
    if (st.count(c) == 0) {
      cout << c << endl;
      return;
    }
  }
}

void solve() {
  string S;
  cin >> S;
  if (S.size() == 26) foo(S);
  else bar(S);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;

long long a[110000], b[110000], c[110000];

int main()
{
    int i, j, n, k, s, lo, ans = 0;
    long long s1 = 0, s2 = 0;
    scanf("%d", &n);
    for (i = 1; i <= n; ++i) 
    {
    	scanf("%lld", &a[i]);
    	s1 += a[i];
      
    }
    for (i = 1; i <= n; ++i) 
    {
    	scanf("%lld", &b[i]);
    	s2 += b[i];
    }

    if (s2 > s1)
    {
    	printf("-1");
    	return 0;
    }


    for (i = 1; i <= n; ++i) c[i] = a[i] - b[i];

    lo = n;
    sort(c + 1, c + 1 + n);
    long long p = c[n];
	for (i = 1; i <= n; ++i)
	if (c[i] >= 0) break;
	else
	{
		if (c[lo] >= -c[i])
		{
			c[lo] += c[i];
			++ans;
		}
		else
		{
			c[i] += c[lo];
			--i;
			--lo;
		}
	}

	ans += (n - lo + 1);
	if (c[n] == p) --ans;
	printf("%d", ans);
	return 0;
    
}

Measured memory_bytes: 2560
n,x=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr)
for i in range(n):
  if x-arr[i]>=0:
    x-=arr[i]
  else:
    print(i)
    break
else:
  if x==0:
    print(n)
  else:
    print(n-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,i;
	string s;
	cin>>a>>b>>s;
	for(i=0;i<a;i++)
		if(s[i]<'0'||s[i]>'9')
		{
			cout<<"No"<<endl;
			return 0;
		}
	//i++;
	if(s[i]!='-')
	{
		cout<<"No"<<endl;
		return 0;
	}
	b+=i++;
	for(i=i;i<b;i++)
		if(s[i]<'0'||s[i]>'9')
		{
			cout<<"No"<<endl;
			return 0;
		}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int a, b, c;
  	cin >> a >> b >> c;
  	bool ok = (a == b && a != c) || (a == c && a != b) || (b == c && b != a);
  	if(ok) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long arr[200005];
map<long long,int> freqArr;
int main()
{
    int n;
    cin >> n;
    long long Sum = 0;
    for(int i = 1;i <= n;i++)
        scanf("%lld",&arr[i]),Sum += arr[i],freqArr[Sum]++;
    Sum = 0;
    long long ans = 0;
    for(int i = 1;i <= n;i++)
    {
        ans += freqArr[Sum];
        Sum += arr[i];
        freqArr[Sum]--;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 14336
S = input()
T = input()

S_list = []
T_list = []
alpha = "abcdefghijklmnopqrstuvwxyz"

for i in alpha:
    SS = S.count(i)
    TT = T.count(i)
    if SS > 0:
        S_list.append(SS)
    if TT > 0:
        T_list.append(TT)

if sorted(S_list) != sorted(T_list):
    print('No')
else:
    print('Yes')

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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll N, K;
  cin >> N >> K;

  if (N < K) {
    cout << 1 << endl;
    return 0;
  }

  ll c = 0;
  ll t = N;
  while (true) {
    t /= K;
    c++;

    if (t < K) {
      cout << c + 1 << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  ll ans = 0;
  int n = s.length();
  vector<int> a;
  for(auto p : s){
    a.push_back(p-'0');
  }
  bool extra = false;
  vector<ll> ex(n + 5, 1001001001);
  vector<ll> ju(n + 5, 1001001001);
  ex[0] = 1 + 1; //一枚渡してお釣りを一枚もらう
  ju[0] = 0;
  
  for (int i = 0; i < n; i++){
    //cout << a[i] << " ";
    ju[i + 1] = min(ju[i], ex[i]) + a[i];
    ex[i + 1] = min(ju[i] + 1 + (10 - a[i]), ex[i] + (10 - a[i]) - 1);
    /*
    if (a[i] >= 0 && a[i] <= 4 || a[i] == 5 && extra == false)
    {
      //小銭を出す
      ans += a[i];
      extra = false; //少額だったらお釣りとして戻してもらう
    }else{
      //多めに出す
      if(extra == true){
        ans += 10 - a[i] - 1; //上の桁の余りを活用
      }else{
        ans += 10 - a[i] + 1; //大きなお金+お釣り
      }
      extra = true;
    }
    */
  }
  //cout << ans << "\n";
  cout << min(ju[n], ex[n]) << "\n";
  return 0;
}

Measured memory_bytes: 21368
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}

int main(){
  int k;
  cin >> k;
  vector<ll> d[10];
  rep(i, 10){
    d[i].push_back(i);
    if(i!=0){
      k--;
      if(k==0){
        cout<< i<< endl;
        return 0;
      }
    }
  }
  ll digit=1;
  while(k!=0){
    vector<ll> nd[10];
    rep(i, 10){
      for(int j=-1;j<=1; j++){
        if(i+j<0 || i+j>=10)continue;
        int dsz=d[i+j].size();
        rep(l, dsz){
          nd[i].push_back(d[i+j][l]+i*modpow(10, digit));
          if(i!=0){
            k--;
            if(k==0){
              cout<< d[i+j][l]+i*modpow(10, digit)<< endl;
              return 0;
            }
          }
        }
      }
    }
    swap(nd, d);
    digit++;
  }

  return 0;
}


Measured memory_bytes: 4132
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define SQ(a) (a)*(a)you
#define f first
#define s second
#define int long long
#define PB push_back
#define MP make_pair
#define db long double
#define all(a) a.begin(), a.end()
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define cases int testcases;cin>>testcases; while(testcases--)



bool customsort(const pair<string,int> &a,const pair<string,int> &b)
{
 

      if(a.f!=b.f)
      {
         return a.f<b.f;
      }

      return a.s>b.s;
   
}
int32_t main()
{
  IOS
  


    

      int n;
      cin>>n;

      vector<pair<string,int>>v,v2;
      for(int i=0;i<n;i++)
      {

         string s;
         cin>>s;
         int x;
         cin>>x;
         v.PB(MP(s,x));
      } 

         v2=v;



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

          


         for(auto i:v)
         {
               int ans=0;

            for(auto j:v2)
            {  
                     ans++;
               if(j==i)
               {
                     cout<<ans<<endl;
               }
            }
         }

return 0;
}  


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

using namespace std;

typedef long long ll;

string n;

int main(){
    cin >> n;
    int c = n.size();
    int d = 0;
    for(auto i : n) d += i - '0';
    cout << max(d, (c - 1) * 9 + n[0] - '0' - 1);
}


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

int main(){
    int a,b,c;
    int max = 0;
    int res = 0;
    cin >> a >> b >> c;
    int array[] = {a,b,c};
    
    max = array[0];
    for(int x = 0;x <= 1;x++){
        if(max < array[x+1]){
            max = array[x+1];
        }else{
            
        }
    }
    
    for(int x = 0;x <= 2;x++){
        if(array[x] < max){
            res += array[x];
        }
    }
    
    if(res == max){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 610
#define ll long long
#define mo 1000000007
int n,K;
int to[N],c[N];
bool bz[N][N];
int f[N][N],g[N];
int main(){
	scanf("%d%d",&n,&K);
	for (int i=1;i<=K;++i){
		int a,b;
		scanf("%d%d",&a,&b);
		if (a>b) swap(a,b);
		to[a]=b,to[b]=a;
		for (int i=a+1;i<=b;++i)
			for (int j=b;j<=2*n;++j)
				bz[i][j]=1;
		for (int j=a;j<=b-1;++j)
			for (int i=1;i<=a;++i)
				bz[i][j]=1;
	}
	for (int i=1;i<=2*n;++i)
		c[i]=c[i-1]+(to[i]==0);
	g[0]=1;
	for (int i=2;i<=2*n;i+=2)
		g[i]=(ll)g[i-2]*(i-1)%mo;
	for (int l=2*n;l>=1;--l){
		for (int r=l+1;r<=2*n;r+=2){
			if (bz[l][r]) continue;
			ll s=0;
			for (int i=l+1;i<r;i+=2)
				(s+=(ll)f[l][i]*g[c[r]-c[i]])%=mo;
			f[l][r]=(g[c[r]-c[l-1]]-s+mo)%mo;
		}
	}
	ll ans=0;
	for (int i=1;i<=2*n;++i)
		for (int j=i+1;j<=2*n;j+=2)
			if (f[i][j])
			(ans+=(ll)f[i][j]*g[c[2*n]-(c[j]-c[i-1])])%=mo;
	printf("%lld\n",ans);
	return 0;
}














Measured memory_bytes: 3464
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  string s,t;cin>>s>>t;
  ll n=s.size(),m=t.size();
  res=INF;
  rep(i,0,n-m+1){
    ll cnt=0;
    rep(j,0,m)cnt+=s[i+j]!=t[j];
    chmin(res,cnt);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;


int main() {
	int n;
	cin >> n;
	map<int, int> m;
	
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		m[a]++;
	}

	int L1 = 0;
	int L2 = 0;

	for (auto it = m.begin(); it != m.end(); it++) {
		if (it->second >= 4) {
			L1 = L2 = it->first;
		}
		else if (it->second >= 2) {
			L2 = L1;
			L1 = it->first;
		}
	}
	long long s = 1LL * L1*L2;

	cout <<s << endl;


	
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
static const int MAX_N = -1, MAX_M = -1;
int n;
vector<tuple<string, int, int>> restraurant;
void solve()
{
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string name;
		int score;
		cin >> name >> score;
		restraurant.push_back(make_tuple(name, 100 - score, i));
	}
	sort(restraurant.begin(), restraurant.end());
	for (int i = 0; i < n; i++)
	{
		cout << get<2>(restraurant[i]) + 1 << endl;
	}
}


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

abc = [a,b,c]

def get_index(ch):
    if (ch == "A"):return 0
    elif (ch == "B"):return 1
    else:return 2

ans = ["Yes"]
S = [input() for _ in range(n)]

for i in range(n):
    s = S[i]
    s1 = get_index(s[0])
    s2 = get_index(s[1])
    
    if abc[s1] == 0 and abc[s2] == 0:
        ans[0] = "No"
    
    elif abc[s1] == 0 or abc[s2] == 0:
        if abc[s2] == 0:
            abc[s1] -= 1
            abc[s2] += 1
            ans.append(s[1])
        else:
            abc[s1] += 1
            abc[s2] -= 1
            ans.append(s[0])
    
    elif abc[s1] + abc[s2] == 2 and i != n-1:
        if S[i] != S[i+1]:
            next_s = S[i+1]
            next_s1 = get_index(next_s[0])
            next_s2 = get_index(next_s[1]) 
            if s1 == next_s1 or s1 == next_s2:
                abc[s1] += 1
                abc[s2] -= 1
                ans.append(s[0])
            else:
                abc[s1] -= 1
                abc[s2] += 1
                ans.append(s[1])
        else:
            abc[s1] += 1
            abc[s2] -= 1
            ans.append(s[0])
    
    elif abc[s1] == 1:
        abc[s1] += 1
        abc[s2] -= 1
        ans.append(s[0])

    else:
        abc[s1] -= 1
        abc[s2] += 1
        ans.append(s[1])

for a in ans:
    print(a)
    if a == "No":
        break
 

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

using namespace std;

int main(){
	string s;
	string t;
	cin>>s;
	cin>>t;
	
	int tot = 0;
	int len = s.length();
	for(int i=0;i<len;i++){
		if(s[i]!=t[i]) tot++;
	}
	cout<<tot<<endl;
} 

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int dp[2][256];
const int INF=1e9;
int N,M;
int val[20000],c[16];

inline int conv(int v){
    return max(min(v,255),0);
}

void solve(){
    fill_n(*dp,2*256,INF);
    dp[0][128]=0;
    int *prev=dp[0],*next=dp[1];

    for(int i=0;i<N;i++){
        for(int j=0;j<256;j++){
            if(prev[j]==INF)continue;
            for(int k=0;k<M;k++){
                int t=conv(j+c[k]);
                int v=(t-val[i])*(t-val[i]);

                next[t]=min(next[t],prev[j]+v);
            }
            prev[j]=INF;
        }
        swap(prev,next);
    }

    printf("%d\n",*min_element(dp[N&1],dp[N&1]+256));

}

int main(){
    while(scanf("%d%d",&N,&M),N||M){
        for(int i=0;i<M;i++)scanf("%d",&c[i]);
        for(int i=0;i<N;i++)scanf("%d",&val[i]);
        solve();
    }
    return 0;
}

Measured memory_bytes: 1268
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(){

int i,n;
double score[1000],ave=0,sigma;

while(1){

ave=sigma=0;
cin>>n;
if(n==0)return 0;

for(i=0; i<n; i++){
cin>>score[i];
ave+=score[i];
}

ave/=(double)n;

for(i=0; i<n; i++)sigma+=(double)(score[i]-ave)*(score[i]-ave);

printf("%.8f\n",sqrt(sigma/(double)n));

}

}

Measured memory_bytes: 1252
#include <iostream>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)

int H, W;

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

    while (1) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break ;
        }
        REP(i, H) {
            REP(j, W) {
                if (i == 0 || j == 0 || i == H - 1 || j == W - 1) {
                cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << '\n';
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 3140
#include <stdio.h>

#define USER_NUM 100
#define DATA_NUM 100

#define NODE_NUM (USER_NUM + DATA_NUM)

int nyaaan[NODE_NUM][NODE_NUM];

int main(void) {
	int N;
	int i, j, k;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < NODE_NUM; i++) {
		for (j = 0; j < NODE_NUM; j++) {
			nyaaan[i][j] = NODE_NUM * 10;
		}
		nyaaan[i][i] = 0;
	}
	for (i = 0; i < N; i++) {
		int u, d;
		char lock[16];
		if (scanf("%d%s%d", &u, lock, &d) != 3) return 1;
		u--;
		d--;
		if (lock[0] == 'l') {
			/* lock : data -> user */
			nyaaan[d + USER_NUM][u] = -1;
		} else {
			/* wait : user -> data */
			nyaaan[u][d + USER_NUM] = -1;
		}
	}
	for (k = 0; k < NODE_NUM; k++) {
		for (i = 0; i < NODE_NUM; i++) {
			for (j = 0; j < NODE_NUM; j++) {
				if (nyaaan[i][j] > nyaaan[i][k] + nyaaan[k][j]) {
					nyaaan[i][j] = nyaaan[i][k] + nyaaan[k][j];
				}
			}
		}
	}
	for (i = 0; i < NODE_NUM; i++) {
		if (nyaaan[i][i] < 0) {
			puts("1");
			return 0;
		}
	}
	puts("0");
	return 0;
}

Measured memory_bytes: 740
#include <stdio.h>
#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 VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<min(b/a, c)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int (i)=int(a);i<=int (b);i++)
#define ff(i,a,b) for(int (i)=int(a);i<int (b);i++)
#define F(i,a,b) for(int (i)=int (a);i>=int (b);i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vt vector
#define ll long long
#define all(x) x.begin(),x.end()
#define lower(p,x) lower_bound(all(p),x)
#define upper(p,x) upper_bound(all(p),x)
#define ms(a,x) memset(a,x,sizeof a)
typedef pair<int,int> ii;
const double pi=acos(-1.0);
const double eps=1e-5;
const int INF=1<<30,mod=1e9,N=1e6+6;
/*int power(int a,int b,int p){
	int ans=1%p;
	for(;b;b>>1){
		if(b&1)  ans=(ll)ans*a%p;
		else a=(ll)a*a%p;
	}
	return ans;
}*/
string s;
ll sum=0;
int main(){
	cin>>s;int k=s.size();
	for(int i=0;i<1<<(k-1);i++){
		string S="";
		ff(j,0,k){
			S+=s[j];
			if((i>>j)%2==0){
				sum+=atoll(S.c_str());
				S="";
			}
		}
	}
	cout<<sum;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int K = sc.nextInt();
	int X = sc.nextInt();
	if((K * 500) >= X) System.out.print("Yes");
	else System.out.print("No");
    }
}


Measured memory_bytes: 25300
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef unsigned long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<vector<ll>> mat;

const ll md = 1e9+7;

const mat id = {{1,0,0}, {0,1,0}, {0,0,1}};
const mat M  = {{1,0,0}, {1,1,0}, {1,2,1}};
const mat N  = {{2,2,1}, {1,1,0}, {1,2,1}};


mat operator*(mat a, mat b){
	mat res(3, vector<ll>(3));
	rep(i,0,3) rep(j,0,3) rep(k,0,3)
		res[i][j] += a[i][k]*b[k][j];
	trav(v, res) trav(x, v) x %= md;
	return res;
}

mat pow(mat a, int e){
	mat res = id;
	for(; e; e /= 2){
		if(e&1) res = res * a;
		a = a*a;
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n,m;
	cin >> n >> m;
	mat cur = id;
/*
	vector<bool> inx(n+1);
	rep(_,0,m){
		int x;
		cin >> x;
		inx[x] = 1;
	}

	rep(i,1,n+1){
		if(inx[i]) cur = cur * M;
		else cur = cur * N;
	}*/

	int pr = 0;
	rep(_,0,m){
		int x;
		cin >> x;
		cur = pow(N, x-pr-1) * cur;
		pr = x;
		cur = M * cur;
	}
	cur = pow(N, n-pr) * cur;

	cout << cur[2][0] << endl;
}

Measured memory_bytes: 384
// ConsoleApplication7.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[])
{
	int i, j;
	int n, m;	// 1 <= n, m <= 100
	int a[101][101];
	int b[101];
	int answer[101];

	memset(answer, 0, sizeof(answer));

	cin >> n >> m;

	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			cin >> a[i][j];
		}
	}
	for (i = 1; i <= m; i++) {
		cin >> b[i];
	}

	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			answer[i] += a[i][j] * b[j];
		}
	}

	for (i = 1; i <= n; i++) {
		cout << answer[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3124
#include "bits/stdc++.h"

using namespace std;

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

	int turn = 0;

	while (true)
	{
		char tmp = s[turn][0];
		if (s[turn][0] == '\0') break;
		s[turn].erase(0, 1);

		switch (tmp)
		{
		case 'a':
			turn = 0;
			break;
		case 'b':
			turn = 1;
			break;
		case 'c':
			turn = 2;
			break;
		default:
			break;
		}
	}

	switch (turn)
	{
	case 0:
		cout << "A" << endl;
		break;
	case 1:
		cout << "B" << endl;
		break;
	case 2:
		cout << "C" << endl;
		break;
	default:
		break;
	}

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s []byte
	fmt.Scan(&s)
	n := len(s)
	k, k2, k3 := true, true, true
	for i := 0; i < n; i++ {
		if s[i] != s[n-1-i] {
			k = false
		}
	}
	for i := 0; i < (n-1)/2; i++ {
		if s[i] != s[(n-1)/2-1-i] {
			k2 = false
		}
	}
	for i := (n+3)/2-1; i < n; i++ {
		if s[i] != s[n-1-i] {
			k3 = false
		}
	}
	if k && k2 && k3 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp93 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
            decimal X = st[0];
            decimal Y = st[1];

            if (X == Y) {
                Console.WriteLine(1);
                return;
            }

            int cnt = 0;

            while (true) {
                if (X <= Y) {
                    X *= 2;
                    cnt++;
                } else {
                    break;
                }
            }
            Console.WriteLine(cnt);

        }
    }
}


Measured memory_bytes: 13396
macro_rules! get {
    (Vec<t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (A, B) = get!(i64, i64);

    if A + B >= 10 {
        println!("error");
    } else {
        println!("{}", A + B);
    }
}

Measured memory_bytes: 4352
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args){

 		int[] left = new int[1000];
 		int[] right = new int[1000];
 		char[] sign = new char[1000];
 		
 		String buffer;
		Scanner scan = new Scanner(System.in);

		int i = 0;
		while(true){

			left[i] = scan.nextInt();
			buffer = scan.next();
			right[i] = scan.nextInt();
			sign[i] = buffer.charAt(0);
			if(sign[i] == '?'){
				break;
			}
			i++;
			
		}

		i = 0;
		
		while(sign[i] != '?'){

			switch(sign[i]){

				case '+':
					System.out.println(left[i]+right[i]);
					break;
				case '-':
					System.out.println(left[i]-right[i]);
					break;
				case '*':
					System.out.println(left[i]*right[i]);
					break;
				case '/':

					System.out.println(left[i]/right[i]);
					break;
			}
			i++;


		}



	}
}

Measured memory_bytes: 26404
# -*- coding: utf-8 -*-

S = list(input())

answer = 1000

for i in range(len(S)-2):
	a = int(S[i])
	b = int(S[i+1])
	c = int(S[i+2])
	temp_x = (a*100) + (b*10) + c

	diff_x = abs(753 - temp_x)

	if answer > diff_x:
		answer = diff_x

print(answer)

Measured memory_bytes: 3064
/**

     .=     ,        =.
  _  _   /'/    )\,/,/(_   \ \
   `//-.|  (  ,\\)\//\)\/_  ) |
   //___\   `\\\/\\/\/\\///'  /
,-"~`-._ `"--'_   `"""`  _ \`'"~-,_
\       `-.  '_`.      .'_` \ ,-"~`/
 `.__.-'`/   (-\        /-) |-.__,'
   ||   |     \O)  /^\ (O/  | .        <-  BESSIE THE COW / BESITE SOV
   `\\  |         /   `\    /
     \\  \       /      `\ /
      `\\ `-.  /' .---.--.\
        `\\/`~(, '()      ('
         /(O) \\   _,.-.,_)
        //  \\ `\'`      /
       / |  ||   `""""~"`
     /'  |__||
           `o

*/


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

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

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

using ll = long long;

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


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


bool DEBUG = 0;
#define debug(x) if (DEBUG) {cerr << #x << " = " << x << "\n";}
#define debug_vec(x) if (DEBUG) {cerr << #x << " = {"; for(auto a : x) cerr << a << ","; cerr << "}" << endl;}

//#define int ll

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;


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

bool us[7];
main() {
    file("sort");
    ios;
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    int ptr = 0;
    for (int i = 0; i < n; ++i) cout << a[i] << b[i];
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**

*/


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

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

int parse(string &s, int &p){
  if(s[p]=='('){
    p++;
    int x = parse(s,p);
    char op = s[p++];
    int y = parse(s,p);
    p++;
    if(op == '^'){
      return x^y;
    }else{
      return x&y;
    }
  }else if(s[p]=='-'){
    p++;
    int x = parse(s,p);
    return ~x&65535;
  }else{
    p++;
    if(s[p-1]=='0')return 0x0000;
    if(s[p-1]=='1')return 0xffff;
    if(s[p-1]=='a')return 0xaaaa;
    if(s[p-1]=='b')return 0xcccc;
    if(s[p-1]=='c')return 0xf0f0;
    return 0xff00;
  }
}

int dp[125252];

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
vpi uni;

void dfs2(vpi v){
  if(v.size() == 1){
    int m = v[0].first;
    dp[m] = min(dp[m],v[0].second);
    dp[~m&65535] = min(dp[~m&65535],v[0].second + 1);
  }else{
    REP(q,4){
      REP(i,v.size()-1){
        vpi w;
        REP(j,v.size())if(i==j){
          pii a = v[j];
          pii b = v[j+1];
          j++;
          pii c;
          if(q%2==0){
            c = pii(a.first & b.first, a.second + b.second + 3);
          }else{
            c = pii(a.first ^ b.first, a.second + b.second + 3);
          }
          if(q>=2){
            c = pii(~c.first & 65535, c.second + 1);
          }
          w.push_back(c);
        }else{
          w.push_back(v[j]);
        }
        dfs2(w);
      }
    }
  }
}

void dfs(int k,vpi v){
  if(k==0){
    dfs2(v);
    return;

  }
  for(pii P : uni){
    vpi w = v;
    w.push_back(P);
    dfs(k-1,w);
  }
}

int main(){
  uni.push_back(pii(0x0000,1));
  uni.push_back(pii(0xffff,1));
  uni.push_back(pii(0xaaaa,1));
  uni.push_back(pii(0xcccc,1));
  uni.push_back(pii(0xf0f0,1));
  uni.push_back(pii(0xff00,1));
  uni.push_back(pii(~0xaaaa&65535,2));
  uni.push_back(pii(~0xcccc&65535,2));
  uni.push_back(pii(~0xf0f0&65535,2));
  uni.push_back(pii(~0xff00&65535,2));

  REP(i,125252)dp[i] = 83025;

  REP(i,10){
    dp[uni[i].first] = uni[i].second;
  }

  REP(k,5)if(k>=2){
    dfs(k,vpi(0));
    // cerr << k << endl;
  }

  while(true){
    string s;
    cin>>s;
    if(s[0] == '.')break;
    int p = 0;
    int msk = parse(s,p);
    if(false){
      int tmp = msk;
      REP(_,4){
        cout << (tmp%16) << " ";
        tmp /= 16;
      }
      cout << endl;
    }
    int ans = s.size();
    ans = min(ans, dp[msk]);
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  
  string s;
  cin >> s;
  
  if ( s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
  
  
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll gcd( ll a, ll b )
{
  ll t;
  if( a < b ){ t = a; a = b; b = t; }
  while( ( t = a % b ) != 0 ){ a = b; b = t; }
  return b;
}
int main( void )
{
  ios::sync_with_stdio(false);
  ll N, X;
  cin >> N >> X;
  ll g = gcd( N, X );
  N /= g;
  ll ret = (N-1)*3*g;
  cout << ret << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
String s=scan.next();
String[] ss=s.split("");
  
if(!(ss[0].equals(ss[1]))&&ss[1].equals(ss[2])){
  System.out.println("Yes");
}else if(ss[0].equals(ss[1])&&!(ss[1].equals(ss[2]))){
  System.out.println("Yes");
}else if(!(ss[0].equals(ss[1]))&&!(ss[1].equals(ss[2]))){
  System.out.println("Yes");
}else{
  System.out.println("No");
}
  

}
}

Measured memory_bytes: 23508
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;
const int MOD = 1e9 + 7;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<long long> dp(k + 1, 0);
    vector<long long> accum(k + 2, 0);
    dp[0] = 1;

    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k + 1; j++) {
            accum[j] = (accum[j - 1] + dp[j - 1]) % MOD;
        }
        for (int j = k; j >= 0; j--) {
            int lb = max(0, j - a[i]);
            dp[j] = (accum[j + 1] - accum[lb] + MOD) % MOD;
        }
    }
    cout << dp[k] << endl;
    return 0;
}

Measured memory_bytes: 1792
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
X = list(map(int,input().split()))
 
l  = sorted(X)[N//2-1]
r = sorted(X)[N//2]

for i in range(N):
    if X[i] <= l:
        print(r)
    else:
        print(l)

Measured memory_bytes: 25476
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
using namespace std;

int main(void){
    int n;
    cin>>n;
    vector<int> a(n+2);
    a[0]=0;a[n+1]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int sum=0;
    for(int i=0;i<=n;i++)sum+=abs(a[i]-a[i+1]);
    for(int i=1;i<=n;i++){
        cout<<sum-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
    }
    return 0;
}


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

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3, y3, x4, y4;
  x3 = x2 + -1*(y2-y1);
  y3 = y2 + (x2-x1);
  x4 = x3 + -1*(x2-x1);
  y4 = y3 + -1*(y2-y1);
  cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
  return 0;
}


Measured memory_bytes: 256
/* Copyright 2016 AcrossTheSky */
#include <iostream>
#include <cstdio>
#include <utility>
#include <cassert>
#include <map>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <sstream>
#include <fstream>
#include <string>
#include <cmath>
#include <algorithm>
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define PER(i, a, b) for (int i = (a); i >= (b); --i)
#define RVC(i, c) fot (int i = 0; i < (c).size(); ++i)
#define RED(k, u) for (int k = head[(u)]; k; k = edge[k].next)
#define SQR(k) (k) * (k)
#define lowbit(x) ((x) & (-(x)))
#define CL(x, v) memset(x, v, sizeof x)
#define MP std::make_pair
#define PB push_back
#define FR first
#define SC second
#define rank rankk
#define next nextt
#define link linkk
#define index indexx
#define abs(x) ((x) > 0 ? (x) : (-(x)))
using namespace std;
typedef long long LL; typedef pair<int, int> PII;

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

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

template<class T> inline
void read(T *a) {
    char c;
    while (isspace(c = getchar())) {}
    bool flag = 0;
    if (c == '-') flag = 1, *a = 0;
    else
        *a = c - 48;
    while (isdigit(c = getchar())) *a = *a * 10 + c - 48;
    if (flag) *a = -*a;
}

const int mo = 1000000007;
template<class T>
T pow(T a, T b, int c = mo) {
    T res = 1;
    for (T i = 1; i <= b; i <<= 1, a = 1LL * a * a % c) if (b & i) res = 1LL * res * a % c;
    return res;
}
/*======================= TEMPLATE =======================*/
string s;
int f[1000000];
int main() {
    cin >> s;
    int n = s.size();
    f[0] = 1;
    REP(i, 5, n) {
        if (s.substr(i - 5, 5) == "dream") f[i] |= f[i - 5];
        if (s.substr(i - 5, 5) == "erase") f[i] |= f[i - 5];
        if (i >= 7 && s.substr(i - 7, 7) == "dreamer") f[i] |= f[i - 7];
        if (i >= 6 && s.substr(i - 6, 6) == "eraser") f[i] |= f[i - 6];
    }
    if (f[n]) puts("YES");
    else puts("NO");
    return 0;
}


Measured memory_bytes: 1024