akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
void get_unique(vector<T>& x) {
    x.erase(unique(x.begin(), x.end()), x.end());
}
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    set<ll> st;
    st.insert(x);
    vector<ll> a = {x};
    ll b = -1;
    while (1) {
        ll nxt = a.back() * a.back() % m;
        if (st.count(nxt)) {
            rep(i, sz(a)) if (a[i] == nxt) b = i;
            break;
        }
        st.insert(nxt);
        a.push_back(nxt);
    }
    if (sz(a) >= n) {
        cout << accumulate(a.begin(), a.begin() + n, 0ll) << '\n';
        return 0;
    }
    ll ans = 0;
    ans += accumulate(a.begin(), a.begin() + b, 0ll);
    n -= b;
    ans += accumulate(a.begin() + b, a.end(), 0ll) * (n / ll(sz(a) - b));
    ans += accumulate(a.begin() + b, a.begin() + b + (n % ll(sz(a) - b)), 0ll);
    cout << ans << '\n';
}

Measured memory_bytes: 5952
#include<iostream>
#include<cstring>

using namespace std;

int map[105][105];
int xg,yg;
int w,h;
int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};

bool check(int x,int y)
{
  if(x==xg && y==yg)
    return true;
  if(map[x][y]==-1)
    return false;
  if(x>h||y>w||x<=0||y<=0)
    return false;
  
  char buf=map[x][y];
  map[x][y]=-1;
  for(int i=0;i<4;i++)
    {
      if(x+dx[i]<=h && x+dx[i]>0 &&
	 y+dy[i]<=w && y+dy[i]>0 &&
	 map[x+dx[i]][y+dy[i]]==buf && 
	 check(x+dx[i],y+dy[i])
	 )
	return true;
    }
  return false;
}
int main()
{
  for(;cin>>w>>h,w;)
    {
      memset(map,-1,sizeof(map));
      int xs,ys;
      cin>>ys>>xs;
      cin>>yg>>xg;
      int n;
      cin>>n;
      for(int i=0;i<n;i++)
	{
	  int c,d,x,y;
	  cin>>c>>d>>y>>x;
	  if(d==0)
	    {
	      for(int xx=x;xx<x+2;xx++)
		for(int yy=y;yy<y+4;yy++)
		  map[xx][yy]=c;
	    }
	  else
	    {
	      for(int xx=x;xx<x+4;xx++)
		for(int yy=y;yy<y+2;yy++)
		  map[xx][yy]=c;
	    }
	}
      if(check(xs,ys))
	cout<<"OK"<<endl;
      else 
	cout<<"NG"<<endl;      
    }
}

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

#define int long long

main() {
    int ans = 0;
    int h, a, b; cin >> h >> a >> b;
    for (int i = a; i < b + 1; i++) {
        ans += (h % i == 0);
    }
    cout << ans << endl;
}


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

const long mod=1e9+7;

const long pow2[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 73741817, 147483634, 294967268, 589934536, 179869065, 359738130, 719476260, 438952513, 877905026, 755810045, 511620083, 23240159, 46480318, 92960636, 185921272, 371842544, 743685088, 487370169, 974740338, 949480669, 898961331, 797922655, 595845303, 191690599, 383381198, 766762396, 533524785, 67049563, 134099126, 268198252, 536396504};

vector<int>getketa(long n, int c){
  vector<int>ret(c);
  for(int i=0; i<c; i++){
    ret[i]=n%2;
    n/=2;
  }
  return ret;
}

int main(){
  int n;
  cin >> n;
  vector<vector<int>>a(n);
  vector<int>num1(61, 0);
  for(int i=0; i<n; i++){
    long ar;
    cin >> ar;
    a[i]=getketa(ar, 61);
  }
  for(int i=0; i<61; i++){
    for(int j=0; j<n; j++){
      if(a[j][i])num1[i]++;
    }
  }
  long ret=0;
  for(int i=0; i<61; i++){
    long cnt=0;
    for(int j=0; j<n; j++){
      if(a[j][i]==0)cnt += num1[i];
      else cnt += n-num1[i];
    }
    cnt %= mod;
    ret += cnt*pow2[i];
    ret %= mod;
  }
  cout << (ret*500000004)%mod;
  return 0;
}

