akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
ios_base::sync_with_stdio(false); \
cin.tie(0);                       \
cout.tie(0);
#define test  \
int t;    \
cin >> t; \
while (t--)
#define debug(a)          \
    cerr << #a << ": ";   \
for (auto i : a)      \
    cerr << i << " "; \
cerr << '\n';
#define trace(a) cerr << #a << ": " << a << "\n"
#define print(ar, n)            \
for (int u = 0; u < n; u++) \
{                           \
    cout << ar[u] << " ";   \
}                           \
cout << endl;
#define int long long
#define M 1000000007
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
signed main()
{
	rootdada;
// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// // 	freopen("error.txt", "w", stderr);
// #endif
	int n;
	cin >> n;
	vi l(n);
	rep(i, 0, n) cin >> l[i];
	sort(all(l));
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			for (int k = j + 1; k < n; k++)
			{
				if (l[i] != l[j] && l[j] != l[k])
				{
					int c = 0;
					if (l[i] + l[j] > l[k])
						c++;
					if (l[j] + l[k] > l[i])
						c++;
					if (l[i] + l[k] > l[j])
						c++;
					if (c == 3)
						ans++;
				}
			}
		}
	}
	cout << ans << endl;

}


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

int main(){
  string s;
  cin >> s;
  
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3624
def resolve():
    import sys
    input = sys.stdin.readline
    
    N, K = map(int, input().split())

    def get_trynum(X, K):
        count = 0
        while X < K:
            X *= 2
            count += 1
        return count

    win_rate_total = 0
    for i in range(1, N+1):
        try_num = get_trynum(i, K)
        win_rate = 0.5 ** try_num 
        win_rate_total += win_rate * (1/N)
    
    print(win_rate_total)

if __name__ == "__main__":
    resolve()

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

typedef long long LL;

LL A, B, C,MIN,MAX,MID,ans;
int main()
{
	ios::sync_with_stdio(false);
	cin >> A >> B >> C;
	MIN = min(A, min(B, C));
	MAX = max(A, max(B, C));
	MID = A + B + C - MIN - MAX;
	int cnt = 0; 
	if (A % 2 == 0) cnt++;
	if (B % 2 == 0) cnt++;
	if (C % 2 == 0) cnt++;
	if (cnt >= 1) ans = 0;
	else {
		ans = MID * MIN;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def check(mlist, s):
    if len(mlist) == 13:
        return 0
    else:
        lack = []
        for i in range(1, 14):
            if not i in mlist:
                lack.append(i)
                    
        #print(lack)
        for j in lack:
            print("{} {}".format(s, j))
        return 0


n = int(input())
Slist = []
Hlist = []
Clist = []
Dlist = []

for i in range(n):
    mark, num = input().split()
    num = int(num)

    if mark == 'S':
        Slist.append(num)
    elif mark == 'H':
        Hlist.append(num)
    elif mark == 'C':
        Clist.append(num)
    else:
        Dlist.append(num)
        
Slist.sort()
Hlist.sort()
Clist.sort()
Dlist.sort()
    
check(Slist, 'S')
check(Hlist, 'H')
check(Clist, 'C')
check(Dlist, 'D')


Measured memory_bytes: 5600
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next(),t;
		int count=0,max=0;
		for(int i=0;i<s.length();i++) {
			if(i%2==0)t="0";
			else t="1";
			if(!s.substring(i, i+1).equals(t))count++;
		}
		max=count;
		count=0;
		for(int i=0;i<s.length();i++) {
			if(i%2==0)t="1";
			else t="0";
			if(!s.substring(i, i+1).equals(t))count++;
		}
		System.out.println((int)Math.min(max, count));
	}
}



Measured memory_bytes: 34288
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void){

  int N,i,v,j,b;
  int a[100]={};

  scanf("%d",&N);

  for(i=0;i<N;i++){
   scanf("%d",&a[i]);
  } 

  for(i=0;i<N;i++){
    v=a[i];
    j=i-1;

    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
      a[j+1]=v;
    }  
    for(b=0;b<N;b++){

    printf("%d",a[b]);

    if(b!=N-1)
      printf(" ");

    }
    	printf("\n");
    }


  }
  

