akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define PI 3.14159265358979323846264338327950288419716939937510
#define mp make_pair
ll inf = 1e18;
ll p = 1e9 + 7;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
ll dp[1001][1001], u2[1001][1001];
char arr[1001][1001];
ll val[1001][1001];
ll  x2, y2, n, m;
void dfs (ll x, ll y, ll v)
{
    u2[x][y] = 1;
    val[x][y] = v;

    ll dx[4] = {1, -1, 0, 0};
    ll dy[4] = {0, 0, 1, -1};
    ll i, j;
    for (i = 0; i < 4; i++)
    {
        ll t1 = x + dx[i];
        ll t2 = y + dy[i];
        if (t1 >= 1 && t1 <= n && t2 >= 1 && t2 <= m)
        {
            if (arr[t1][t2] == '.' && u2[t1][t2] == 0)
                dfs(t1, t2, v);




        }

    }



}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, y, x,  z, w, g, key, l, t, k, n, m;
    ll a, b;
    ll t2, t3, t4, t1;

    string s;
    ll ctr;
    cin >> n >> m >> ctr;
    map<ll, ll>row, col, tr;
    ll rmax = 0, cmax = 0;
    vector<pair<ll, ll>>arr;
    for (i = 0; i < ctr; i++)
    {
        cin >> x >> y;
        arr.pb(mp(x, y));
        row[x]++;
        col[y]++;
        rmax = std::max(rmax, row[x]);
        cmax = std::max(cmax, col[y]);


    }
    vector<ll>r, c;
    for (i = 1; i <= n; i++)
    {
        if (row[i] == rmax)
            r.pb(i);
    }
    for (i = 1; i <= m; i++)
    {
        if (col[i] == cmax)
            c.pb(i);
    }
    for (i = 0; i < arr.size(); i++)
    {
        x = arr[i].fi;
        y = arr[i].se;
        if (row[x] == rmax && col[y] == cmax)
        {
            tr[x]++;
        }
    }
    ll flag = 0;
    for (auto u : r)
    {
        if (tr[u] != c.size())
        {
            flag = 1;
            break;
        }
    }
    ll ans = 0;
    if (flag)
    {
        ans = rmax + cmax;
    }
    else
        ans = rmax + cmax - 1;
    cout << ans;

}

Measured memory_bytes: 68720
N, M = map(int, input().split())
H = list(map(int, input().split()))
z = [0]*N
c = 0
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] < H[b-1]:
        z[a-1] += 1
    elif H[a-1] > H[b-1]:
        z[b-1] += 1
    else:
        z[a-1] += 1
        z[b-1] += 1
for i in range(N):
    if z[i] == 0:
        c += 1
print(c)

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

hs = 90 - (H * 30) - (30 * M / 60)
ms = 90 - M * 6

hs = math.pi * hs / 180
ms = math.pi * ms / 180

ax = A * math.cos(hs)
ay = A * math.sin(hs)

bx = B * math.cos(ms)
by = B * math.sin(ms)

dis = math.sqrt(pow(ax - bx, 2) + pow(ay - by, 2))
print(dis)


Measured memory_bytes: 9520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
  vector<string> day = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
  string s;
  cin >> s;
  rep(i,7) {
    if(s==day[i]){
      int ans = 6 - i;
      if(ans==0) cout << 7 << endl;
      else cout << ans << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }


int main() {
  int N; cin>>N;
  bool ans = true;
  vector<pair<ll, ll> > data(N);
  REP(i,N) {
    ll a, b; cin>>a>>b;
    data[i] = make_pair(b, a);
  }
  sort(data.begin(), data.end());
  ll sum = 0;
  REP(i,N) {
    sum += data[i].second;
    if(sum > data[i].first) {
      ans = false;
      break;
    }
  }
  YesNo(ans);
  return 0;
}


Measured memory_bytes: 3328
use superslice::Ext;
fn main() {
    proconio::input! {
        n: usize,
        ab: [(i32,i32);n],
    }
    let mut a: Vec<_>=ab.iter().map(|&(a,_)|a).collect();
    a.sort();
    let mut b: Vec<_>=ab.iter().map(|&(_,b)|b).collect();
    b.sort();
    if n&1==1 {
        let (s,e) = f(n/2, n, &a, &b);
        println!("{}",e-s+1);
    }
    else {
        let (s1,e1) = f(n/2-1, n, &a, &b);
        let (s2,e2) = f(n/2, n, &a, &b);
        println!("{}",(e1+e2)-(s1+s2)+1)
    }
}
fn f(k: usize, n: usize, a: &Vec<i32>, b: &Vec<i32>) -> (i32,i32) {
    let mut l=a[0]-1;
    let mut r=b[n-1]+1;
    while l+1<r {
        let m=(l+r)/2;
        let (x,y)=(b.lower_bound(&m),n-a.upper_bound(&m));
        let z=n-x-y;
        if x+z<=k {
            l=m;
        }
        else {
            r=m;
        }
    }
    let s=r;
    let mut l=a[0]-1;
    let mut r=b[n-1]+1;
    while l+1<r {
        let m=(l+r)/2;
        let (x,y)=(b.lower_bound(&m),n-a.upper_bound(&m));
        let z=n-x-y;
        if y+z<=n-1-k {
            r=m;
        }
        else {
            l=m;
        }
    }
    let e=l;
    (s,e)
}

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

using namespace std;
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    int a, b; cin >> a >> b;
    cout << (a-1)*(b-1);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a)cout<<k<<endl;
	else if(k<=a+b)cout<<a<<endl;
	else cout<<a-(k-a-b)<<endl;
	return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