Measured memory_bytes: 82304
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	ll N;
	cin >> N;
	ll i, cx, cy, ct, nx, ny, nt;
	ct = 0;
	cx = 0;
	cy = 0;
	for (i = 0; i < N; i++){
		cin >> nt >> nx >> ny;
		int md = abs(nx - cx) + abs(ny - cy);
		int dt = nt - ct;
		if (dt < md || abs(md - dt) % 2 == 1) break;
		ct = nt;
		cx = nx;
		cy = ny;
	}
	if (i == N) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    dp = [[0 for _ in range(10)] for _ in range(10)]
    ans = 0
    for i in range(1, n+1):
        s = str(i)
        l = int(s[0])
        r = int(s[-1])
        dp[l][r] += 1
    for i in range(1, n+1):
        s = str(i)
        l = int(s[0])
        r = int(s[-1])
        # print(i, l, r, dp[l][r], dp[r][l])
        ans += dp[r][l]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N = int(input())
S = []
for j in range(N):
  S.append(input().split())
G = []
for i in range(N):
  if S[i][0] == S[i][1]:
    G.append("1")
  else:
    G.append("0")

AN = (''.join(G))

if "111" in AN:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9128
#include <iostream>
#include <stdlib.h>
using namespace std;
int GCD(int a,int b)
{
	if (a%b==0)
		return b;
	else
		return GCD(b,a%b);
}
int cmp(const void *a,const void *b)
{
	return *(int*)b-*(int*)a;
}
int main()
{
	float a[2],gcd,lcm;
	while(cin>>a[0]>>a[1])
	{
		if (cin.eof())break;
		qsort(a,2,sizeof(int),cmp);
		gcd=GCD(a[0],a[1]);
		lcm=(a[0]*a[1])/gcd;
		cout<<(int)gcd<<' '<<(int)lcm<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int b = sc.nextInt();
		// long[] a = new long[n];
		// for (int i = 0; i < n; i++) {
		// a[i] = sc.nextLong();
		// }
		sc.close();
		long ans = n - b + 1;
		System.out.println(ans);
	}
}


Measured memory_bytes: 20820
class UnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n)]
    self.rank = [0]*n
  def find(self, x):
    if self.par[x]==x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
  def unit(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x==y:
      return
    elif self.rank[x]<self.rank[y]:
      self.par[x] = y
      return
    elif self.rank[y]<self.rank[x]:
      self.par[y] = x
    else:
      self.par[y] = x
      self.rank[x] += 1
      
  def same(self, x, y):
    return self.find(x)==self.find(y)
  

N, M, *L = map(int, open(0).read().split())
p = L[:N]
ls = L[N:]
u = UnionFind(N+1)
for x,y in zip(*[iter(ls)]*2):
  u.unit(x,y)
inf = {p[i]:i for i in range(N)}
ans = sum(1 if u.same(i,inf[i]+1) else 0 for i in range(1,N+1))
print(ans)

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


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int sum = a + b + c;
    int m = max(max(a,b),c);
    int s = min(min(a,b),c);
    cout << s << " " << (sum - m -s) << " " << m << endl;
    return 0;
}


Measured memory_bytes: 3100
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, K = gets_i_list
a_list = gets_i_list

puts ( (N - K).to_f / (K - 1) ).ceil + 1


Measured memory_bytes: 8956
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
using namespace std;
int main()
{
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	int max1=-1000;
	int min2=1000;
	int a;
	for (int i=0;i<n;i++)  cin>>a,max1=max(max1,a);
	for (int i=0;i<m;i++)  cin>>a,min2=min(min2,a);
	for (int i=-105;i<105;i++)  if (i>max1 && i<=min2 && i>x && i<=y)  {cout<<"No War";return 0;}
	cout<<"War";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

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

int main(){
    int n;
    cin >> n;
    vector<int> ab(n);
    ll res = 0;
    for(int i = 0; i < n; ++i){
        int a, b;
        cin >> a >> b;
        res -= b;
        ab[i] = a + b;
    }
    
    sort(ab.begin(), ab.end(), greater<int>());
    int num = ceil((double)n / 2);
    ll sum = 0;
    for(int i = 0; i < n; i += 2){
        sum += ab[i];
    }
    res += sum;
    
    cout << res << endl;
}

Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let a = read::<usize>();
  let b = read::<usize>();

  if (a + b) % 2 == 0 {
    println!("{}", (a + b) / 2);
  } else {
    println!("IMPOSSIBLE");
  }
}


Measured memory_bytes: 4352
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


MOD = 1000000007
X, Y = map(int, input().split())

n = (X + Y) // 3
x = (2 * X - Y) // 3
y = (-X + 2 * Y) // 3
if (X + Y) % 3 or x < 0 or y < 0:
    print(0)
    exit()