Measured memory_bytes: 1748
#include<bits/stdc++.h>
using namespace std;
long long int n;
int main()
{
    cin>>n;
    for(int i=sqrt(n);i>=1;i--)
    {
        if(n%i==0)
		{
            int t=i,l=n/i,s=1;
            while(l>=10)
			{
                s++;
                l/=10;
            }
	        cout<<s;
	        return 0;
    	}
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int x[100006];
int kj[100006];
int c[100006];

int modpow(int a, int x, int mod) {
	int res = 1;
	while (x) {
		if (x & 1)res = res*a%mod;
		a = a*a%mod;
		x >>= 1;
	}
	return res;
}

signed main() {
	int n; cin >> n;
	rep(i, n)cin >> x[i];
	kj[0] = 1;
	rep(i, n + 1)kj[i + 1] = (kj[i] * (i + 1)) % mod;
	c[0] = kj[n-1];
	rep(i, n - 2) {
		c[i + 1] = c[i] + kj[n - 1] * modpow((i + 2), mod - 2, mod) % mod;
		c[i + 1] %= mod;
	}
	int ans = 0;
	rep(i, n - 1) {
		ans += c[i] * (x[i + 1] - x[i]) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    ll n, k; cin >> n >> k;
    cout << min(n%k, k-(n%k)) << ln;
}

Measured memory_bytes: 3620
public class Main {

  private static void solve() {
    int h = ni();
    int w = ni();

    char[][] map = new char[h][w];
    for (int i = 0; i < h; i++) {
      map[i] = ns();
    }
    int AL = 26;
    int[] count = new int[AL];
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        map[i][j] -= 'a';
        count[map[i][j]]++;
      }
    }

    int[] modc = new int[4];
    for (int i = 0; i < AL; i++) {
      modc[count[i] % 4]++;
    }
    modc[2] += modc[3];
    modc[1] += modc[3];
    modc[3] = 0;

    if (modc[1] == 1 && (h % 2 == 0 || w % 2 == 0) || modc[1] > 1) {
      out.println("No");
    } else if (modc[2] > (h % 2 == 1 ? w / 2 : 0) + (w % 2 == 1 ? h / 2 : 0)) {
      out.println("No");
    } else {
      out.println("Yes");
    }

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

int main(){
  string s;
  cin >> s;
  
  int cnt=0;
  int i=0;
  int j = s.size() - 1;
  while(i <= j){
    if(s[i] != s[j]){
      cnt++;
    }
    i++;
    j--;
  }
  
  cout << cnt;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		if (sc.nextInt() + sc.nextInt() + sc.nextInt() <= 21) {
			System.out.println("win");
		} else {
			System.out.println("bust");
		}
	}
}


Measured memory_bytes: 21716
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0 
#ループカウンタ
counter =0

for i in range(0,N):
    #まずはその料理の満足度を足す
    ans += B[A[i]-1]
    #食べた料理が連番だった場合Cの値がプラスされる
    if((counter >=1) and (A[i]-A[i-1]==1)):
        #処理(C[A[i-1]-1]を足す処理）
        ans += C[A[i-1]-1]
    counter +=1

print(ans)

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

string nextstr(string s){
	string ans;
	for(auto it=s.end()-1; it>=s.begin(); it--){
		if(it==s.begin()){
			ans += *(it)+1;
			for(int i=1; i<s.size(); i++){
				ans += max<char>('0', ans.at(i-1)-1);
			}
			return ans;
		}
		else{
			if(*(it-1)+1==*it) continue;
			if(*it=='9') continue;
			else{
				for(auto it2=s.begin(); it2<it; it2++) ans += *it2;
				ans += *(it)+1;
				for(int i=it-s.begin()+1; i<s.size(); i++){
					ans += max<char>('0', ans.at(i-1)-1);
				}
				return ans;
			}
		}
	}
}

int main() {
	
	int k; cin>>k;
	vector<string> ans((int)1e5+1);
	for(int i=1; i<=9; i++){
		ans.at(i) = to_string(i);
	}
	for(int i=10; i<1e5+1; i++){
		char c{'9'};
		for(auto j:ans.at(i-1)) c = min(c, j);
		if(c=='9') {
			ans.at(i)='1';
			ans.at(i)+= string(ans.at(i-1).size(),'0');
		}
		else ans.at(i) = nextstr(ans.at(i-1));
	}
	cout << ans.at(k) << endl;
	
}

Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define p pair<int,int>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> graph(n);
    vector<int> count(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
        count[a]++;
        count[b]++;
    }

    vector<int> c(n);
    for (int i = 0; i < n; i++)cin >> c[i];
    sort(c.begin(), c.end());

    priority_queue<p, vector<p >, greater<>> que;
    for (int i = 0; i < n; i++)que.push(p(count[i], i));
    vector<bool> used(n);
    vector<int> v(n);

    for (int i = 0; i < n; i++) {
        p now;
        do {
            now = que.top();
            que.pop();
        } while (used[now.second]);

        int nowv = now.second;
        used[nowv] = true;
        v[nowv] = c[i];

        for (auto next:graph[nowv]) {
            count[next]--;
            que.push(p(count[next], next));
        }
    }


    long long ret = 0;
    for (int i = 0; i < n; i++) {
        for (auto x:graph[i])
            ret += min(v[i], v[x]);
    }
    cout << ret / 2 << endl;

    for (int i = 0; i < n; i++) {
        if (i > 0)cout << " ";
        cout << v[i];
    }
    cout << endl;
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n)
    {
        string s;
        cin >> s;
        sort(ALL(s));
        mp[s]++;
    }

    ll sum = 0;

    for (auto p : mp)
    {
        ll i = p.second;
        sum += i * (i - 1) / 2;
    }

    OP(sum)

    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <utility>
#include <unordered_set>
#include <vector>
#include <string>

void add_item(std::unordered_set<int>& current, std::unordered_set<int>& next, int x){
  for(auto&& it: current){
    next.insert(it);
    next.insert(it+x);
  }
  std::swap(current, next);
  next.clear();
}

int main(){
  std::string S;
  std::cin >> S;
  int X,Y;
  std::cin >> X >> Y;

  bool init = true;
  int length = 0;
  bool xy = true;
  std::vector<int> x_arr, y_arr;
  int x_total = 0, y_total = 0;
  S = S+"T";
  for(int i = 0; i < S.size(); i++){
    if(S[i] == 'F'){
      length++;
    }else{
      if(init){
        init = false;
        X -= length;
        length = 0;
        xy = !xy;
      }else if(xy){
        if(length > 0) x_arr.push_back(2*length);
        x_total -= length;
        length = 0;
        xy = !xy;
      }else{
        if(length > 0) y_arr.push_back(2*length);
        y_total -= length;
        length = 0;
        xy = !xy;
      }
    }
  }

  std::unordered_set<int> current, next;
  current.insert(x_total);
  for(auto&& it: x_arr) add_item(current, next, it);
  if(current.count(X) == 0){
    std::cout << "No" << std::endl;
    return 0;
  }
  current.clear();
  current.insert(y_total);
  for(auto&& it: y_arr) add_item(current, next, it);
  if(current.count(Y) == 0){
    std::cout << "No" << std::endl;
    return 0;
  }
  std::cout << "Yes" << std::endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    string a(100000, 0);
    string b(100000, 0);
    int counta = 0;
    int countb = 0;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++) {
        if(i % 2 == 0) {
            a[i] = '0';
            b[i] = '1';
        } else {
            a[i] = '1';
            b[i] = '0';
        }
    }

    for(int i = 0; i < n; i++) {
        if(a[i] != s[i])
            counta++;
        if(b[i] != s[i])
            countb++;
    }
    if(counta > countb)
        cout << countb<<endl;
    else
        cout << counta<<endl;

    return 0;
}

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