const int N=405,mo=998244353;
int n,A[N],B[N],f[N][N],pp,sa,sb,i,j,k,l,inv[N],ans,C[N][N];
int main(){
	for(i=1;i<N;++i)inv[i]=i==1?1:1ll*(mo-mo/i)*inv[mo%i]%mo;
	for(i=**C=1;i<N;++i)for(j=*C[i]=1;j<=i;++j)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d%d",A+i,B+i),sa+=A[i],sb+=B[i];
	f[0][0]=1;
	for(i=1;i<=n;++i)for(j=sa;j>=A[i];--j)for(k=sb;k>=0;--k)for(l=0,pp=1;l<=k && l<B[i];++l)
		f[j][k]=(f[j][k]+mo-1ll*pp*C[k][l]%mo*f[j-A[i]][k-l]%mo)%mo,pp=1ll*pp*A[i]%mo;
	for(i=1;i<=sa;++i)
		for(j=0,k=1ll*inv[i]*sa%mo;j<=sb;++j)ans=(ans+1ll*k*f[i][j])%mo,k=1ll*inv[i]*k%mo;
	ans=(mo-ans)%mo;printf("%d\n",ans);
	return 0;
}

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

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int x;
  scanf("%d",&x);

  printf("%d\n",1-x);

  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,n1,max=0;
    cin>>n;
    string s;
    unordered_map<string,int>m;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        m[s]++;
    }
    cin>>n1;
    for(int i=0;i<n1;i++)
    {
        cin>>s;
        if(m.find(s)!=m.end())
        m[s]--;
    }
    for(auto x:m)
    {
        if(x.second>max)
        max=x.second;
    }
    if(max<=0)
        cout<<"0"<<endl;
    else
        cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int n,m; cin >> n >> m;
    vector<int> likeCnt(m,0);
    rep(i,n)
    {
        int k; cin >> k;
        rep(j,k) {
            int like; cin >> like;
            likeCnt[--like]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < m; i++)
    {
        if (likeCnt[i] == n)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;

    vector<int> p(n);
    rep(i, n) cin >> p.at(i);

    sort(p.begin(),p.end());

    int ans = 0;
    rep(i, k) ans += p.at(i);
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
using P = pair<int, int>;
using PP = pair<int, P>;
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define rep0(i,n) for (int i=0; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#ifdef _DEBUG
string _format(string args) { string r = "", t; istringstream s(args); while (getline(s, t, ',')) r += t+":%ld "; return r + "\n"; }
#define debug(...) do { printf(_format(#__VA_ARGS__).c_str(), __VA_ARGS__); } while(0)
#define fast_ios() do {} while(0);
#else //_DEBUG
#define debug(...) do {} while(0)
#define fast_ios() do { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } while(0)
#endif //_DEBUG

int main() {
    fast_ios();

    int n, x, y;
    cin >> n >> x >> y;

    int dp[n+1];
    rep1(i,n+1) dp[i] = 0;
    rep1(i,n) {
        for(int j=i+1;j<=n;j++) {
            int k = min(j-i, abs(y-j)+abs(x-i)+1);
            dp[k]++;
        }
    }

    rep1(i,n-1) { cout << dp[i] << endl; }

}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define int long long
#define rep(a,b) for(int (a)=0; (a)<(int)(b); ++(a))
using namespace std;

constexpr int MOD=1000000007;

signed main(void){
  int N; cin>>N;
  map<int,int> A;
  rep(i,N){
    int ta; cin>>ta;
    ++A[ta];
  }
  bool able=true;
  int ans=0;
  if(N%2){
    able&=A[0]==1;
    for(int i=2;i<N;i+=2){
      able&=A[i]==2;
    }
    if(able){
      ans=1;
      rep(i,N/2){
        ans=ans*2%MOD;
      }
    }
  }
  else{
    for(int i=1;i<N;i+=2){
      able&=A[i]==2;
    }
    if(able){
      ans=1;
      rep(i,N/2){
        ans=ans*2%MOD;
      }
    }
  }
  cout<<ans;
}

Measured memory_bytes: 5376
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

int dp[1010][1010] = {};



/*----------------------------------------------------------------*/
signed main(){

    int q;
	cin >> q;
	rep(iii,q){
		string s,t;
		cin >> s >> t;
		int sl = s.size();
		int tl = t.size();
		rep(i,sl)rep(j,tl)dp[i][j] = 0;
		rep(i,sl){
			rep(j,tl){
				if(s[i] == t[j]){
					dp[i+1][j+1] = dp[i][j]+1;
				}else{
					dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
				}
			}
		}
		cout << dp[sl][tl] << endl;
	}
	
	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc088.contest.atcoder.jp/tasks/abc088_d


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll X, Y, Z;
    cin >> X >> Y >> Z;

    cout << (X-Z)/(Y+Z) << endl;
    return 0;
}

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

int main(){

    int a,b,c,ans;
    cin >> a >> b>>c;
    if (a >= b) {
        if (a >= c) {
            ans = b + c;
        }
    }
    if (b >= c) {
        if (b >= a) {
            ans = c + a;
        }
    }
    if (c >= a) {
        if (c >= b) {
            ans = a + b;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	int[][] board;
	int d, M, N, S;
	int[][] matrix;

	void run(){
		Scanner in = new Scanner(System.in);
		for(;;){
			M = in.nextInt();
			N = in.nextInt();
			d = in.nextInt();
			if(M==0 && N==0 && d==0) return ;
			board = new int[N][M];
			for(int i=0; i<N; i++){
				for(int j=0; j<M; j++){
					board[i][j] = in.nextInt();
				}
			}
			System.out.println(solve()?1:0);
		}
	}

	void setMatrix(){
		S = M*N;
		matrix = new int[S][S+1];
		for(int i=0; i<N; i++){
			for(int j=0; j<M; j++){
				if(board[i][j] == 1){
					matrix[i*M+j][S] = 1;
				}
			}
		}

		for(int i=0; i<N; i++){
			for(int j=0; j<M; j++){
				matrix[i*M+j][i*M+j] = 1;
				for(int k=0; k<=d; k++){
					for(int l=0; l<4; l++){
						int ny = i + ((l&1)==1?k:-k),
							nx = j + (((l>>1)&1)==1?d-k:k-d);
						if(0<=ny && ny<N && 0<=nx && nx<M){
							matrix[ny*M+nx][i*M+j] = 1;
						}
					}
				}
			}
		}

	}

	boolean solve(){
		setMatrix();
		for(int i=0; i<S; i++){
			boolean found = false;
			int key = -1;
			for(int k=i; k<S; k++){
				if(matrix[k][i] == 1){
					found = true;
					key = k;
					break;
				}
			}
			if(found){
				int[] tmp = matrix[i].clone();
				matrix[i] = matrix[key].clone();
				matrix[key] = tmp;
				for(int k=i+1; k<S; k++)if(matrix[k][i] == 1){
					for(int j=i; j<=S; j++){
						matrix[k][j] ^= matrix[i][j];
					}
				}
			}
		}
		
		for(int i=S-1; i>=0; i--){
			if(matrix[i][i] == 1){
				for(int k=i-1; k>=0; k--)if(matrix[k][i] == 1){
					for(int j=S; j>=i; j--){
						matrix[k][j] ^= matrix[i][j];
					}
				}
			}
		}
		
		for(int i=0; i<S; i++){
			if(matrix[i][i] == 0 && matrix[i][S] == 1){
				return false;
			}
		}
		return true;
	}

	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 18000
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int cal[MAXN];
char S[MAXN];
bool pos[MAXN];

int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n>>m;

    fill(cal,cal+n+1,1);

    pos[1] = true;

    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        if(pos[x])pos[y] = true;
        cal[x]--;
        if(!cal[x])pos[x] = false;
        cal[y]++;
    }

    for(int i=1;i<=n;i++)
        if(pos[i])cnt++;

    cout<<cnt<<"\n";

    return 0;
}


Measured memory_bytes: 768
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long [] X = new long[N];
		ArrayList<Long> list = new ArrayList<Long>();
		for(int i=0;i<N;i++){
			X[i] = sc.nextLong();
			list.add(X[i]);
		}
		Collections.sort(list);
		long ans1,ans2;
		ans1 = list.get(N/2-1);
		ans2 = list.get(N/2);
		for(int i=0;i<N;i++){
			if(X[i]<=ans1)
				System.out.println(ans2);
			else
				System.out.println(ans1);
		}
	}
}


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

vector<int> graph[201000];

int main(){
    int n,m;
    bool flag = false;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        graph[a].push_back(b);
    }
    for(int i=0;i<graph[1].size();i++){
        int temp =graph[1][i];
        for(int j=0;j<graph[temp].size();j++){
            if(graph[temp][j]==n){flag = true;
            break;
            }
        }
    }
if(flag == true)cout << "POSSIBLE" <<endl;
else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 8576
import math
class RangeMinimumQuery:
    """
    RangeMinimumQuery by Segment Tree
    query:
    1. update(i, val): update i-th value to val
    2. query(low, high): find minimun value in [low, high)
    time complexity: O(log n)
    space complexity: O(2n)    
    """
    def __init__(self, N, INF=float('inf')):
        self.N = 1 << math.ceil(math.log(N, 2))
        self.INF = INF
        self.segtree = [self.INF] * (self.N * 2 - 1)

    def update(self, i, val):
        i += self.N - 1
        self.segtree[i] = val
        while i > 0:
            i = (i - 1) // 2
            self.segtree[i] = min(self.segtree[2*i+1], self.segtree[2*i+2])

    def query(self, low, high, k=0, left=0, right=-1):
        if right == -1: right = self.N
        if right <= low or high <= left: return self.INF

        if low <= left and right <= high:
            return self.segtree[k]
        else:
            mid = (left + right) // 2
            return min(self.query(low, high, 2*k+1, left, mid), 
                       self.query(low, high, 2*k+2, mid, right))

N, Q = map(int, input().split())
rmq = RangeMinimumQuery(N, INF=(1<<31)-1)
for _ in range(Q):
    com, x, y = map(int, input().split())
    if com == 0:
        rmq.update(x, y)
    elif com == 1:
        print(rmq.query(x, y+1))

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

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

const int INF = 1e9 + 7;

using namespace std;

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

	int d;
	cin >> d;

	if (d == 22)
		cout << "Christmas Eve Eve Eve" << endl;
	else if (d == 23)
		cout << "Christmas Eve Eve" << endl;
	else if (d == 24)
		cout << "Christmas Eve" << endl;
	else
		cout << "Christmas" << endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}

void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    go();
    return 0;
}
/****************ackun*********************/
const int MAXN=1e5+10;
int a[MAXN];
int bl[MAXN],br[MAXN];
void go(){
    int n;
    R(n);
    rep(i,1,n){
        R(a[i]);
    }
    bl[1]=a[1];
    rep(i,2,n){
        bl[i]=__gcd(bl[i-1],a[i]);
    }
    br[n]=a[n];
    per(i,n-1,1){
        br[i]=__gcd(br[i+1],a[i]);
    }
    int ans=max(bl[n-1],br[2]);
    rep(i,2,n-1){
        ans=max(ans,__gcd(bl[i-1],br[i+1]));
    }
    W(ans);
}


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

