akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
using namespace std;
typedef long long ll;

int n;
int vs[200000+10];

// inline bool lessThanPow(int v, int k, int n) {
//   if(k == 1) {
//     return v < 1;
//   } else {
//     ll r = 1;
//     REP(i, n) {
//       r *= k;
//       if(v < r) return true;
//     }
//     return v < r;
//   }
// }

struct K {
  int d;
  int ith;
};

// carry overでtrue
bool incr(vector<K>& st, int k) {
  assert(!st.empty());
  int n = st.size();
  int lastD = st.back().d+1;
  for(int i = n-1; i >= 0; --i) {
    if(lastD-1 < 1) return true;
    if(st[i].d < lastD-1) {
      st.insert(st.begin()+i+1, (K){lastD-1, 1});
      return false;
    }
    st[i].ith++;
    if(st[i].ith < k) {
      return false;
    }
    st[i].ith = 0;
    lastD--;
  }
  if(lastD-1 < 1) return true;
  st.insert(st.begin(), (K){lastD-1, 1});
  return false;
}

bool isOK(int k) {
  // cerr << "> " << k << endl;
  vector<K> st;
  st.push_back((K){vs[0], 0});
  for(int i = 1; i < n; ++i) {
    // REP(j, st.size()) {
    //   cerr << "(" << st[j].d << "," << st[j].ith << "),";
    // }
    // cerr << endl;
    if(vs[i] > st.back().d) {
      st.push_back((K){vs[i], 0});
      continue;
    }
    if(k == 1) return false;
    while(!st.empty() && st.back().d > vs[i]) {
      st.pop_back();
    }
    if(st.empty()) {
      st.push_back((K){vs[i], 1});
      continue;
    }
    if(st.back().d < vs[i]) {
      st.push_back((K){vs[i], 0});
    }
    bool carry = incr(st, k);
    if(carry) return false;
  }
  return true;
}

int main(void) {
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &vs[i]);
  }
  int left = 0;
  int right = n;
  while(left+1 < right) {
    int md = (left + right) / 2;
    if(isOK(md)) {
      right = md;
    } else {
      left = md;
    }
  }
  cout << right << endl;
  return 0;
}


Measured memory_bytes: 4692
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

class Point {
public:
  int x, y;
};

int main() {

  int h, w;
  cin >> h >> w;
  vector< vector<int> > a(h, vector<int>(w));
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> a[i][j];
    }
  }

  vector< pair<Point, Point> > p;
  for(int i=0; i<h-1; i++){
    for(int j=0; j<w; j++){
      if( (a[i][j] % 2) == 0 ) continue;
      Point tmp1;
      Point tmp2;
      tmp1.x = j;
      tmp1.y = i;
      tmp2.x = j;
      tmp2.y = i+1;
      p.push_back({tmp1, tmp2});
      a[i][j]--;
      a[i+1][j]++;
    }
  }

  for(int j=0; j<w-1; j++){
    if( (a[h-1][j] % 2) == 0 ) continue;
    Point tmp1;
    Point tmp2;
    tmp1.x = j;
    tmp1.y = h-1;
    tmp2.x = j+1;
    tmp2.y = h-1;
    a[h-1][j]--;
    a[h-1][j+1]++;
    p.push_back({tmp1, tmp2});
  }

  cout << p.size() << endl;
  for(int i=0; i<p.size(); i++){
    printf("%d %d %d %d\n", p[i].first.y+1, p[i].first.x+1, p[i].second.y+1, p[i].second.x+1);
  }

  return 0;
}



//


Measured memory_bytes: 5232
#include <bits/stdc++.h>
#define ll long long
#define fir first
#define sed second
#define i64 int64_t
#define mp make_pair
#define pb push_back
const int mod = 1e9+7;

using namespace std;
ifstream fi("");
ofstream fo("");

int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int a,b,c;
    cin>>a>>b;

    if (a==1&&b==2) cout<<3;
    if (a==2&&b==1) cout<<3;

    if (a==1&&b==3) cout<<2;
    if (a==3&&b==1) cout<<2;

    if (a==2&&b==3) cout<<1;
    if (a==3&&b==2) cout<<1;
}





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


def main():
    s = input()

    if s == 'RRR':
        print(3)
    elif s == 'RRS':
        print(2)
    elif s == 'SRR':
        print(2)
    elif s == 'RSR':
        print(1)
    elif s == 'RSS':
        print(1)
    elif s == 'SRS':
        print(1)
    elif s == 'SSR':
        print(1)
    elif s == 'RSR':
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8980
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <numeric>
#include <math.h>

#define rep(i, n) for (int i = 0; i < n; ++i)
typedef unsigned long long ll;

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int max_a = 0;
    vector<int> a ;
    a.assign(n, 0);
    ll tot_vote = 0;
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    tot_vote = accumulate(a.begin(),a.end(),0);
    bool flag_yes = true;
    rep(i, m)
    {
        int goods = a[i];
        int hikaku = ceil(tot_vote / float(4 * m));
       
        if (goods < hikaku)
        {
            flag_yes = false;
        }
    }
    if (flag_yes == false)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

    return 0;
}

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