int coin_num[4], tmp_coin_num[4];
int coins[4] = {10, 50, 100, 500};

void calc_change(int res) {
    for (int i = 3; i >= 0; i--) {
        while (res >= coins[i]) {
            res -= coins[i];
            tmp_coin_num[i]++;
        }
    }
}

int main(void) {
    int total;
    bool first = true;
    while (cin >> total, total) {
        if (!first) cout << endl;
        first = false;

        // 0: 10yen, 1: 50yen, 2: 100yen, 3: 500yen
        for (int i = 0; i < 4; i++) cin >> coin_num[i];

        int pay = 10*coin_num[0] + 50*coin_num[1] + 100*coin_num[2] + 500*coin_num[3];
        for (int i = 0; i < 4; i++) tmp_coin_num[i] = 0;
        calc_change(pay-total); // ?????£???????¨????
        for (int i = 0; i < 4; i++) coin_num[i] -= tmp_coin_num[i];

        for (int i = 0; i < 4; i++) {
            if (coin_num[i] > 0) cout << coins[i] << " " << coin_num[i] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	vector<int> d(3);
	cin >> d[0] >> d[1] >> d[2];
	sort(d.begin(), d.end());
	cout << d[0] + d[1] << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <string.h>
#include <map>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#define INF 1000000
#define MAX 500000
#define pb push_back
#define mp make_pair
#define UNVISITED 0
using namespace std;
typedef long long int ll;
typedef vector <ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
int main()
{
//  freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
 ll n,m,a,b;
 cin>>n>>m;
 vector<ii> v1,v2;
 for(ll i=0;i<n;i++)
 {
  cin>>a>>b;
  v2.pb(ii(a,b));
 }
 for(ll i=0;i<m;i++)
 {
  cin>>a>>b;
  v1.pb(ii(a,b));
 }
 for(ll i=0;i<n;i++)
 {
  ii qq=v2[i];
  a=qq.first;
  b=qq.second;
  //cout<<a<<" "<<b<<endl;
  //cin>>a>>b;
  ll min=100000000000,ind;
  for(ll j=0;j<v1.size();j++)
  {
    ii pp=v1[j];
   // cout<<pp.first<<" "<<pp.second<<endl;
    if(abs(pp.first-a)+abs(pp.second-b)<min)
    {
      min=abs(pp.first-a)+abs(pp.second-b);
      ind=j;
    }
    
  }
  for(ll j=0;j<v1.size();j++)
  {
    ii pp=v1[j];
   // cout<<pp.first<<" "<<pp.second<<endl;
    if(abs(pp.first-a)+abs(pp.second-b)==min)
    {
      min=abs(pp.first-a)+abs(pp.second-b);
      ind=j;
      break;
    }
    
  }
  cout<<ind+1<<endl;
 }
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>s;
    rep(i,Size(s)){
        if(i%2==0){
            if(s[i]=='0')tmp++;
            else tmpp++;
        }
        else{
            if(s[i]=='0')tmpp++;
            else tmp++;
        }
    }
    ans=min(tmp,tmpp);
    Cout(ans);
    return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;
public class Main{
   public static void main(String[]args){
      Scanner sc = new Scanner(System.in);
      int nh = sc.nextInt();
      String n = Integer.toString(nh);
      String a = n.substring(0,1);
      String b = n.substring(n.length()-1);
      int x=Integer.parseInt(a);
      int y =Integer.parseInt(b);
      if(x ==y){
         System.out.println("Yes");
      }else{
         System.out.println("No");
      }
      
   }  
}

Measured memory_bytes: 23764
from itertools import accumulate, count

n, m, k = map(int, input().split())

"""
3 5 8
# # # 
 # # 
# # # 

###  
   ##
###

###
###
   ##  
"""

for i in range(n+1):
    for j in range(m+1):
        if j * (n - i) + i * (m - j) == k:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3060
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<int,int>mp;
set<int> s;

int main()
{
    fast;
   int a;
   cin>>a;
   int c=1;
   for(int i=2;i<=a;i++)
   {
       if(i%2) c++;
   }
   double d = (c*1.0/a*1.0);
   printf("%.6lf\n",d);
    return 0;

}






Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String args[]) {

        int[] a = new int[6];
        for (int i=0; i < 6; i++)
            a[i] = sc.nextInt();

        System.out.println(a[5] >= a[4] - a[0] ? "Yay!" : ":(");

    }

}


Measured memory_bytes: 22736
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s:chars
    }
    let mut ans = "YYMM";
    let a1 = (s[0] as i32 - 48)*10 + (s[1] as i32 - 48);
    let a2 = (s[2] as i32 - 48)*10 + (s[3] as i32 - 48);
    if (a1>12 || a1==0)&& (a2 > 12 || a2==0){
        ans = "NA";
    }else if a1 > 12 && a2 <=12 && a2 >=1 {
        ans = "YYMM";
    }else if a1 <= 12 && a1 >=1 && a2 > 12{
        ans = "MMYY";
    }else if a1 <= 12 && a1 >=1 && a2 <= 12 && a2 >= 1{
        ans = "AMBIGUOUS";
    }else if a1==0 && a2 <= 12 && a2 >= 1 {
        ans = "YYMM";
    }else{
        ans = "MMYY";
    }
    println!("{}", ans);
}

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