int main()
{
  int n;
  cin >> n;
  int i;
  vector<int> a(n);
  int ans = 0;
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i);
    while(a.at(i)%2==0)
    {
      a.at(i) /= 2;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		System.out.println((int)Math.pow(Integer.parseInt(br.readLine()),3));
	}
}


Measured memory_bytes: 20692
#include <stdio.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

long long n, x;
long long a[100005];
long long ans = 0;

int main()
{
    scanf("%lld %lld", &n, &x);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }

    for (int i = 1; i < n; i++) {
        if (a[i] + a[i - 1] > x) {
            ans += (a[i] + a[i - 1]) - x;
            a[i] -= min(a[i], (a[i] + a[i - 1]) - x);
            a[i - 1] -= min(a[i - 1], (a[i] + a[i - 1]) - x);
        }
    }

    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

template<class Type>
Type gcd(Type x,Type y){
	return (x%y)?gcd(y,x%y):y;
}

int main(){
	int x,y;
	cin >> x >> y;
	cout << gcd(x,y) << endl;
}


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

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

    ll tot = 0;
    rep(i,n+1) {
        if (i %3 != 0 && i %5 != 0) tot += i;
    }
    cout << tot << endl;
    return 0;
}


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

int main(){
    int a,b; cin>>a>>b;
    string s=to_string(a)+to_string(b);
    int c=atoi(s.c_str());
    for(int i=1;i<=10000;i++){
        if(i*i==c){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
s = input()
n = len(s)
zero = 0
one = 0
for i in range(n):
    if s[i] == "0":
        zero += 1
    else:
        one += 1

if one != 0 or zero != 0:
    print(2 * min(zero,one))
else:
    print(0) 

Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  Scanner sc;

  void run() {
    int n = ni();
    for ( int i = 0; i < n; ++i ) {
      L = 0;

      String str = sc.next();
      Pair<Node, Integer> p = make( str.toCharArray(), 0, 0 );
      cal( p.f, 0 );

      System.out.println( p.f.v );
    }
  }

  class Pair<T, U> {
    T f;
    U s;

    Pair(T t, U u) {
      f = t;
      s = u;
    }
  }

  class Node {
    int v;
    LinkedList<Node> children;

    Node() {
      children = new LinkedList<Node>();
    }

    void add(Node node) {
      children.add( node );
    }
  }

  void cal(Node node, int depth) {
//    debug(depth, L);
    if ( depth == L - 2 ) {
//      debug("\tb:", node.v);
      node.v = node.children.getFirst().v;
//      debug("\tb:", node.v);
    } else if ( depth == L - 3 ) {
      ArrayList<Integer> list = new ArrayList<Integer>();
      for ( Node ch : node.children ) {
        cal(ch, depth + 1);
        list.add( ( ch.v + 1 ) / 2 );
      }
      Collections.sort( list );
      int sum = 0;
      for ( int i = 0; i < ( list.size() + 1 ) / 2; ++i ) {
        sum += list.get( i );
      }
      node.v = sum;
    } else {
      ArrayList<Integer> list = new ArrayList<Integer>();
      for ( Node ch : node.children ) {
        cal(ch, depth + 1);
        list.add( ch.v );
      }
      Collections.sort( list );
      int sum = 0;
      for ( int i = 0; i < ( list.size() + 1 ) / 2; ++i ) {
        sum += list.get( i );
      }
      node.v = sum;
    }
  }

  int L;

  Pair<Node, Integer> make(char[] str, int idx, int depth) {
    L = Math.max( L, depth + 1 );

    Node node = new Node();

    if ( str[ idx ] == '[' ) {
      while (str[ ++idx ] != ']') {
        Pair<Node, Integer> p = make( str, idx, depth + 1 );
        node.add( p.f );
        idx = p.s;
      }
    } else {
      // numecal
      ArrayList<Character> list = new ArrayList<Character>();
      while (str[ idx ] != ']') {
        list.add( str[ idx++ ] );
      }
      --idx;
      int len = list.size();
      char[] nums = new char[len];
      for ( int i = 0; i < len; ++i ) {
        nums[ i ] = list.get( i );
      }
      node.v = Integer.parseInt( new String( nums ) );
    }

    return new Pair<Node, Integer>( node, idx );
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }

}

Measured memory_bytes: 80952
h, w = gets.split.map(&:to_i)

DIRS_X = [0, 1, 0, -1]
DIRS_Y = [-1, 0, 1, 0]

Node = Struct.new('Node', :cost, :y, :x)

nodes = []

h.times do
  nodes << gets.chomp.chars
end

start_pos = []
nodes.each_with_index do |rows, y|
  rows.each_with_index do |c, x|
    start_pos << [y, x] if c == '.'
  end
end

max_cost = -1
cnt = 0
start_pos.each do |start_y, start_x|
  costs = Array.new(h).map { Array.new(w, -1) }
  costs[start_y][start_x] = 0
  queue = [Node.new(0, start_y, start_x)]

  while !queue.empty?
    node = queue.shift
    y = node.y
    x = node.x
    # p [y, x, node.cost]
    4.times do |i|
      ny = y + DIRS_Y[i]
      nx = x + DIRS_X[i]
      next if ny < 0 || ny >= h || nx < 0 || nx >= w
      next if costs[ny][nx] != -1 || nodes[ny][nx] != '.'
      queue.push(Node.new(node.cost + 1, ny, nx))
      costs[ny][nx] = node.cost + 1
    end
  end
  max_cost = [max_cost, costs.flatten.max].max
end
puts [max_cost, 0].max

Measured memory_bytes: 2172
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main
{

  public static void main(String[] args)
  {
    try (Scanner scanner = new Scanner(System.in))
    {
      while (scanner.hasNextLine())
      {
        int n = Integer.valueOf(scanner.nextLine());
        int[] data = new int[n];
        for (int i = 0; i < n; i++)
        {
          data[i] = Integer.valueOf(scanner.nextLine());
        }
        solver(data);
      }
    }
  }

  private static void solver(int[] data)
  {
    Arrays.sort(data);

    List<Integer> ansList = new ArrayList<>();
    for (int i = 0; i < 4; i++)
    {
      for (int j = 0; j < 4; j++)
      {
        if (i == j)
        {
          continue;
        }
        ansList.add(Integer.valueOf(String.valueOf(data[i]) + String.valueOf(data[j])));
      }
    }

    ansList.sort(null);
    System.out.println(ansList.get(2));
  }

}



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

#define FOR(i, a, b) for (int (i) = (a); (i) < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cerr << #x << " " << x << endl
#define eb emplace_back
#define _ << " " <<
typedef long long ll;
typedef std::pair<int, int> ii;
#define X first
#define Y second
#define double long double
typedef double db;
using namespace std;

const int MaxN = 200100;
const int Mod = 1e9 + 7;

int N;
ll pref[MaxN];
int a[MaxN];
map <ll, int> M;

ll binom (ll A) {
  return A * (A - 1) / 2;
}

void solve(){
  REP(i, N + 1) M[pref[i]]++;

  ll cnt = 0;

  for (auto x: M) {
    cnt += binom(x.second);
  }

  cout << cnt << endl;
}

void load(){
  scanf("%d", &N);
  REP(i, N) scanf("%d", a + i);
  pref[0] = 0;
  REP(i, N) pref[i + 1] = pref[i] + a[i];
}

int main(){
//  ios_base::sync_with_stdio(false);
  load();	
  solve();
  return 0;
}



Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pp pop_back
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f0(i,a,n) for(i=a;i<n;i++)
#define f1(I,a,b) for(i=a;i<=b;i++)
#define stp setprecision
#define nl endl
#define ipt(a) for(i=0;i<n;i++)cin>>a[i];
#define pll pair<ll,ll>
#define vl vector<ll>
#define mp map<ll,ll>
int main()
{
    fast;
    ll n,i,j;
    cin>>n;
    ll c=0,s=0;
    for(i=1;i<=n-1;i++)
    {
        if(n%i)
        s+=n/i;
        else
        s+=n/i-1;
    }
    cout<<s;
}

Measured memory_bytes: 3628
'use strict'
function Main(input) {
  input = input.split("\n")
  let N = parseInt(input[0])
  let res = 'No'
  if (N % 7 === 0) {
    console.log('Yes')
    return
  }
  while (N > 0) {
    if (N % 4 === 0) {
      res = 'Yes'
      break
    }
    N -= 7
  }
  console.log(res)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

int n;
void dfs(string s,char mx){
  if(s.size() == n){
    cout << s << endl;
    return ;
  }
  for(char c = 'a';c <= mx;c++){
    if(c == mx)dfs(s+c,mx+1);
    else dfs(s+c,mx);
  }
}

int main(){

  cin >> n;
  dfs("a",'b');
  
  




  return 0;
}

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

int main(){
  long long n, k;
  cin >> n >> k;
  int a, b;
  vector<pair<int, int> > v;
  for ( int i = 0; i < n; i++){
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }

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

  long long cnt = 0;
  for ( int i = 0; i < v.size(); i++){
    cnt += v[i].second;
    if ( cnt >= k){
      cout << v[i].first << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 1400
n,k=map(int,input().split())

if k%2==0:
    half=0
    zero=0
    i=1
    for i in range(1,n+1):
        if i%k==0:
            zero+=1
        if i%k==k/2:
            half+=1
    print(half**3 + zero**3)
else:
    zero=0
    i=1
    for i in range(1,n+1):
        if i%k==0:
            zero+=1
    print(zero**3)

Measured memory_bytes: 38896
class DataConv
    @handler
    @enddata
    @state

    def initialize
        @state = 0
    end

    def main
        while input = gets
            input.chomp!
            if @state == 0
                # 終了条件
                if input.to_i == 0
                    exit
                end
                @inputdata = InputData.new

                @inputdata.initEndData(input)
            end

            if @state == 1
                # addConvHash
                input_array = input.split
                @inputdata.addConvertList(input_array[0], input_array[1])
            end

            if @state == 2
                @inputdata.initEndData(input)
            end

            if @state == 3
                print @inputdata.getConvertResult(input)
            end

            @state = @inputdata.tranState(input, @state)
        end
    end
end

class InputData
    @conv_list_end
    @conv_hash
    @enddata
    def initialize
        @enddata = EndData.new(0)
        @conv_hash = Hash.new
    end

    def initEndData(input)
        @enddata.init(input.to_i)
    end

    def tranState(input, state)
        if state == 0 or state == 2
            return state + 1
        end

        # 0になったら進める
        @enddata.decrementFlag

        if @enddata.getFlag == 0
            if state == 3
                print "\n"
                return 0
            end
            return state + 1
        end

        # そのまま
        return state
    end

    def addConvertList(before, after)
        @conv_hash[before] = after
    end

    def getConvertResult(before)
        if @conv_hash.has_key?(before)
            return @conv_hash[before]
        end
        return before
    end
end

class EndData
    @end_flag
    def initialize(flag)
        @end_flag = flag
    end

    def init(flag)
        @end_flag = flag
    end

    def decrementFlag
        @end_flag = @end_flag - 1
    end

    def getFlag
        return @end_flag
    end
end

DataConv.new.main

Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string sa,sb,sc;
    cin >> sa >> sb >> sc;
    int ia = 0, ib = 0, ic = 0;
    int next = 0;
    while(true){
        if(next == 0){
            if(ia == sa.size()){
                cout << "A" << endl;
                break;
            }
            if(sa[ia] == 'a'){
                next = 0;
            }else if(sa[ia] == 'b'){
                next = 1;
            }else{
                next = 2;
            }
            ia++;
        }else if(next == 1){
            if(ib == sb.size()){
                cout << "B" << endl;
                break;
            }
            if(sb[ib] == 'a'){
                next = 0;
            }else if(sb[ib] == 'b'){
                next = 1;
            }else{
                next = 2;
            }
            ib++;
        }else{
            if(ic == sc.size()){
                cout << "C" << endl;
                break;
            }
            if(sc[ic] == 'a'){
                next = 0;
            }else if(sc[ic] == 'b'){
                next = 1;
            }else{
                next = 2;
            }
            ic++;
        }
    }
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var dp = new long[N + 10];
            dp[0] = 0;

            for (var i = 1; i < N; i++)
            {
                if (i == 1)
                    dp[i] = Math.Abs(h[i]-h[i-1]);
                else
                    dp[i] = Math.Min(dp[i - 1] + Math.Abs(h[i]-h[i-1]), dp[i - 2] + Math.Abs(h[i]-h[i-2]));
            }

            Console.WriteLine(dp[N - 1]);
        }
    }
}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int A, B, C;
  std::cin >> A >> B >> C;
  std::cout << (std::max(0, C + B - A)) << '\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

template <typename T>
struct min_ {
    T operator()(T x, T y) {
        return min(x, y);
    }
};

template <typename T, class F=min_<T>>
struct SegmentTree {
    size_t n;
    T e;
    vector<T> tree;
    F qfunc;
    SegmentTree(size_t m, T e=0): n(1), e(e) {
        qfunc = F();
        while (n < m) n <<= 1;
        tree = vector<T>(n<<1, e);
    }
    T range_query(size_t a, size_t b, size_t i=1, size_t l=0, size_t r=-1) {
        if (!~r) r = n;
        if (a<=l && r<=b) return tree[i];

        T vl=e, vr=e;
        size_t c=(l+r)>>1;

        if (a < c) vl=qfunc(e, range_query(a, b, i<<1|0, l, c));
        if (c < b) vr=qfunc(e, range_query(a, b, i<<1|1, c, r));

        return qfunc(vl, vr);
    }
    void update(size_t i, T x) {
//        i += n;
//        tree[i] = x;
//        while (i>>1) {
//            tree[i>>1] = qfunc(tree[i^1], tree[i]);
//            i >>= 1;
//        }
        i += n;
        tree[i] = x;
        while (i>>=1)
            tree[i] = qfunc(tree[i<<1], tree[i<<1|1]);
    }
};

int main() {
    size_t n, q;
    scanf("%zu %zu", &n, &q);

    SegmentTree<int> tree(n, (1LL<<31)-1);
    for (size_t i=0; i<q; ++i) {
        int com;
        scanf("%d", &com);
        if (com) {
            size_t s, t;
            scanf("%zu %zu", &s, &t);
            printf("%d\n", tree.range_query(s, t+1));
        } else {
            size_t i;
            int x;
            scanf("%zu %d", &i, &x);
            tree.update(i, x);
        }
    }

    return 0;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
int d[1000005];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

int n;
cin>>n;

memset(d,0,sizeof(d));

for(int i=1;i<=n;i++)
{
   for(int j=i;j<=n;j+=i)
   d[j]++;
}

int ans=0;


for(int i=1;i<n;i++)
{
  ans+=d[n-i];
}

cout<<ans<<endl;

return 0;
}



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

int main(void){
  long int X, Y, cnt, max_cnt = 0;
  cin >> X >> Y;
  long int a[100];
    a[0] = X;
    for(int j = 1; j < 100; j++){
      a[j] = 2*a[j - 1];
      if(a[j] > Y){
        cnt = j;
        break;
      }
    }
    if(max_cnt < cnt) max_cnt = cnt;
  cout << max_cnt << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

struct BIT {
    BIT(int n) : s(n + 1), n(n) {}
    int sum(int k) {
        int r = 0;
        for (; k > 0; k -= k & -k) r += s[k];
        return r;
    }
    void add(int i, int v) {
        for (int k = i + 1; k <= n; k += k & -k) s[k] += v;
    }
    vector<int> s;
    int n;
};

struct Line {
    bool operator<(const Line& l) {
        return t < l.t;
    }
    double t, r;
    int16_t a, b, c;
    uint16_t j;
};

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

    int n;
    cin >> n;

    vector<Line> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i].a >> l[i].b >> l[i].c;
    }

    BIT b(n);
    int m = (n - 1) * n / 2;
    int h = (m + 1) / 2;

    for (int u = 0; u < 2; u++) {
        for (int i = 0; i < n; i++) {
            l[i].t = (double)l[i].a / l[i].b;
        }
        sort(l.begin(), l.end());

        for (int i = 0; i < n; i++) {
            l[i].r = 1.0 / l[i].b;
            l[i].j = i;
        }

        double x, x1 = 2e+8, x0 = -x1;
        while (1) {
            x = (x0 + x1) * 0.5;
            if (x1 - x0 < 1.6e-9 * max(abs(x), 1.0)) break;

            for (int i = 0; i < n; i++) {
                l[i].t = (l[i].c - l[i].a * x) * l[i].r;
            }
            sort(l.begin(), l.end());

            fill(b.s.begin(), b.s.end(), 0);

            int k = m;
            for (int i = 0; i < n; i++) {
                int j = l[i].j;
                k -= b.sum(j);
                b.add(j, 1);
            }
            if (k < h) x0 = x; else x1 = x;
        }

        cout << fixed << setprecision(12) << x << " \n"[u];

        if (u == 1) break;

        for (int i = 0; i < n; i++) {
            swap(l[i].a, l[i].b);
        }
    }

    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
// 104, 79, 
// 169, 133, 
// 180, 106, 
// 171, 42, 
// 45, 76, 
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	long long ks=1;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		printf("? %d %d %d %d\n",i,j,i,j);
		fflush(stdout);
		int t;
		scanf("%d",&t);
		if(t)ret=(ret+ks)%d;
		ks=ks*2%d;
	}
	int sz=ret/40000%200;
	char *p = new char[sz*1000000];
	for(int i=0;i<sz*1000000;i++)p[i]='e';
	printf("! %lld\n",ret);
}

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (x, y) = [int(e) for e in lines[0].split(' ')]

    return (x, y)