constexpr long long MOD = 998244353;
vector<long long> F, RF;

long long Calc(long long A, long long B) {
	if (B == 0) return 1;
	if (B % 2 == 0) {
		long long C = Calc(A, B / 2);
		return (C * C) % MOD;
	}
	return (A * Calc(A, B - 1)) % MOD;
}

void init() {
	F.resize(2500001), RF.resize(2500001);
	F[0] = F[1] = RF[0] = RF[1] = 1;
	for (int i = 2; i <= 2500000; i++) F[i] = (F[i - 1] * i) % MOD;
	RF[2500000] = Calc(F[2500000], MOD - 2);
	for (int i = 2499999; i >= 2; i--) RF[i] = (RF[i + 1] * (i + 1)) % MOD;
}

long long Comb(long long A, long long B) {
	if (B < 0 || A < B) return 0;
	return (F[A] * ((RF[A - B] * RF[B]) % MOD)) % MOD;
}

long long Solve(long long X, long long Y, long long Z) {
	long long COUNT = 0;
	for (int P = 0; P <= Y && P <= Z; P++) {
		if ((X - P) < 0 || (X - P) % 2 == 1) continue;
		long long Q = (X - P) / 2;
		COUNT += (Comb(Q + Z - 1, Q) * Comb(Z, P)) % MOD;
		COUNT %= MOD;
	}
	return COUNT;
}

int main() {
	init();
	long long N, M;
	cin >> N >> M;
	long long ANS1 = Solve(M * 3, M, N), ANS2 = (Solve(M, M, N) - Solve(M, M, N - 1) + MOD) % MOD;
	cout << (ANS1 + (MOD - ANS2) * N) % MOD << endl;
}

Measured memory_bytes: 39296
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int a[3]={0},n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	if(a[0]>a[1])swap(a[0],a[1]);
	if(n==3){
		if(a[1]>a[2])swap(a[1],a[2]);
		if(a[0]>a[1])swap(a[0],a[1]);}
	for(int i=1;i<=a[0];i++){
		if(0==a[0]%i)
		if(0==a[1]%i)
			if(0==a[2]%i)cout<<i<<endl;
	}

	return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll k; cin>>k;
  if(k%2==0||k%5==0)
    return cout<<"-1\n", 0;
  ll cnt=1, i=k, p=7;;
  while(i--){
    if(p%k==0)
      break;
    p=p*10+7;
    p%=k;
    cnt++;
  }
  if(p%k==0)
    return cout<<cnt<<"\n", 0;
  cout<<"-1\n";
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#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())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 998244353;
const ll LINF = 1e18;
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...));
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> v;
    for (int i = 0; i < n;) {
        int j = i;
        while (j < n && a[i] == a[j]) j++;
        v.emplace_back(j - i);
        i = j;
    }
    int ans = 0;
    for (int x : v) {
        ans += x / 2;
    }
    cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i=0;i<n;i++)

ll h, w, k;
 
ll memo[8][110];
 
ll dfs(ll pos, ll hei) {
	if(memo[pos][hei] != -1) return memo[pos][hei];
	if(hei == h + 1) {
		if(pos == k) return 1;
		else return 0;
	}
	ll ret = 0;
	rep(i,(1ll<<(w-1))) {
		bitset<7> bi(i);
		bool d = true;
		rep(j,w-2) if(bi[j] == 1 && bi[j + 1] == 1) d = false;
		if(!d) continue;
		bool upd = false;
		if(pos > 0 && bi[pos - 1]) {
			upd =true;
			ret += dfs(pos - 1, hei + 1);
		}
		if(pos < w - 1 && bi[pos]) {
			upd = true;
			ret += dfs(pos + 1, hei + 1);
		}
		if(!upd) ret += dfs(pos, hei + 1);
	}
	return memo[pos][hei] = ret % MOD;
}
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> h >> w >> k;
	k--;
	if(w == 1) {
		cout << 1 << endl;
		return 0;
	}
	rep(i,8) rep(j,110) memo[i][j] = -1;
	cout << dfs(0, 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);
 