using namespace std;

#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define inf			1e12
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

	int n;
	cin >> n;

	vector<int> v(n);

	for (int i = 0 ; i < n; i++)
		cin >> v[i];

	int yen = 1000, stocks = 0, buy;
	int i, j;

	for ( i = 0; i < n - 1; i++) {
		if (v[i + 1] < v[i])
			continue;

		for (j = i + 1; j < n; j++) {
			if (v[j] < v[j - 1]) {
				break;
			}
		}

		j--;
		stocks += yen / v[i];
		yen -= (yen / v[i]) * v[i];
		yen += stocks * v[j];
		stocks = 0;
		i = j;

	}

	cout << yen << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define INF 1e9+5
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define forn(i,a,b) for(ll i=a;i<(ll)b;i++)
#define ff first
#define ss second
int check(string s)
{
	int n=s.length();
	for(int i=0;i<n/2;i++)
	{
		if(s[i]!=s[n-i-1])
			return 0;
	}
	return 1;
}
int32_t main()
{
	IOS;
	string str;
	cin>>str;
	int ans=0;
	ans+=check(str);
	string s1="";
	int n1=(int)str.length();
	for(int i=0;i<n1/2;i++)
		s1+=str[i];
	// cout<<s1<<"\n";
	ans+=check(s1);
	s1="";
	for(int i=n1/2+1;i<n1;i++)
		s1+=str[i];
	// cout<<s1<<"\n";
	ans+=check(s1);
	if(ans==3)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();

        if(x == 0){
        System.out.println("1");
        }else if(x == 1){
        System.out.println("0");
        }
    }
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 200005;
int p[N], ird[N], irr[N];
vector<int> grd[N], grr[N];