def solve(x, y):
    
    result = 'No'
    for c in range(0, 101):
        for t in range(0, 101):
            if c + t == x and 2 * c + 4 * t == y:
                result = 'Yes'
                break
                


    return result    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 63136
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

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

    if ((a == b && a != c) || (a == c && a != b) || (b == c && b != a)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    

    return 0;
}

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

int main() {
    cin >> n;
    map<string, int> memo;
    for(int i = 0; i < n; ++i) {
        string ins;
        cin >> ins;
        memo[ins] += 1;
    }

    int maxv = 0;
    for(const auto& x:memo) {
        int v = x.second;
        maxv = max(maxv, v);
    }

    for(auto it = memo.begin(); it != memo.end(); it++) {
        if(it->second == maxv) {
            cout << it->first << endl;
        }
    }
}

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

int main(int argc, char const* argv[])
{
	int h, m, s, S;
	cin >> S;
	h = S/(60*60);
	m = (S%(60*60)) / 60;
	s = (S%(60*60)) % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


Measured memory_bytes: 1164
#include<stdio.h>

int main(){
  int n, i, j, count, output;
  count = 0;

  scanf("%d", &n);

  for(i = 1; i <= n; i += 2){
    for(j = 1; j <= i; j++){
      if(i % j == 0){
	count++;
      }
    }
    if(count == 8){
      output++;
    }
    count = 0;
  }


  printf("%d\n", output);

  return 0;
}


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int n , a[ N ][ 5 ];
int dp[ N ][ 5 ];

int solve( int idx , int last ) {
        if( idx > n ) return 0;
        if( dp[idx][last] != -1 ) return dp[idx][last];
        int ret = -inf;
        for( int i = 1; i <= 3; i++ ) {
                if( i != last ) ret = max( ret , solve( idx + 1 , i ) + a[idx][i] );
        }
        return dp[idx][last] = ret;
}
int main( ) {
        IO;
        #ifdef LOCAL
            freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        cin >> n;
        for( int i = 1; i <= n; i++ ) {
                for( int j = 1; j <= 3; j++ ) {
                      cin >> a[i][j];
                }
        }
        memset( dp , -1 , sizeof( dp ) );
        int ans = -inf;
        for( int i = 1; i <= 3; i++ ) {
                ans = max( ans , a[1][i] + solve( 2 , i ) );
        }
        cout << ans << endl;
        return 0;
}






Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define REP(i,N) for(int i = 0; i < (int)N; i++)


int main(){
	string s;
	cin >> s;
	reverse(s.begin(),s.end());
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 2996
n,m,*a=map(int,open(0).read().split())
d=[0]*n*9
for i in range(n):
 for j in a:
  if d[i]or i<1:c=i+(0,2,5,5,4,5,6,3,7,6)[j];d[c]=max(d[c],d[i]*10+j)
print(d[n])

Measured memory_bytes: 15332
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll ret=pow(x,y/2);
  ret%=mod;
  ret*=ret;
  ret%=mod;
  if(y%2==1) ret*=x;
  return ret%mod;
}
int main(){
  int array[2000]={0};
  int n;
  cin>>n;
  int ans=0;
  for(int i=0;i<n;i++) cin>>array[i];
  for(int i=1;i<n-1;i++){
    if(array[i-1]<array[i]&&array[i]<array[i+1]) ans++;
    if(array[i+1]<array[i]&&array[i]<array[i-1]) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,k;
    cin>>n>>k;
    n++;
    int ans=0;
    REP(i,k,n){
        int a=i*(i-1)/2;
        int b=(2*n-i-1)*i/2;
        ans=(ans+b-a+1)%mod;
    }
    cout<<ans<<endl;
}

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

int main(){
	int n;
	vector<int> array;
	for(int i=0; i<10; i++){
		cin >> n;
		array.push_back(n);
	}
	sort(array.begin(), array.end(), greater<int>() );
	for(int i=0; i<3; i++){
		cout << array[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1216