def mod_com(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    if k > n - k:
        k = n - k
    if k == 0:
        return 1
    ans = 1
    for i in range(n - k + 1, n + 1):
        ans = ans * i % MOD

    inv = [0] * (k + 1)
    inv[1] = 1
    for i in range(2, k + 1):
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        ans = ans * inv[i] % MOD

    return ans


print(mod_com(n, x))


Measured memory_bytes: 41328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; i++)
			x[i] = sc.nextInt();
		int ans = 999999999;
		int[] dist = new int[n - k + 1];





		for (int i = 0; i < n - k + 1; i++) {
			dist[i] = Math.abs(x[i + k - 1] - x[i]);

			if (Math.abs(x[i + k - 1]) >= Math.abs(x[i])) {
				dist[i] += Math.abs(x[i]);
			} else {
				dist[i] += Math.abs(x[i + k - 1]);
			}
		}





		for (int i = 0; i < n - k + 1; i++) {

			if (ans >= dist[i]) {
				ans = dist[i];
			}
		}
		System.out.println(ans);
	}

}

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

using namespace std; 

string s, t; 

int main() {
	cin >> s >> t; 

	int n = s.length(), m = t.length(); 
	int ans = n; 

	for (int i = 0; i + m - 1 < n; ++i) {
		int cur = 0; 
		for (int j = 0; j < m; ++j)
			cur += s[j + i] != t[j]; 
		ans = min(ans, cur); 
	}

	cout << ans << '\n'; 

	return 0; 
}

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

using ll = long long;

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

    string S;
    cin >> S;

    int abc[3] = {};
    for (auto s: S) {
        abc[s - 97]++;
    }
    sort(abc, abc + 3);
    if ((abc[0] == abc[1] && abc[2] - abc[1] <= 1) || (abc[1] == abc[2] && abc[1] - abc[0] <= 1)) {
        cout << "YES" << '\n';
    } else {
        cout << "NO" << '\n';
    }

    return 0;
}


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

int main() {
  string c; cin>>c;
  for(int i=0;i<c.size();i++){
    if(c.at(i)=='a'||c.at(i)=='i'||c.at(i)=='u'||c.at(i)=='e'||c.at(i)=='o') cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
  }
  return 0;
}

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

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

    int A[100];
    int N; cin >> N;
    for(int i = 0; i < N; i++)
        cin >> A[i];

    double result = 0;
    for(int i = 0; i < N; i++)
        result += 1 / (double) A[i];
    
    result = 1 / result;

    printf("%.5f", result);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#define maxn 5010