int find(int v){
	return (p[v] < 0)?v:(p[v] = find(p[v]));
}

void combine(int u, int v){
	u = find(u);
	v = find(v);
	if(u == v)return;
	if(p[u] > p[v])swap(p[u], p[v]);
	p[u] += p[v]; p[v] = u;
}

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

inline int find(vector<int> &v, int x){
	int l = 0, r = (int)v.size() - 1;
	while(l <= r){
		int m = l + (r - l)/2;
		if(v[m] == x)return 1;
		if(v[m] < x)l = m + 1;
		else r = m - 1;
	}
	return 0;
}

inline int get(int ia, int ib){
	if(mp.find({ia, ib}) != mp.end())return mp[{ia, ib}];
	if(grd[ia].size() < grr[ib].size()){
		int ret = 0;
		for(auto x : grd[ia]){
			ret += find(grr[ib], x);
		}
		return mp[{ia, ib}] = ret;
	}else{
		int ret = 0;
		for(auto x : grr[ib]){
			ret += find(grd[ia], x);
		}
		return mp[{ia, ib}] = ret;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, k, l;
	cin>>n>>k>>l;
	memset(p, -1, sizeof(p));
	for(int i = 0; i < k; i++){
		int u, v; cin>>u>>v;
		combine(u, v);
	}
	for(int i = 1; i <= n; i++){
		ird[i] = find(i);
		grd[ird[i]].push_back(i);
	}
	memset(p, -1, sizeof(p));
	for(int i = 0; i < l; i++){
		int u, v; cin>>u>>v;
		combine(u, v);
	}
	for(int i = 1; i <= n; i++){
		irr[i] = find(i);
		grr[irr[i]].push_back(i);
	}
	for(int i = 1; i <= n; i++){
		cout<<get(ird[i], irr[i])<<" ";
	}

	return 0;
}

Measured memory_bytes: 35328
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_E"

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

#define call_from_test

#ifndef call_from_test
#include <bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
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;}
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif

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

#define call_from_test
#include "../tools/chminmax.cpp"
#undef call_from_test

#endif
//BEGIN CUT HERE
int edit_distance(string s,string t){
  int n=s.size(),m=t.size();
  vector< vector<int> > dp(n+1,vector<int>(m+1,n+m+1));
  dp[0][0]=0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      if(i<n) chmin(dp[i+1][j],dp[i][j]+1);
      if(j<m) chmin(dp[i][j+1],dp[i][j]+1);
      if(i<n and j<m)
        chmin(dp[i+1][j+1],dp[i][j]+(s[i]!=t[j]));
    }
  }
  return dp[n][m];
}
//END CUT HERE
//INSERT ABOVE HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif

#undef call_from_test

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

  string s1,s2;
  cin>>s1>>s2;
  cout<<edit_distance(s1,s2)<<endl;
  return 0;
}



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


int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n, -1), s(n), c(n);
    rep1(i, m) cin >> s[i] >> c[i];
    rep1(i, m){
        if (a[s[i]-1]!=-1 && a[s[i]-1]!=c[i]){
            cout << -1 << endl;
            return 0;
        }
        a[s[i]-1] = c[i];
    }
    if (a[0]==0 && n>1){
        cout << -1 << endl;
        return 0;
    }
    rep1(i, n){
        if (i==0 && n>1){
            if (a[i]==-1) cout << 1;
            else cout << a[i];
        }else{
            if (a[i]==-1) cout << 0;
            else cout << a[i];
        }
    }
}