int main()
{
	ll n;
	cin >> n;
	vector<ll> a(5,0);
	for(int i = 0; i < 5; i++) cin >> a[i];
	ll mi = 1e18;
	for(int i = 0; i < 5; i++) mi = min(mi,a[i]);
	cout << 4 + (n+mi-1)/mi << endl;
	return 0;	
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int n, k; cin>>n>>k;
    vector<double> p(n);
    for(int i=0; i<n; i++){
        cin>>p[i];
        p[i] = (p[i] + 1) / 2;
    }

    double sum = 0;
    for(int i=0; i<k; i++) sum += p[i];

    double ans = sum;
    for(int i=k; i<n; i++){
        sum -= p[i-k];
        sum += p[i];
        chmax(ans, sum);
    }

    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
char vowel[6]={'a','e','e','i','o','u'};
int main(){
    char s;
    cin>>s;
    for (int i = 0; i <6 ; ++i) {
        if (s == vowel[i])
        {cout << "vowel";
            return 0;}
    }
    cout<<"consonant";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int n,M,ans=1;
	scanf("%d%d",&n,&M);
	if (n==1) return !printf("%d",M);
	for (int i=2;i<=M/n;++i)
	{
		if (M%i) continue;
		if (M/i>=n) ans=i;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
void print(ll x){
	if(x<0)putchar('-'),x=-x;
	char y=x%10+'0';
	if(x>=10)print(x/10);
	putchar(y);
}
ll n,k,x,y,sx=1,sy=1,cx,cy;
int main(){
	k=read(),x=read(),y=read();
	if(k%2==0 and(abs(x)+abs(y))%2)return puts("-1"),0;
	if(x<0)x=-x,sx=-1;
	if(y<0)y=-y,sy=-1;
	n=(x+y+k-1)/k;
	if(n==1 and x+y!=k)n++;
	while((n*k-x-y)%2)n++;
	print(n),puts("");
	for(ll i=(n*k-x-y)/2;i;){
		bool t=abs(x-cx)<abs(y-cy);
		ll z=min(k,i);
		if(t)cx-=z,cy+=k-z;
		else cy-=z,cx+=k-z;
		i-=z;
		print(cx*sx),putchar(' '),print(cy*sy),puts("");
	}
	while(cx!=x or cy!=y){
		ll r=k;
		if(cx!=x){
			ll d=min(k,x-cx);
			cx+=d,r-=d;
		}
		if(cy!=y){
			ll d=min(r,y-cy);
			cy+=d;
		}
		print(cx*sx),putchar(' '),print(cy*sy),puts("");
	}
	return 0;
}

Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N;
vector<ll> v;

int main () {
  cin >> N;
  Rep(i, N) {
    ll tmp;
    cin >> tmp;
    v.push_back(tmp);
  }

  sort(All(v), greater<ll>());

  ll ans = 0;

  ll times = 1;

  Rep(i, N-1) {
    times *= 4;
    times %= MOD;
  }

  for (ll i=2;i<2+N;++i) {
    ans += v[i-2] * i;
    ans %= MOD;
  }

  ans *= times;
  ans %= MOD;

  cout << ans << "\n";

}

Measured memory_bytes: 2420
N, Y = map(int, input().split())
count = 0

for i in range(N+1):
    if count == 1:
        break
    else:
        for j in range(N+1-i):
            k = N - (i + j)
            if 10000 * i + 5000 * j + 1000 * k == Y:
                count += 1
                print('{} {} {}'.format(i, j, k))
if count == 0:
    print('-1 -1 -1')

Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};

//int ans = 0;

int dfs(string s, int N){
  int ans = 0;
  if (!s.empty() && stoll(s) > N) return 0;
  if (count(all(s), '7') && count(all(s), '5') && count(all(s), '3')) ans ++;
  ans += dfs(s + "7", N);
  ans += dfs(s + "5", N);
  ans += dfs(s + "3", N);
  return ans;
}

int main(void){
  int N;
  cin >> N;
  cout << dfs(""s, N) << endl;
  return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int N; cin >> N;
    string S;
    cin >> S;
    int cnt = 0;
    rep(i, S.size()-2) {
        if (S.substr(i, 3) == "ABC") {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n=sc.nextLong();
        long output=Long.MAX_VALUE;
        for(int i=1;i<Math.sqrt(n)+1;i++){
            if(n%i==0){
                output=Math.min(output,Math.max((long)Math.log10(i),(long)Math.log10(n/i))+1);
            }
        }
        System.out.println(output);
    }
}

Measured memory_bytes: 23252
package main

import (
  "fmt"
)

func main() {
  var s,t string
  var l,cnt  int
  fmt.Scanf("%s", &s)
  fmt.Scanf("%s", &t)

  l = len(s)
  cnt = 0

  for i := 0; i < l; i++ {
    if s[i] != t[i] {
      cnt++
    }
  }

  fmt.Println(cnt)
}

Measured memory_bytes: 4580
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
int main()
{
	int n,i,j,k;
	string s;
	string t = "ABC";
	cin>>n>>s;
	int ans = 0,c;
	for(i=0;i<n-2;i++)
	{
		c = 0;
		k = i;
		for(j=0;j<3;j++,k++)
			if(s[k] == t[j])
				c++;
			else
				break;
		if(c == 3)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

bool judge(int X){
    int limit = (int)sqrt(X);
    for(int i = 2; i < limit+1; i++){
        if(X % i == 0){
            return true;
        }
    }
    return false;
}

int min_prime(int &X){
    while(judge(X)){
        X++;
    }
    return X;
}

int main() {
    int X;

    cin >> X;

    cout << min_prime(X) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long
ll min(ll a, ll b)
{
    return a < b ? a : b;
}
ll max(ll a, ll b) { return a > b ? a : b; }

ll sep(int a, int b)
{
    ll pre = 1 << 30, a1, a2;
    for (ll i = 1; i < a; i++)
    {
        a1 = max(llabs(b * i - b * ((a - i) / 2)), llabs(b * i - b * (a - i - (a - i) / 2)));
        a2 = max(llabs(b * i - (a - i) * (b / 2)), llabs(b * i - (a - i) * (b - b / 2)));
        pre = min(pre, min(a1, a2));
    }
    return pre;
}

int main(void)
{
    ll h, w;
    cin >> h >> w;
    cout << min(sep(h, w), sep(w, h));
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 3005;
const ll mod = 998244353;
ll c[maxn][maxn];
ll f[maxn][maxn+maxn];
void pd(ll&ret,ll val){
  ret+=val;
  ret%=mod;
}
void init() {
  f[0][0] = 1;
  for (int i = 0; i < maxn; i++)c[i][0] = c[i][i] = 1;
  for (int i = 1; i < maxn; i++)
    for (int j = 1; j < i; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1])%mod;
    }
}

int n,m;
int sq[maxn];
int ans;
void dfs(int pos) {
  if(pos == n) {
    for(int i=0;i<n;i++){
      int sum = 0;
      for(int j=i;j<n;j++){
        sum+=sq[j];
        if(sum==m)return;
      }
    }
    ans++;
    if(ans>mod)ans-=mod;
    return;
  }
  for(int i=0;i<3;i++){
    sq[pos]=i;
    dfs(pos+1);
  }
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  init();
  cin>>n>>m;
 // dfs(0);
 // bug(ans)
  for(int i=1;i<=n;i++) {
    for (int j = 1; j < m; j++) {
      if (2 * i < j)break;
      if(2*i-j<=i)
      f[i][j] = c[i][2 * i - j];
    }
    if((m&1)&&2*i>m)f[i][2*i]=1;
    for (int j = 1; j + j <i&&(j+j<m-1);j++) {
      if(m-1+2*j!=2*i)
      pd(f[i][m-1+2*j],f[i-j-j][m-1-2*j]);
    }
  }
  //bug(f[1][2])
  ll ret = 1;
  for(int i=1;i<=n;i++){
    ll sum = 0;
    for(int j=1;j<=i+i;j++)pd(sum, f[i][j]);
    pd(ret, sum*c[n][i]%mod);
  }
  cout<<ret%mod<<endl;
  return 0;
}



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

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  
  int ans;
  double diff = 1000.0;
  
  REP(i, n) {
    int h;
    cin >> h;
    double tmp = t - h * 0.006;
    if (abs(tmp - a) < diff) {
      ans = i + 1;
      diff = abs(tmp - a);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
// package app;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    // フィールド
    static char[][] field;
    // 最小反転回数
    static int retMinCnt = Integer.MAX_VALUE;

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        final String S = sc.next();
        int result = 0;
        for (int i = 0; i < S.length(); i++) {
            result += S.charAt(i) == '+' ? 1 : -1;
        }

        System.out.println(result);

    }
}

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

int n;
int A[21];
bool B[40001];
void dfs(int i, int j)
{
    if(i == n){
        B[j] = true;
        return;
    }
    else{
        dfs(i + 1, j);
        dfs(i + 1, j + A[i]);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> A[i];
    dfs(0,0);
    
    int q, m;
    cin >> q;
    for(int i = 0; i < q; ++i){
        cin >> m;
        cout << (B[m] ? "yes" : "no") << endl;
    }
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    int n,k;
    cin >> n >> k;

    map<int,bool> mp;
    for(int i = 0;i < k;i++){
        int d;
        cin >> d;
        mp[d] = true;
    }

    for(int i = 1;i <= 100000;i++){
        string now = to_string(i);
        bool flag = true;
        for(char c:now){
            if(mp[(int)(c-'0')])flag = false;
        }

        if(flag && i >= n){
            cout << i << endl;
            return 0;
        }
    }
}


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

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n, x;
   vector<int> vc;
   cin >> n >> x;
   for(int i = 0;i < n;i++) {
      int x;
      cin >> x;
      vc.push_back(x);
   }
   int count = 0;
   sort(vc.begin(), vc.end());
   int ans = 0;
   for(int i = 0;i < vc.size();i++) {
      x-=vc[i];
      count++;
   }
   int z = x/vc[0];
   count += z;
   cout << count << endl;
   
   return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
vector<int> divisor(int n)
{
	vector<int> ret;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n)	ret.push_back(n / i);
		}
	}
	return ret;
}
int main()
{
	// Tenka1 Programmer Contest-C, 1151, 15:40, First-AC
	/*ll n; cin >> n;
	rep(i, 3501) {
		if (i == 0) continue;
		rep(j, 3501) {
			if (j == 0) continue;
			int l = 0, r = 3500;
			while (l + 1 < r) {
				int m = (l + r) / 2;
				ll left = ll(m) * (ll(4) * ll(i) * ll(j) - n * ll(i) - n * ll(j));
				ll right = n * ll(i) * ll(j);
				if (left == right) {
					cout << i << " " << j << " " << m << endl;
					return 0;
				}
				else if (left < right) l = m;
				else r = m;
			}
		}
	}
	assert(false);
	*/

	// ABC106-B, 4:58, First AC
	/*int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 2) {
		vector<int> v = divisor(i);
		if (v.size() == 8) ans++;
	}
	cout << ans << endl;
	*/

	// ABC122-B, 8:54, WA-AC
	/*string s; cin >> s;
	int ans = 0, tmp = 0;
	bool ok = true;
	rep(i, s.size()) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') ok = true;
		else ok = false;
		if (ok) tmp++;
		else {
			ans = max(ans, tmp);
			tmp = 0;
		}
	}
	ans = max(ans, tmp);
	cout << ans << endl;
	*/

	// ABC095-C, 
	int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
	ll price = 0;
	if (c <= a / 2 + b / 2) {
		ll price1, price2;
		price1 = max(x, y) * c * 2;
		price2 = min(x, y) * c * 2;
		if (x < y) price2 += (y - x) * b;
		else price2 += (x - y) * a;
		price = min(price1, price2);
	}
	else {
		price = a * x + b * y;
	}
	cout << price << endl;

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
void chmin(ll &a, ll b){a = min(a, b);}
void solve(){
	ll n;
	cin >> n;
	vector<ll> a(n), v;
	for(int i=0;i<n;i++) cin >> a[i];
	string s;
    cin >> s;
    for(int i=n-1;i>=0;i--){
    	for(ll j: v) chmin(a[i], a[i] ^ j);
    	if(a[i]){
    		if(s[i] == '1'){
    			cout << 1 << endl;
    			return;
    		}else v.pb(a[i]);
    	}
    }
    cout << 0 << endl;
    return;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

const int n = 26;

int main(){
    int days;
    cin >> days;

    // 満足度が下がる値
    vector<int> bad(n);
    rep(i, n) cin >> bad[i];

    // そのコンテストをその日に開いた時の満足度
    vector<vector<int>> score(days+1, vector<int>(n));
    for(int d = 1; d <= days; d++){
        rep(i, n) cin >> score[d][i];
    }

    // 最後にそのコンテストが開かれたのが何日前か
    vector<vector<int>> preD(days+1, vector<int>(n, 0));

    // 日付毎で満足度が最大になるコンテストを開く
    vector<int> sats(days+1, 0), cons(days+1, 0);
    for(int d = 1; d <= days; d++){
        int maxSat = 0, maxCon = 0;

        // d日のi番目のコンテストを開いたときの満足度を計算し、最大になるコンテストと満足度を記録する
        rep(i,n){
            int conSat = score[d][i] + sats[d-1];
            vector<int> copyPreD = preD[d-1];
            rep(j,n){
                if (i == j) continue;
                conSat -= bad[j] * copyPreD[j];
                copyPreD[j]++;
            }
            if (chmax(maxSat, conSat)){
                maxCon = i;
            }
        }

        // 最も良いスコアとコンテストを更新
        sats[d] = maxSat;
        cons[d] = maxCon+1;

        // 開いたコンテストの最終日を更新
        rep(i,n){
            if (i == maxCon) preD[d][i] = 0;
            else preD[d][i] = preD[d-1][i] + 1;
        }
    }
    
    for(int d = 1; d <= days; d++){
        cout << cons[d] << endl;
    }
}

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

typedef long long ll;

int A[2000010], B[2000010];
ll C[10010];
using namespace std;

void coutnting_sort(int n)
{



    for(int j=0;j<n;j++)
    {
        C[A[j]]++;
    }

    for (int i = 1; i <= 10000; i++)
        C[i] += C[i - 1];

    for(int j=n-1;j>=0;j--)
    {
       B[C[A[j]]]=A[j];
       C[A[j]]--;
    }



    for(int i = 1;i <=n;i++){
    cout <<B[i];
    /// last akta space na print korar ar jnno
    if(i !=n)
      cout <<" ";
  }
  cout <<endl;
}




int main()
{

int n;
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>A[i];
}
coutnting_sort(n);


return 0;
}



Measured memory_bytes: 18716
#include <iostream>
#include <stdio.h>

using namespace std;

struct HL{
	int h,p,q;
}hl[1001];

int main(){
	int n, m ,a;
	
	while(1){
		for(int i=0 ; i<1001 ; i++){
hl[i].h = 0;hl[i].p = 0; hl[i].p = 0;
}

		cin >> n >> m >> a;
		if(n==0 && m==0 && a==0) break;

		for(int i=0 ; i<m ; i++){
			cin >> hl[i].h >> hl[i].p >> hl[i].q;
		}

		for(int h=1000 ; h>0 ; h--){
			for(int i=0 ; i<m ; i++){
				if(hl[i].h==h && hl[i].p==a){
					a++;
				}
				else if(hl[i].h==h && hl[i].q==a){
					a--;
				}
			}
		}
		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 880
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cstring>
#include <cctype>
#include <complex>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
const int INF = 1<<30;
const int EPS = 1e-8;
#define PB push_back
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int > Pii;
int panel[32];
int tech[32];
int memo[1<<16][32];
int n,c;
int bitCount(int a,int b){
	int cnt = 0;
	rep(i,16){
		if(a>>i & 1 && b>>i & 1){
			cnt++;
		}
	}
	return cnt;
}
int search(int bit,int dep){
	if(dep == n){
		return 0;
	}
	if(memo[bit][dep] != -1){
		return memo[bit][dep];
	}
	int ans = 0;
	rep(i,c){
		ans = max(ans,bitCount(bit,tech[i])+search(bit&~tech[i]|panel[dep+1],dep+1));
	}
	return memo[bit][dep] = ans;
}
int main(){
	while(scanf("%d%d",&n,&c),(n|c)){
		memset(panel,0,sizeof(panel));
		memset(tech,0,sizeof(tech));
		memset(memo,-1,sizeof(memo));
		rep(i,n){
			rep(j,16){
				int tmp;
				scanf("%d",&tmp);
				if(tmp){
					panel[i] += 1<<j;
				}
			}
		}
		rep(i,c){
			rep(j,16){
				int tmp;
				scanf("%d",&tmp);
				if(tmp)tech[i] += 1<<j;
			}
		}
		printf("%d\n",search(panel[0],0));
	}
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  string t = s.substr(0, n / 2);
  string y = s.substr(n / 2, n);
  if (n % 2 == 1)
  {
    cout << "No" << endl;
  }
  else
  {
    if (t == y)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
s = int(input())

a = [0, s]
i = 2
while True:
    if a[i - 1] % 2 == 0:
        a.append(a[i - 1] // 2)
    else:
        a.append(3 * a[i - 1] + 1)
    # print(a)
    if a[-1] in a[:-1]:
        print(len(a) - 1)
        break
    i += 1

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<int> B(N + 1);
  for (int i = 0, cnt = 0; i < N; i++) {
    if (S.at(i) == '#') cnt++;
    B.at(i + 1) = cnt;
  }
  vector<int> W(N + 1);
  for (int i = 0, cnt = 0; i < N; i++) {
    if (S.at(i) == '.') cnt++;
    W.at(i + 1) = cnt;
  }
  int ans = 1e9;
  for (int i = 0; i <= N; i++) {
    ans = min(ans, B.at(i) + (W.at(N) - W.at(i)));
  }
  cout << ans << "\n";
}

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

int main() {
    int N,K,r;
    long ans = 0;
    cin >> N >> K;

    for(int a=K+1;a<=N;a++){
        r = N % a;
        ans += (N/a)*(a-K)+max(0,r-K+1);
        if (K==0){
            ans -= 1;
        }
        //cout << a << " " << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
A,B,H,M=map(int,input().split())

m=(2*math.pi*M)/60
h=(2*math.pi*H)/12
h+=(2*math.pi*M)/(60*12)

if h<m:
    r=m-h
    ha=A*math.sin(r)
    ba=A*math.cos(r)
    ans=(ha**2+(B-ba)**2)
    ans=math.sqrt(ans)
else:
    r=h-m
    ha=B*math.sin(r)
    ba=B*math.cos(r)
    ans=(ha**2+(A-ba)**2)
    ans=math.sqrt(ans)

print(ans)

Measured memory_bytes: 9536
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  string D;
  cin>>D;
  string s="AIDUNYAN",t="AIZUNYAN";
  for(int i=0;i+s.size()-1<D.size();){
    string c(begin(D)+i,begin(D)+i+s.size());
    sort(begin(s),end(s));
    sort(begin(c),end(c));
    if(s==c){
      copy(begin(t),end(t),begin(D)+i);
      i+=s.size();
    }else{
      i++;
    }
  }
  cout<<D<<endl;
}

Measured memory_bytes: 1212
#include<cstdio>
#include<cstring>
const int MAXN = 100000;
const int MAXK = 1000;
int x[MAXN + 5], y[MAXN + 5], c[MAXN + 5];
int y1[10 * MAXK + 5];
int main() {
	int N, K, Max = 0, cnt = 0;
	scanf("%d%d",&N,&K);
	for(int i=1;i<=N;i++) {
		char ch;
		scanf("%d%d %c",&x[i],&y[i],&ch);
		x[i] = x[i] % (2*K);
		y[i] = y[i] % (2*K);
		if( ch == 'W' ) c[i] = 1;
		else c[i] = 0;
	}
	for(int i=0;i<=K;i++) {
		cnt = 0;
		memset(y1,0,sizeof(y1));
		for(int j=1;j<=N;j++) {
			int p = ( i <= x[j] && x[j] < i+K );
			int q = ( 0 <= y[j] && y[j] < K );
			if( p ^ q == c[j] ){
				cnt++;
				y1[y[j]] ++;
			}
			else {
				y1[y[j]] --;
			}
		}
		for(int j=0;j<=K;j++) {
			if( cnt > Max ) Max = cnt;
			if( N - cnt > Max ) Max = N - cnt;
			if( j != K )
				cnt = cnt - y1[j] - y1[K+j];
		}
	}
	printf("%d\n",Max);
}

Measured memory_bytes: 1408
while(a, b = gets.split(' ').map(&:to_i)) != [0, 0] 
  a.times do |x|
    _t = ''
    s = (x % 2).zero? ? '#.' : '.#'
    b.times { |y| _t += (y % 2).zero? ? s[0] : s[1] }
    puts _t
  end
  puts
end

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

using namespace std;

constexpr int MAX = 60 * 60 * 24 + 100;
int L[MAX];

int main()
{
	int n;
	while (cin >> n, n)
	{
		int fh, fm, fs, th, tm, ts;
		int f, t;
		for (int i = 0; i < n; ++i)
		{
			scanf("%d:%d:%d %d:%d:%d", &fh, &fm, &fs, &th, &tm, &ts);
			f = 60 * 60 * fh + 60 * fm + fs;
			t = 60 * 60 * th + 60 * tm + ts;
			//cout << f << t << endl;
			L[f]++;
			L[t]--;
		}
		for (int i = 1; i < MAX; ++i)
		{
			L[i] += L[i - 1];
		}
		int ans = 0;
		for (int i = 0; i < MAX; ++i)
		{
			ans = max(ans, L[i]);
			L[i] = 0;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3484
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const int mod = ((int)1e9 + 7);
// loop
#define rep(i, n) for(int i = 0, i##_mx = n; i < i_##mx; i++)
#define brep(i, b, e) for(int i = b; i < e; i++)
#define erep(i, b, e) for(int i = b; i <= e; i++)
#define rrep(i, b, e) for(int i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
// function
int gcd(int a, int b){return b ? gcd(b, a % b) : a;}
void prime(vint& v, int n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}

signed main(){
    int n;
    cin >> n;
    vector<tuple<int, string, int>> res;
    string s;
    int p;
    rep(i, n){
        cin >> s >> p;
        res.pb(mt(i + 1, s, p));
    }
    sort(all(res), [](auto l, auto r){if(get<1>(l) != get<1>(r)){return get<1>(l) < get<1>(r);}else{return get<2>(l) > get<2>(r);}});
    for(auto r : res){
        cout << get<0>(r) << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
long long wt[110];
long long val[110];
long long dp[101][100005];
long long n, w;
long long knapsack(long long wt[], long long val[], long long n, long long w)
{
    if (n == 0 || w == 0)
        return 0;
    if (dp[n][w] != -1)
        return dp[n][w];
    if (wt[n - 1] <= w)
    {
        return dp[n][w] = max(knapsack(wt, val, n - 1, w), val[n - 1] + knapsack(wt, val, n - 1, w - wt[n - 1]));
    }
    else
    {
        return dp[n][w] = knapsack(wt, val, n - 1, w);
    }
}
int main()
{
    cin >> n >> w;
    for (long long i = 0; i < n; i++)
    {
        cin >> wt[i] >> val[i];
    }
    /*for (int i = 0; i < n; i++)
    {
        cin >> val[i];
    }*/
    memset(dp, -1, sizeof(dp));
    cout << knapsack(wt, val, n, w);
    return 0;
}

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


int main(){

    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int index = 1;
    for( int i = 0; i < K; i++ ) index *= 2;

    if( A >= B && A >= C ) cout << A*index + B + C << endl;
    else if( B >= A && B >= C ) cout << A + B*index + C << endl;
    else cout << A + B + C*index << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  rep(i,0,N-1)rep(j,i+1,N)sum+=P[i]*P[j];
  Out(sum);
}

Measured memory_bytes: 256
N, m = gets.split.map(&:to_i)

@g = []
(0...m).each do |i|
  s, t = gets.split.map(&:to_i)

  @g[s] = [] if @g[s].nil?
  @g[s].push(t)
  @g[t] = [] if @g[t].nil?
  @g[t].push(s)
end

q = gets.to_i
s, t = q.times.map{gets.split.map(&:to_i)}.transpose

NONE = -1
@color = Array.new(N){NONE}

def dfs(r, c)
  s = []
  s.push(r)
  @color[r] = c

  while !s.empty?
    u = s.shift
    next if @g[u].nil?

    (0...@g[u].size).each do |i|
      v = @g[u][i]

      if @color[v] == NONE
        @color[v] = c
        s.push(v)
      end
    end
  end
end

def assign_color
  id = 1

  (0...N).each do |u|
    dfs(u, id) if @color[u] == NONE
    id += 1
  end
end

assign_color

(0...q).each do |i|
  puts @color[s[i]] == @color[t[i]] ? 'yes' : 'no'
end


Measured memory_bytes: 18080
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  string a,b;
  cin >> a >> b;
  
  bool ans=true;
  rep(i,3) if(!(a[i]==b[2-i])) ans=false;
  cout << (ans ? "YES" : "NO" ) << endl;
  return 0;
} 

Measured memory_bytes: 3572
N, K = [int(i) for i in input().split()]
ps = [int(i) for i in input().split()]
cs = [int(i) for i in input().split()]

global_max = -10**10
past_score = [[]]*N
past_time = [[]]*N
for n in range(N):
    score = 0
    itta = [0]*N
    iru = n
    k = 0
    while k < K:
        score += cs[ps[iru]-1]
        k += 1
        if itta[iru] == 1:
            # print('itta')
            # print(f'iru is {iru}')
            # print(f'score is {score}')
            # print(f'past_score is {past_score}')
            if score > past_score[iru]:
                # print('plus loop')
                T = k - past_time[iru]  # 周期
                # print(f'周期は {T}')
                if K - k > (2 * T) + 1:
                    # print(f'繰り返しは{((K-k)//T - 1)}回')
                    # print('それによって', (((K-k)//T - 1)*(score - past_score[iru])))
                    score += (((K-k)//T - 1)*(score - past_score[iru]))
                    k += T * ((K-k)//T - 1)
                    # print(f'new score is {score}')
                    # print(f'new k is {k}')
            else:
                # print('break!')
                break
        itta[iru] = 1
        # print(iru)
        # print(ps[iru]-1)
        # print(f'score is {score}')
        global_max = max(score, global_max)
        past_score[iru] = score
        past_time[iru] = k
        iru = ps[iru]-1
print(global_max)


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

int main()
{
    std::string S;
    std::string T;
    std::cin >> S >> T;

    T.pop_back();
    if(S == T)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<iostream> 
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#define Mod 1000000007
using namespace std;
long long ans,n,a[200001],k[200001];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],k[i]=(a[i]+k[i-1])%Mod;
	k[0]=0;
	for(int i=1;i<=n;i++)
	{
		ans=(ans+(k[i-1]*a[i])%Mod)%Mod;
	}
	cout<<ans%Mod; 
}

Measured memory_bytes: 6716
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.collection.immutable.TreeMap
import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val x = input.split(" ").map(_.toInt)
    var res = 0
    (1 to 5).foreach{i =>
      if (x(i - 1) != i) res = i
    }
    res.toString
  }

  def medianCalculator(seq: Seq[Long]): Long = {
    //In order if you are not sure that 'seq' is sorted
    val sortedSeq = seq.sortWith(_ < _)

    if (seq.size % 2 == 1) sortedSeq(sortedSeq.size / 2)
    else {
      val (up, down) = sortedSeq.splitAt(seq.size / 2)
      (up.last + down.head) / 2
    }
  }

  def factorize(x: Long): List[Long] = {
    def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {
      case false if x % a == 0 => foo(x / a, a    , a :: list)
      case false               => foo(x    , a + 1, list)
      case true                => x :: list
    }
    foo(x)
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """0 2 3 4 5""".stripMargin -> """1
                                     |
                                   |
                                   |""".stripMargin,
    """1 2 0 4 5""".stripMargin -> """3""".stripMargin
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 55276
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n,k;
  cin >> n >> k;
  vector<bool> snuke(n,false);
  rep(i,k){
    int d;
    cin >> d;
    rep(i,d){
      int a;
      cin >> a;
      snuke[a-1] = true;
    }
  }
  int cnt;
  rep(i,n){
    if(snuke[i] == false)cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CTravelingPlan solver = new CTravelingPlan();
        solver.solve(1, in, out);
        out.close();
    }

    static class CTravelingPlan {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] x = new int[n + 2];
            for (int i = 1; i <= n; i++) {
                x[i] = in.nextInt();
            }
            long sum = 0;
            for (int i = 0; i <= n; i++) {
                sum += Math.abs(x[i] - x[i + 1]);
            }

            for (int i = 1; i <= n; i++) {
                out.println(sum - Math.abs(x[i] - x[i - 1]) - Math.abs(x[i + 1] - x[i]) + Math.abs(x[i + 1] - x[i - 1]));
            }
        }

    }
}



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

const int N = 1e5 + 10;

int t[N], x[N], y[N];

int main(){
	int n, tt, xx, yy;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%d %d %d",&t[i],&x[i],&y[i]);
	t[0] = x[0] = y[0] = 0;
	for (int i = 1; i <= n; i++){
		tt = t[i] - t[i - 1]; xx = x[i] - x[i - 1]; yy = y[i] - y[i - 1];
		if (tt < abs(xx) + abs(yy) || (tt + abs(xx) + abs(yy)) % 2 != 0){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1408