#define maxint 0x7fffffff/2
using namespace std;
double pi=3.1415926;
int main() {
	int n;
	cin>>n;
	double r=double(1.0*n);
	printf("%.4lf",1.0*r*2.0*1.0*pi);
	return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a;
  long long b;
  long long k;
  cin >> a >> b >> k;

  if(a > k) {
   a = a - k;
  } else {
   b = b - (k - a);
    if(b < 0)
      b = 0;
   a = 0;
  }
  
  cout << a << ' ' << b << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vi l(n), r(n);
  rep(i,n) cin>>l[i]>>r[i];
  priority_queue<ll> ql;
  PQ(ll) qr;
  ll offl = 0, offr = 0;
  ql.push(0); qr.push(0);
  ll ans = 0;
  rep(i,n-1) {
    ll xl = r[i+1]-l[i];
    ll xr = l[i+1]-r[i];
    offl -= xl; offr -= xr;
    if (offl+ql.top() >= 0) {
      ql.push(-offl); ql.push(-offl);
      ll x = ql.top()+offl; ql.pop();
      ans += x;
      qr.push(x-offr);
    } else if (offr+qr.top() <= 0) {
      qr.push(-offr); qr.push(-offr);
      ll x = qr.top()+offr; qr.pop();
      ans += -x;
      ql.push(x-offl);
    } else {
      ql.push(-offl);
      qr.push(-offr);
    }
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 2804
#include <iostream>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	int n,k;
	cin>>n>>k;
	vector<int> h(n);
	for(int i=0;i<n;i++)
	cin>>h[i];
	//dp[i] minimum cost to reach i th step from 0
	ll dp[100005];
	dp[0]=0;
	for(int i=1;i<n;i++){
		dp[i]=mod;
		for(int j=1;j<=k;j++){
			if(i-j>=0)
			dp[i]=min(dp[i], abs(h[i]-h[i-j])+dp[i-j]);
		}
	}
	cout<<dp[n-1];
	
	
}

Measured memory_bytes: 4524
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int i, j, a;

int main() {
    cin >> n;
    FOR(i, 0, n) {
        cin >> a;
        while (a % 2 == 0) {
            a = a / 2;
            ans++;
        }
    }
    cout << ans << endl;   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF=1LL<<60;
int main(){
    int p,q,m;cin >> p >> q >> m;
    vector<int> a(p),b(q),x(m),y(m),c(m);
    int am=1e6,bm=1e6;
    for(int i=0;i<p;i++){
        cin >> a[i];
        chmin(am,a[i]);
    }
    for(int i=0;i<q;i++){
        cin >> b[i];
        chmin(bm,b[i]);
    }
    int ans=am+bm;
    for(int i=0;i<m;i++){
        cin >> x[i] >> y[i] >> c[i];
        x[i]--,y[i]--;
        chmin(ans,a[x[i]]+b[y[i]]-c[i]);
    }
    cout << ans << endl;
}

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

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	vector<int> v(3);
	v = {a, b, c};
	sort(v.begin(), v.end());
	int ans = 0;
	rep (i, k) {
		v[v.size() - 1] *= 2;
		
	}

	rep (i, 3) {
			ans += v[i];
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n, i, max, min;
    long long sum;
    scanf("%d", &n);
    int a[n];
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    max = a[0];
    min = a[0];
    sum = a[0];
    for(i = 1; i < n; i++){
        if(max < a[i]){
            max = a[i];
        }
        if(min > a[i]){
            min = a[i];
        }
        sum += a[i];
    }
    printf("%d %d %lld\n", min, max, sum);
    return 0;
}


Measured memory_bytes: 2112
#include<stdio.h>
   #include<string.h>
  int main(void){
       int i;
       char str[10000];
         scanf("%[^\n]%*c",str);
       for(i=0;i<=strlen(str);i++){
          if(str[i]>=97&&str[i]<=122)
            str[i]=str[i]-32;
         else if(str[i]>=65&&str[i]<=90)
           str[i]=str[i]+32;
      }
      printf("%s\n",str);
      return 0;
  }


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

long long calc(long long A){
  long long cnt1=(A+1)/2;
  long long ans=(cnt1+1)%2;
  if((A%2==0))ans^=A;
  return ans;
}
int main() {
  long long A,B;
  cin>>A>>B;
  long long ans=calc(B)^calc(A-1);
  cout<<ans<<endl;   
  return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V
 
getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]
 
type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)
 
mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
fi = fromInteger
fig = fromIntegral
rf = realToFrac
 
(.<.) f g -- combination
    | f < g = 0 
    | g < 1 || f < 1 = 1
    | True = foldr1 (*) (take g [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)
 
unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)
 
mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a
 
countIf f = length . filter f
 
-- 
--
--
main = do
  inp <- getLine
  putStrLn . show . minimum $ map (\x -> drop x >>> take 3 >>> (read :: String -> Int) >>> (-) 753 >>> abs $ inp) [0..(length inp - 3)]


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

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

const long long INF = 1LL << 60;

int GCD(int a,int b){
	if(b==0) return a;
	return GCD(b,a%b);
}
int main(void){
	int k;cin >> k;
	int sum=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int l=1;l<=k;l++){
				sum += GCD(GCD(i,j),l);
			}
		}
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3624
/**
	*    author:  accesss_denied
	**/
	#include <bits/stdc++.h>
	using namespace std;
	#define ll long long int
	#define ff first
	#define ss second
	#define pb push_back
	#define endl "\n"
	#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll mod=1e9+7;			
	ll inf=1e18;

	int main() {
				fast
				// #ifndef ONLINE_JUDGE
				// freopen("input.txt","r",stdin);
				// freopen("output.txt","w",stdout);
				// #endif

				ll t;
				t=1;
				while(t--)
				{
					string s;
                    cin>>s;
                    if(s[s.size()-1]=='s')
                    cout<<s<<"es"<<endl;
                    else
                    cout<<s<<"s"<<endl;
					
				}
				return 0;
			}	




Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>


#define MAX 10

typedef unsigned char	U08;
typedef signed char	S08;
typedef unsigned long	U32;


static void Denominator_Division_Void( U32 u32_1st_num, U32 u32_2nd_num );


int main()
{
    U08 u08a_get_1st_num[MAX];
    U08 u08a_get_2nd_num[MAX];
    U32 u32_1st_num;
    U32 u32_2nd_num;
    S08 *s08p_dummy_buffer;
    
    fscanf( stdin, "%s", u08a_get_1st_num );
    fscanf( stdin, "%s", u08a_get_2nd_num );
    u32_1st_num = strtol( u08a_get_1st_num, &s08p_dummy_buffer, 0 );
    u32_2nd_num = strtol( u08a_get_2nd_num, &s08p_dummy_buffer, 0 );
    
    Denominator_Division_Void( u32_1st_num, u32_2nd_num );

    return 0;
}