Measured memory_bytes: 3528
/**
 * @author torith
 * @date 2018-11-04
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

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

    int N; cin >> N;
    double T,A; cin >> T >> A;

    int ans = 0;
    double diff = 1e9;
    for (int i = 0; i < N; ++i) {
        int H; cin >> H;
        if (diff > abs(T - H * 0.006 - A)){
            ans = i;
            diff = (abs(T - H * 0.006 - A));
        }
    }

    cout << ans+1 << "\n";

    return 0;
}



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

long long A, B, C,K,ans;

void p(long long a, long long b, long long c,long long sum)
{
	if (sum == K) {
		ans = a - b;
		return;
	}
	p(b + c, a + c, a + b, sum + 1);
}

int main() 
{
	cin >> A >> B >> C >> K;

	if (K % 2 == 0 && K >= 1) {
		K = 2;
	}
	else if (K % 2 != 0) {
		K = 1;
	}

	p(A, B, C, 0);

	cout << ans << 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 MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz(x) (int)x.size()
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int l,r,d;
	cin>>l>>r>>d;
	cout<<((r/d) - ((l-1)/d))<<"\n";
	return;
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

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

int main(){
  int N,D,X,sum;
  cin >> N >> D >> X;
  int A;
  sum = N;
  for(int i=0;i<N;i++){
    cin >> A;
    sum += (D-1)/A;
  }
  cout << sum + X << endl;
  return 0;
}

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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"
#define llevel 20
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
string s;
ll d,n;
const int  N=10005;
ll dp[N][100][2];
ll solve(ll pos,ll sum,ll prev)
{
	if(pos==n)
	{
		return (sum==0);
	}
	if(dp[pos][sum][prev]!=-1)return dp[pos][sum][prev];
	ll ans=0;
	ll num=9;
	if(prev==1)
		num=s[pos]-'0';
	for(ll j=0;j<=num;++j)
	{
		ll ff=0;
		if(j==num && prev==1)ff=1;
		ans+=solve(pos+1,(sum+j)%d,ff);
		ans%=M;
	}
	return dp[pos][sum][prev]=ans;
}
int _runtimeTerror_()
{
	cin>>s>>d;
	n=s.length();
	mem1(dp);
	cout<<(solve(0,0,1)-1+M)%M;
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	return 0;
}


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

int n,pos;
vector<int> pre,in,post;

void rec(int l,int r) {
  if (l>=r) 
    return ;
  int root=pre[pos++];
  int m=distance(in.begin(),find(in.begin(),in.end(),root));
  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
  
}
void solve() {
  pos=0;
  rec(0,pre.size());
  for (int i=0; i<n; i++) {
    if (i) 
      cout<<" "<<flush;
    cout<<post[i]<<flush;
  }
  cout<<endl;
}
int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin>>n;
  int s;
  for (int i=0; i<n; i++) {
    cin>>s;
    pre.push_back(s);
  }
  for (int i=0; i<n; i++) {
    cin>>s;
    in.push_back(s);
  }
  
  
  solve();
  return 0;
}



Measured memory_bytes: 3220
#include <iostream>
using namespace std;
int main(){
	int n,m,x[200100],y[200100],c,a,b;
	cin >> n >> m;
	for (int i=0; i<n; i++){
		x[i]=0;
		y[i]=0;
	}
	for (int i=0; i<m; i++){
		cin >> a >> b;
		if (a==1 || b==1){
			if (a==1)
				x[b-1]=1;
			else
				x[a-1]=1;
		}
		else if (a==n || b==n){
			if (a==n)
				y[b-1]=1;
			else
				y[a-1]=1;
		}
		else if (a==1 || b==1){
			if (a==1)
				x[b-1]=1;
			else
				x[a-1]=1;
		}
	}
	for (int i = 0; i < n; i++){
		if (x[i]==1 && y[i]==1){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}
		cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

const int mod = 998244353;

int n;
long long a, b, req;

int fact[300005], inv_fact[300005];

int expo(int a, int b){
	int c = 1, d = a;
	while(b){
		if(b & 1){
			c = 1LL * c * d % mod;
		}
		d = 1LL * d * d % mod;
		b >>= 1;
	}
	return c;
}

int ncr(int N, int R){
	int ret = fact[N];
	ret = 1LL * ret * inv_fact[R] % mod;
	ret = 1LL * ret * inv_fact[N - R] % mod;
	return ret;
}

int inv(int x){
	return expo(x, mod - 2);
}

int main(){
	fact[0] = inv_fact[0] = 1;
	for(int i = 1; i <= 300000; i++){
		fact[i] = 1LL * fact[i - 1] * i % mod;
		inv_fact[i] = inv(fact[i]);
	}
	
	scanf("%d %lld %lld %lld", &n, &a, &b, &req);
	
	int ans = 0;
	
	for(int i = 0; i <= n; i++){
		long long remain = req - i * a;
		if(remain < 0 || remain % b > 0){
			continue;
		}
		long long need = remain / b;
		if(need > n){
			continue;
		}
		
		ans = (ans + 1LL * ncr(n, i) * ncr(n, need)) % mod;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
    return b ? gcd(b, a%b) : abs(a);
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e: a) cin >> e;

    vector<int> g(n), gr(n);
    g[0] = a[0];
    for (int i = 1; i < n; ++i) {
        g[i] = gcd(g[i-1], a[i]);
    }
    gr[n-1] = a[n-1];
    for (int i = n-2; i >= 0; --i) {
        gr[i] = gcd(gr[i+1], a[i]);
    }
    int ans = max(gr[1], g[n-2]);
    for (int i = 1; i <= n-2; ++i) {
        ans = max(ans, gcd(g[i-1], gr[i+1]));
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))
const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

string replaceStr(string &replacedStr, string from,string to){
    unsigned int pos = replacedStr.find(from);
    int toLen = to.length();

    if(from.empty()){
        return replacedStr;
    }

    while((pos = replacedStr.find(from,pos)) <= replacedStr.size()){
        replacedStr.replace(pos,from.length(),to);
        pos += toLen;
    }
    return replacedStr;
}


int main(){
    string s;
    cin >> s;
    replaceStr(s,","," ");
    cout << s << endl;

    return 0;
}

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

typedef pair<int,int> P;
int X, Y, ans;

char field[MAX][MAX];
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};

void bfs(int px, int py)
{
     field[px][py] = '#';
     ans++;
     for (int i = 0; i < 4; i++) {
	  int x = px + dx[i], y = py + dy[i];
	  if (0 <= x && x < X && 0 <= y && y < Y && field[x][y] == '.') bfs(x,y);
     }
}

int main(void)
{
     int x, y;
     while (cin >> Y >> X && X && Y) {
	  for (int i = 0; i < X; i++)
	       for (int j = 0; j < Y; j++) {
		    cin >> field[i][j];
		    if (field[i][j] == '@') {
			 x = i;
			 y = j;
		    }
	       }
	  ans = 0;
	  bfs(x,y);
	  cout << ans << endl;
     }

     return 0;
}

Measured memory_bytes: 1168
n=int(input())
a=list(map(int,input().split()))

import math

Min=[0]*(n+1)
Max=[0]*(n+1)
true=[0]*(n+1)
ans=sum(a)
fault=0

if n==0:
  if a[0]!=1:
    print(-1)

  else:
    print(ans)
else:
  if a[0]==0:
    Min[0]=1
    Max[0]=1


  for i in range(1,n):
    m=Min[i-1]-a[i]
    M=Max[i-1]*2-a[i]
    if M<0:
      fault=1
      #print('i')
      break
    Min[i]=max(m,0)
    Max[i]=M

#print(Min)
#print(Max)

  if a[n]<Min[n-1] or 2*Max[n-1]<a[n]:
    fault=1
#else:
  #Min[n]=a[n]
  #Max[n]=a[n]
  #true[n]=a[n]

  for i in reversed(range(1,n)): 
    true[i]=min(Max[i],true[i+1]+a[i+1])
    ans+=true[i]

  if fault==1:
    print(-1)
  else:
    print(ans+1)

Measured memory_bytes: 674896
#include<cstdio>
#include<iostream>
#define int long long
using namespace std;
int data[30][1000005];
int n;
inline int lowbit(int x){return x&(-x);}
void change(int z,int x,int y)
{
    for(int i=x;i<=n;i+=lowbit(i))
    {
        data[z][i]+=y;
    }
}
int query(int z,int x)
{
    if(x==0)return 0;
    int ans=0;
    for(int i=x;i;i-=lowbit(i))
    {
        ans+=data[z][i];
    }
    return ans;
}
char s[500005];int xx;int l,r;
signed main()
{
	cin>>n;
	cin>>s+1;
	for(int i=1;i<=n;i++)
	{
		change(s[i]-'a',i,1);
	}
    int m;cin>>m;
    for(int i=1;i<=m;i++)
    {
    	cin>>xx;
    	if(xx==1)
    	{
			int weizhi;
			char c;
			cin>>weizhi;
			cin>>c;
			if(s[weizhi]!=c)
			{
				change(s[weizhi]-'a',weizhi,-1);
				change(c-'a',weizhi,1);
				s[weizhi]=c;
			}
		}
		else if(xx==2)
		{
			cin>>l>>r;
			int ans=0;
			for(int j=0;j<26;j++)
			{
				if((query(j,r)-query(j,l-1))>=1)
				{
					ans++;
				}
			}
			cout<<ans<<endl;
		}
	}
}

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

struct type
{
	int len, vtx;
};

vector<type> m[100001];
int a, b, c, q, k, n;
long long arr[100001];
bool v[100001];

void dfs(int num, long long cnt)
{
	arr[num] = cnt;
	v[num] = 1;
	for (int i = 0; i < m[num].size(); i++)
		if (!v[m[num][i].vtx])
			dfs(m[num][i].vtx, cnt + m[num][i].len);
}

int main()
{
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		cin >> a >> b >> c;
		m[a].push_back({ c, b });
		m[b].push_back({ c, a });
	}
	cin >> q >> k;
	dfs(k, 0);
	for (int i = 0; i < q; i++)
	{
		cin >> a >> b;
		cout << arr[a] + arr[b] << endl;
	}
}

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

int e[128][128];
int d[128][128];

int main(){
  int n, m; cin >> n >> m;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (i != j) d[i][j] = 1e9;
      e[i][j] = -1;
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    e[a][b] = c;
    e[b][a] = c;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        d[i][j] = min(d[i][k] + d[k][j], d[i][j]);
      }
    }
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (d[i][j] - d[k][j] == e[i][k]) e[i][k] = 0;
      }
    }
  }
  int count = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (e[i][j] > 0) count++;
    }
  }
  cout << count / 2 << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++)
		if((i%2==0&&s[i]=='L')||(i%2!=0&&s[i]=='R')) {cout<<"No";return 0;}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
	while(true){
		int n;
		cin >> n;
		if (n == 0) break;

		int max_p = 0, max_d = 0;
		for (int i = 0; i < n; i++) {
			int p, d1, d2;
			cin >>p >> d1 >> d2;

			if (max_d <=  d1 + d2) {
				max_d = d1 + d2;
				max_p = p;
			}
		}
		cout << max_p << " " << max_d << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
class SegTree:
    def __init__(self, a, func):
        self.n = 2**(len(a) - 1).bit_length()
        self.f = func
        self.d = [0] * (2 * self.n - 1)
        self.d[self.n - 1:self.n - 1 + len(a)] = a
        for i in reversed(range(self.n - 1)):
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def update(self, i, v):
        i += self.n - 1
        self.d[i] = v
        while i:
            i = (i - 1) // 2
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def query(self, l, r):
        assert l <= r
        l += self.n
        r += self.n
        s = self.d[l - 1]
        while l < r:
            if l & 1:
                s = self.f(s, self.d[l - 1])
                l += 1
            if r & 1:
                r -= 1
                s = self.f(s, self.d[r - 1])
            l //= 2
            r //= 2
        return s
def main():
    N, C = map(int, input().split())
    S = []
    for i in range(N):
        x, v = map(int, input().split())
        S.append((x,v))
    r = [S[0][1] - S[0][0]]
    for i, v in enumerate(S[1:], start=1):
        r.append(r[-1] + v[1] - (v[0] - S[i-1][0]))
    l = [S[-1][1] + S[-1][0] - C]
    for i, v in enumerate(reversed(S[:-1]), start=1):
        l.append(l[-1] + v[1] - (S[N-i][0] - v[0]))
    l.reverse()
    def func(x,y):
        return max(x, y)
    rs = SegTree(r, func)
    ls = SegTree(l, func)
    m = 0
    for i in range(N):
        rr = r[i] - S[i][0] + ls.query(i+1, N) if i < N-1 else 0
        ll = l[i] + S[i][0] - C + rs.query(0, i) if i > 0 else 0
        m = max(m, r[i], rr, ll, l[i])
    return m
print(main())


Measured memory_bytes: 75992
/*
AizuOnline A0028
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int HIST[101];
//
main()
{
  int t,i,maxhin;

  while(EOF!=scanf("%d",&t))
    {
      HIST[t]++;
    }

  maxhin=0;
  for(i=1;i<=100;i++)
    if(HIST[i] > maxhin)
      maxhin = HIST[i];

  for(i=1;i<=100;i++)
    if(HIST[i] == maxhin)
      printf("%d\n",i);

return(0);
}

Measured memory_bytes: 596
O = input()
E = input()
password = ""

if len(O) == len(E):
    for i in range(len(O)):
        password += O[i]
        password += E[i]
    print(password)
else:
    for i in range(len(O)-1):
        password += O[i]
        password += E[i]
    password +=O[-1]
    print(password)



Measured memory_bytes: 3060
from collections import defaultdict
import itertools

d = defaultdict(int)
N = int(input())
for i in range(N):
  s = input()[0].lower()
  d[s] += 1

n = [d['m'], d['a'], d['r'], d['c'], d['h']]
ans = 0

a = itertools.combinations(n, 3)
for aa in a:
  t = 1
  for aaa in aa:
    t *= aaa
  ans += t

print(ans)

Measured memory_bytes: 3444