static void Denominator_Division_Void( U32 u32_1st_num, U32 u32_2nd_num )
{
    U32 u32_dividend;
    U32 u32_divisor;
    U32 u32_remainder = 1;
    
    if( u32_1st_num >= u32_2nd_num )
    {
        u32_dividend = u32_1st_num;
        u32_divisor = u32_2nd_num;
    }
    else
    {
        u32_dividend = u32_2nd_num;
        u32_divisor = u32_1st_num;
    }
    
    while( 0 != u32_remainder )
    {
        u32_remainder = u32_dividend % u32_divisor;
        u32_dividend = u32_divisor;
        u32_divisor = u32_remainder;
    }
    printf("%d\n",u32_dividend);
    
}




Measured memory_bytes: 2104
#include<iostream>
#include<vector>
#include<string.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
 
int dp[2000][1<<12];
int a[300000];
int c[300000];
 
int main(){
	int n,m;cin>>n>>m;
	rep(i,m){
		int b;scanf("%d%d",&a[i],&b);
		rep(j,b){
			int d;scanf("%d",&d);d--;
			c[i]|=1<<d;
		}
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	rep(i,m)rep(j,1<<n){
		dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
		dp[i+1][j|c[i]]=min(dp[i+1][j|c[i]],dp[i][j]+a[i]);
	}
	if(dp[m][(1<<n)-1]==INF)puts("-1");
	else cout<<dp[m][(1<<n)-1]<<endl;
}

Measured memory_bytes: 32512
#include  <cstdio>
#include  <algorithm>
using  namespace  std;
int N,ptr ,res;int A[100000];
int  main()
{
  scanf("%d",&N);
  for(int i=0;i<N;i++) scanf("%d",&A[i]);
  sort(A,A+N);while(ptr <N)
  {
    int cc=A[ptr],f=0;
    while(ptr <N&&A[ptr]==cc)f++,ptr++;
    res+=f%2;
  }
  printf("%d\n",res);
}

Measured memory_bytes: 512
list = []
for i in range(4):
    list.append(int(input()))

#print(list)

a = 0
b = 0
c = 0
res = 0
for a in range(list[0]+1):
    for b in range(list[1]+1):
        for c in range(list[2]+1):
            total = 500*a + 100*b + 50*c
            if total == list[3]:
                res += 1
print(int(res))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i] >> h[i];
    vector<vector<int>> d(101, vector<int> (101, -1));
    int flag = 0;
    for(int i = 0; i < N; i++){
        if(h[i] > 0) flag = 1;
    }
    int flag2 = 0;
    for(int i = 0; i < N; i++){
        int a = 0;
        for(int j = -100; j <= 100; j++){
            for(int k = -100; k <= 100; k++){
                int nx = x[i] + j, ny = y[i] + k;
                int nd = h[i] + abs(j) + abs(k);
                if(flag == 1 && 0 <= nx && nx <= 100 && 0 <= ny && ny <= 100){
                    if(flag2 == 0 && h[i] != 0){
                        d[nx][ny] = nd;
                        a = 1;
                    }
                    else if(h[i] != 0){
                        if(d[nx][ny] != nd) d[nx][ny] = -1;
                    }
                }
                else if(flag == 0 && 0 <= nx && nx <= 100 && 0 <= ny && ny <= 100){
                    if(flag2 == 0){
                        d[nx][ny] = nd;
                        a = 1;
                    }
                    else{
                        if(d[nx][ny] != nd) d[nx][ny] = -1;
                    }
                }
                
            }
        }
        if(a == 1) flag2 = 1; 
    }
    if(flag == 1){
        for(int i = 0; i < 101; i++){
            for(int j = 0; j < 101; j++){
                for(int k = 0; k < N; k++){
                    if(h[k] == 0 && d[i][j] - abs(x[k] - i) - abs(y[k] - j) > 0) d[i][j] = -1;
                }
            }
        }
    }
    int ans = -1;
    int cx, cy;
    for(int i = 0; i < 101; i++){
        for(int j = 0; j < 101; j++){
            if(ans < d[i][j]){
                ans = d[i][j];
                cx = i;
                cy = j;
            }
        }
    }
    printf("%d %d %d\n", cx, cy, ans);
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long N, long long K){
    if(N <= K) cout << min(abs(N - K), N) << endl;
    else{
        i64 cnt = N / K;
        cout << min(abs(N - K * cnt), abs(N - K * (cnt + 1))) << endl;
    }
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int l=s.length()-1;
    if(l%2!=0)
    	l--;
    int i=0, j=(l/2);
    for( ; i<j, j<l; )
    {
    	if(s[i++]!=s[j++])
    	{
    		i=0; l-=2; j=l/2;
    	}
    }
    cout<<l<<endl;
}
    

Measured memory_bytes: 3644
#include<iostream>


#define MAX 100
#define ll long long
using namespace std;


int main( )
{
	int n;
	while(cin >> n){
		ll ans = 180;
		for(int i = 3; i < n; i++){
			ans += 180;
		}
		cout << ans << endl;
	}
	return 0;
}

 

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

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

    int n, k;
    cin >> n >> k;

    map<int, bool> s;
    REP(i, n)
        s.insert(make_pair(i, false));

    REP(i, k) {
        int tmp; cin >> tmp;
        REP(j, tmp) {
            int tmp2; cin >> tmp2;
            s[tmp2 - 1] = true;
        }
    }

    int count = 0;
    for (auto [k, v] : s) {
        if (v == false) count++;
    }
    cout << count << '\n';
    return 0;
}


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

int in(){int x;cin>>x;return x;}

int main(){
	int N; cin>>N;
	vi ans(N);
	rep(i, N-1) ans[in()-1]++;
	rep(i, N) cout<<ans[i]<<endl;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
const int MOD = 1e9 + 7;
const int INF = 2e9;
#define pb push_back
#define mp make_pair
#define mt make_tuple
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; }

int main(){
    int n, d;
    cin >> n >> d;
    cout << 1 + (n - 1) / (1 + 2 * d) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
vector<int> visited;
int N,M;
vector<vector<int>> G;
bool fl = false;


int main(){
    cin >> N >> M;
    G.resize(N);
    visited.resize(N);
    for(auto i:visited) i = 0;
    rep(i,M){
        int a,b;cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(auto nv:G[0]){  
        for(auto go:G[nv]){
            if(go==N-1){
                fl = true;
            }
        }
    }
    cout << (fl?"POSSIBLE":"IMPOSSIBLE") << endl;
}

Measured memory_bytes: 12784
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
char s[200010];
int b[300], res[200010], nxt[200010][26]; 
int main() {
	scanf("%s", s);
	int n = strlen(s);
	int now_have = 0, need = 1;
	for(int i = n - 1; i >= 0; i--) {
		res[i] = need;
		if(!b[s[i]]) now_have++;
		b[s[i]] = 1;
		if(now_have == 26) {
			now_have = 0;
			memset(b, 0, sizeof(b));
			need++; 
		}
	}
	for(int i = 0; i <= 25; i++) nxt[n - 1][i] = n;
	for(int i = n - 2; i >= 0; i--) {
		for(int j = 0 ; j <= 25; j++)
		nxt[i][j] = nxt[i + 1][j];
		nxt[i][s[i + 1] - 'a'] = i + 1;
	} 
	for(int j = 0; j <= 25; j++)
	nxt[n + 1][j] = nxt[0][j];
	nxt[n + 1][s[0] - 'a'] = 0;
	int pos = n + 1;
	while(1) {
		int mi = n, mxn = pos, pre = pos;
		for(int i = 0; i <= 25; i++) {
			if(res[nxt[pos][i]] < mi) {
				mi = res[nxt[pos][i]];
				mxn = nxt[pos][i];
			}
		}
		pos = mxn; 
		if(mxn == n) {
			for(int i = 0; i <= 25; i++) {
				if(nxt[pre][i] == mxn) {
					printf("%c", 'a' + i);
					break;
				}
			}
			break;
		}
		printf("%c", s[mxn]);
	}
	return 0;
} 

Measured memory_bytes: 21504
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    A = LI()
    a = sorted(A,reverse=True)

    high = a[0] * 2 + 1
    low = 0
    while high > low + 1:
        mid = (high + low) // 2

        cnt = 0
        j = N - 1
        for i in range(N):
            while a[i] + a[j] < mid:
                j -= 1
                if j < 0: break
            else:
                cnt += (j+1)
                continue
            break
        if cnt <= M:
            high = mid
        else:
            low = mid

    s = [a[0]]
    for i in range(1,N):
        s.append(s[-1]+a[i])

    ans = 0
    cnt = 0
    m = a[0] * 2
    j = N - 1
    for i in range(N):
        while a[i] + a[j] < low:
            j -= 1
            if j < 0: break
        else:
            ans += a[i] * (j+1) + s[j]
            cnt += j + 1
            m = min(m,a[i] + a[j])
            continue
        break

    print(ans - (cnt-M) * low)


if __name__ == '__main__':
    main()

Measured memory_bytes: 91672
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     

def main():
    N, M = LI()
    if M == 0:
        print("Yes")
        return

    G = [[] for _ in range(N)]
    for i in range(M):
        l, r, d = LI()
        l -= 1
        r -= 1
        G[l].append((r, d))
        G[r].append((l, -d))
    val = [inf] * N
    global_visited = set()

    def bfs(ini):
        flag = True
        q = deque([ini])
        visited = set()
        visited.add(ini)
        while q:
            v = q.popleft()
            for next_v, d in G[v]:
                if next_v in visited:
                    if val[next_v] == val[v] + d:
                        continue
                    else:
                        return False
                val[next_v] = val[v] + d
                visited.add(next_v)
                global_visited.add(next_v)
                q.append(next_v)
        return True

    can = True
    for i in range(N):
        if i in global_visited:
            continue
        v = i
        val[v] = 0
        if not bfs(v):
            can = False
            break

    if can:
        print("Yes")
    else:
        print("No")
    return


main()




Measured memory_bytes: 115228
N, X = map(int, input().split())
x = list(map(int, input().split()))
g = X - max(x)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
    
for i in range(N):
    if g == 1:
        break
    g = gcd(g, abs(X-x[i]))

print(g)

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

using namespace std;

int main(){
    int N,hcf,lcm;
    cin>>N;
    for(int i = 1; i <= 2 && i <=N; i++) {
        if (2% i == 0 && N % i == 0) {
            hcf = i;
        }
    }
    lcm=(N*2)/hcf;
    cout<<lcm;
}


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

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;

	int x, y, z;
	x = a + b;
	y = b + c;
	z = c + a;

	if (x <= y && x <= z) {
		cout << x;
	}
	else if (y <= x && y <= z) {
		cout << y;
	}
	else {
		cout << z;
	}

}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> as;
    rep(i, n) {
        cin >> a[i];
        as[a[i] - i]++;
    }
    ll ans = 0;
    rep(i, n) {
        ll v = (a[i] - i + i * 2) * -1;
        as[a[i] - i] = max(0LL, as[a[i] - i]);
        ans += as[v];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 27484
A, B, M = map(int, input().split())
a_ = list(map(int,input().split()))
b_ = list(map(int,input().split()))
price = []

for i in range(0, M):
    c = list(map(int, input().split()))
    price.append(a_[c[0]- 1]+b_[c[1]- 1]-c[2])

price.append(min(a_)+min(b_))
print(min(price))

Measured memory_bytes: 72044
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define endl "\n"
#define oo 0x3f3f3f3f3f3f3f3fLL
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define setdp memset(dp,-1,sizeof(dp))
#define db(x) cout<<" LOOK "<<(#x)<<" = "<<x <<'\n'
#define NumofDigits(n)   ((long long)log10(n)+1)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};*/
inline void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}


int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    //File();
    int a,b,k;
    cin>>a>>b>>k;
    vector<int>ans(105);
    ans[0]=1;
    for(int i=2; i<=min(a,b); i++)
        if(a % i == 0 and b % i == 0)
            ans.pb(i);
    sort(allr(ans));
    cout<<ans[--k];
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n,ans=0;
	cin>>n;
	for(int i=sqrt(n); i>0; --i) {
		if(n%i==0) {
			int j=n/i;
			while(j){
				ans++;
				j/=10;
			}
			break;
		}
	}
	cout<<ans<<endl;
}

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


void se(ll n,vector<ll>& PN_chk){
    //2以上の数の素因数分解をするので無視して良い
    PN_chk[0]=0;PN_chk[1]=0;
    for(int i=2;i<=n;i++){
        //たどり着いた時に素数と仮定されているなら素数
        //ある素数の倍数はその素数で割り切れるのでマークづけ
        if(PN_chk[i]==1) for(int j=2;j<=n/i;j++){PN_chk[j*i]=i;}
    }
}

//O(logn)
//mapなのでprimeは整列されている！！！
void prime_factorize(ll n,vector<ll>& PN_chk ,map<ll,ll>& prime){
    if(n<=1) return;
    //1の場合はnは素数
    if(PN_chk[n]==1){prime[n]++;return;}
    //マークされている数は素数
    prime[PN_chk[n]]+=1;
    //マークされている数でnを割った数を考える
    prime_factorize(n/PN_chk[n] , PN_chk , prime);
}
int main(){
    
    map<ll,ll> prime;
    int n;
    cin >> n;
    vector<ll> pn_chk(n+1,1);
    ll ans=1;
    se(n,pn_chk);

    for(ll i=2;i<=n;i++){
        map<ll,ll> prime;
        ll sum=1;
        prime_factorize(i,pn_chk,prime);
        for(auto p :prime){
            sum*=(p.second+1);
        }
        ans+=sum*i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 81412
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N; cin >> N;
  for(ll h=1; h<=3500; h++) {
    for(ll n=1; n<=3500; n++) {
      ll a = 4*h*n-N*h-N*n;
      ll b = N*h*n;
      if(a == 0) {
        if(b == 0) {
          cout << h << ' ' << n << ' ' << 1 << endk;
          return 0;
        }
      } else {
        if(b % a == 0 && b/a > 0) {
          cout << h << ' ' << n << ' ' << b/a << endk;
          return 0;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<numeric>
#include<climits>
#include<map>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;
class DisjointSet
{
public:
	//rank:それぞれの木の深さ
	//p:ポインタ的な配列
	vector<int> rank, p;
	int tree_num;
	DisjointSet() {}
	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		//最初は、全ての値は別の木に属するようにする
		//{0},{1},{2},...といった数字一つのみを持つ木が作られる
		for (int i = 0; i < size; i++)
		{
			makeSet(i);
		}
	};

	//ただ一つの要素xを持つ木を作成
	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}

	//要素xが属する木のルートノードの値を求める
	int findSet(int x) {
		//xがルートノードでないならポインタがさしている先を再帰的に探索する
		//ルートノードならreturnする
		if (x != p[x]) {
			//ここで最終的に返ってくるのはルートノードの値であるため、探索中に経由したすべてのノードのポインタはルートノードへとつながる。
			p[x] = findSet(p[x]);
		}
		return p[x];
	}

	//xとyが同じ木に属しているか判定→ルートノードが同じかどうかで判定可能
	bool isSame(int x, int y) {
		return findSet(x) == findSet(y);
	}

	//xを根に持つ木とyを根に持つ木を統合する
	void link(int x, int y) {
		//なるべく木が深くならないように、rankが小さい方をrankが大きい方へ統合する
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			//木の深さが同じだったらどうしても一段深くなってしまう
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

	//xを要素に持つ木とyを要素に持つ木を統合する
	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}
};

int main(void) {
	int n, m;
	cin >> n >> m;
	vector<vector<int> > edge(m,vector<int>(2));
	for (int i = 0; i < m; i++)
	{
		cin >> edge[i][0] >> edge[i][1];
		edge[i][0]--; edge[i][1]--;
	}

	int count = 0;
	for (int i = 0; i < m; i++)
	{
		DisjointSet ds(n);
		for (int j = 0; j < m; j++)
		{
			if (j != i) {
				ds.unite(edge[j][0],edge[j][1]);
			}
		}

		for (int j = 1; j < n; j++)
		{
			if (!ds.isSame(j, j - 1)) {
				count++;
				break;
			}
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = input()
    ans =""
    
    for i in a:
        if i =="1":
            ans +="9"
        else:
            ans+="1"
    print(ans)

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    vector<int> cnt(100005, 0);
    ll sum = 0;
    rep(i, N)
    {
        int a;
        cin >> a;
        cnt[a]++;
        sum += a;
    }

    int Q;
    cin >> Q;
    rep(i, Q)
    {
        int B, C;
        cin >> B >> C;
        sum += cnt[B] * (C - B);
        cnt[C] += cnt[B];
        cnt[B] = 0;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3780
eval"N,C,*H="+`dd`.split*?,;g,*q=->i{x,y=q[i,2];1.0*($*[x]-$*[y])/(H[y]-H[x])-H[x]-H[y]};N.times{|i|q.shift while q[-2]&&g[0]>-2*H[i];$*<<X=i>0?$*[q[0]]+C+(H[q[0]]-H[i])**2:0;q.pop 2while(q<<i)[-3]&&g[-2]>g[-3]};p X

Measured memory_bytes: 85264
#include<iostream>
#include<string>

using namespace std;

int main() {
	string S;
	cin >> S;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == S[i + 1]) {
			cout << "Bad";
			return 0;
		}
	}

	cout << "Good";
}

Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
int main() {
	ll A, B, C, D;
	ll ans;
	cin >> A >> B >> C >> D;
	ll E, F;
	ll L, H;
	//高校数学発想、AでC,D割れるものを差っ引いたものから
	//B-1=HでC,Dで割れるものを差っ引く；
	H = A - 1;
	ll tmp;//CDの入れ替えに必要；
	ll I = C, J = D;
	ll K = C * D;

	if (I< J) { tmp = I;I = J;J = tmp; }
	//互除法
	ll r = I % J;
	while (r != 0) {
		I = J;
		J = r;
		r = I % J;
	}
	L = K / J;
	E = H - (H / C + H / D - H / L);
	F = B - (B / C + B / D- B / L);
	ans = F - E;

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


Measured memory_bytes: 256
def solve(string):
    n, *a = map(int, string.split())
    a = ("{:060b}".format(_a) for _a in a)
    m, ans = 10**9 + 7, 0
    for c in zip(*a):
        s = c.count("1")
        ans <<= 1
        ans += s * (n - s)
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 72412
#include<stdio.h>
int main(void)
{
	int H, W, h, w;
	int num;
	scanf("%d %d",&H, &W);
	scanf("%d %d",&h, &w);
	
	num = H*W - h*W -(H-h)*w;
	
	printf("%d",num);
	return 0;
}

Measured memory_bytes: 128