akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main(void) {
	int n,b;
	int a[3][3] = {{}};

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> a[i][j];
		}
	}

	cin >> n;

	for (int k = 0; k < n; k++)
	{
		cin >> b;

		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				if (a[i][j] == b)
				{
					a[i][j] = 0;
				}				
			}
		}
	}

	if (a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0) cout << "Yes" << endl;
	else if (a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0) cout << "Yes" << endl;
	else if (a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0) cout << "Yes" << endl;
	else if (a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0) cout << "Yes" << endl;
	else if (a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0) cout << "Yes" << endl;
	else if (a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0) cout << "Yes" << endl;
	else if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) cout << "Yes" << endl;
	else if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) cout << "Yes" << endl;
	else cout << "No" <<endl;

	return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll a, b, c; cin >> a >> b >> c;
  if(c - a - b < 0) {
    cout << "No" << endl;
    return 0;
  }

  if(a == 0 || b == 0) {
    cout << "Yes" << endl;
    return 0;
  }

  if(4 * a*b < (c - a - b) * (c - a - b)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


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

int main() {
	int A,B,C;
	cin>>A>>B>>C;
	int H=0; //hanteisuru
	for (int i = 0; i < 100000; i++) {
  if((A*(i+1)-C)%B==0)
  {
  	H+=1;
  }
}
if(H==0)
{
	cout<<"NO"<<endl;
}
else{
	cout<<"YES"<<endl;
}

	return 0;
}

Measured memory_bytes: 256
/*
  AUTHOR:SOURABH
  CREATED:13:09:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAXN 10000001
#define M 32

using namespace std;
using namespace __gnu_pbds;

ll modex(ll x,ll y)
{
    x=x%mod;
    ll r=1;
    while(y>0)
    {
        if(y%2==1)
            r=(r*x)%mod;
        y/=2;
        x=(x*x)%mod;
    }
    return r;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,i,l,r,c;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n;
        vll a(n),b(n);
        fn(i,n)
        cin>>a[i];
        fn(i,n)
        cin>>b[i];
        reverse(b.begin(),b.end());
        l=n,r=-1;
        fn(i,n)
        {
            if(a[i]==b[i])
            {l=i;c=a[i];break;}
        }
        fr(i,n-1)
        {
            if(a[i]==b[i])
            {r=i;c=a[i];break;}
        }
        fn(i,n)
        {
            if(l>r)
            break;

            if(a[i]!=c && b[i]!=c)
                swap(b[i],b[l++]);
        }
        if(l<=r)
            cout<<"No\n";
        else
        {
            cout<<"Yes\n";
            fn(i,n)
            cout<<b[i]<<" ";
            cout<<"\n";
        }
    }

}


Measured memory_bytes: 6368
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int W;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> W;
    int ans = W * 32;
    cout << ans << endl;
}


Measured memory_bytes: 3208
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

bool is_prime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

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

    int x;
    cin >> x;

    while (true) {
        if (is_prime(x)) {
            cout << x << '\n';
            return 0;
        } else {
            x++;
        }
    }

    return 0;
}

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

int gcd(int x, int y)
{
	int tmp;

	if (y > x)
	{
		tmp = x;
		x = y;
		y = tmp;
	}

	if (y == 0)
		return x;
	else
		return gcd(y, x % y);
}

int main()
{
	int x, y;

	scanf("%d%d", &x, &y);

	printf("%d\n", gcd(x, y));
}


Measured memory_bytes: 2132
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def naive(N, X, M):
    ans = X
    ans_prev = X
    for i in range(2, N + 1):
        an1 = ans_prev % M
        an1 = pow(an1, 2, M)
        ans += an1
        ans_prev = an1
    return ans

def doubling(N, X, M):
    ans = X
    ans_prev = X
    A = [X]
    computed = set({})

    for i in range(2, N + 1):
        an1 = ans_prev % M
        an1 = pow(an1, 2, M)
        if an1 in computed:
            breakA = an1
            break
        A.append(an1)
        computed.add(an1)
        ans_prev = an1

    # if break
    num_break = len(A)
    index = A.index(breakA)
    num_length = len(A) - index
    total = sum(A[:index])
    repeat_length = (N - index) // num_length
    remain_length = (N - index) % num_length
    total_sub = sum(A[index:]) * repeat_length
    total += total_sub
    if remain_length > 0:
        sub = naive(remain_length, breakA, M)
        total += sub    
    return total


def solve(N, X, M):
    return -1

def main():
    from builtins import int, map
    N, X, M = map(int, input().split())

    if N < 10 ** 7:
        print(naive(N, X, M))
    else:
        print(doubling(N, X, M))
        # print(naive(N, X, M))

if __name__ == '__main__':
    main()


Measured memory_bytes: 78008
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;

int main(){
	//scanf("%d",&t);
	while(t--){
		int n,m,c;
		cin>>n>>m>>c;
		vector<int>b(m);
		for(int i=0;i<m;i++){
			cin>>b[i];
		}
		int ans=0,count=0;
		for(int i=0;i<n;i++){
			ans=c;
			for(int j=0;j<m;j++){
				int a;
				cin>>a;
				ans+=(a*b[j]);
			}
			if(ans>0){
				count++;
			}
		}
		cout<<count<<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int i,c0,c1,c2,c3,N;
  char S[3];
  c0=c1=c2=c3=0;
  scanf("%d",&N);
  for(i=0;i<N;++i){

      scanf("%s",S);
    
      if(strcmp(S,"AC")==0){
        c0+=1;
      }
      else if(strcmp(S,"WA")==0){
        c1+=1;
      }
      else if(strcmp(S,"TLE")==0){
        c2+=1;
      }
      else {

        c3+=1;
      }
  }
  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",c0,c1,c2,c3);
}


Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int r = Integer.parseInt(sc.next());
        int ans;

        ans = r * r;

        // 出力
        System.out.println(Integer.toString(ans));
    }
}


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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

int A, B, C;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> A >> B >> C;
    if (A + B + C >= 22) cout << "bust";
    else cout << "win";
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


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


void solve(ll X, ll Y, ll A, ll B, ll C, vector<ll> p, vector<ll> q, vector<ll> r)
{
    priority_queue<ll,vector<ll>,greater<ll>> heap;
    sort(p.begin(),p.end(),greater<ll>());
    sort(q.begin(),q.end(),greater<ll>());
    for(int i=0;i<X;++i)
    {
        heap.push(p[i]);
    }
    for(int i=0;i<Y;++i)
    {
        heap.push(q[i]);
    }
    for(ll x:r)
    {
        ll front = heap.top();
        if(front < x)
        {
            heap.pop();
            heap.push(x);
        }
    }
    ll sum = 0;
    while(!heap.empty())
    {
        sum += heap.top();
        heap.pop();
    }
    cout<<sum<<endl;
}


int main()
{
    ll X;
    cin >> X;
    ll Y;
    cin >> Y;
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    ll C;
    cin >> C;
    vector<ll> p(A);
    for(int i = 0 ; i < A ; i++)
    {
        cin >> p[i];
    }
    vector<ll> q(B);
    for(int i = 0 ; i < B ; i++)
    {
        cin >> q[i];
    }
    vector<ll> r(C);
    for(int i = 0 ; i < C ; i++)
    {
        cin >> r[i];
    }
    solve(X, Y, A, B, C, move(p), move(q), move(r));
    return 0;
}


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

#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int k;
int d;
int used[N];
int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> k;
    for(int i = 1; i <= k; i ++){
        cin >> d;
        for(int j = 1; j <= d; j ++){
            int x;
            cin >> x;
            used[x] = 1;
        }
    }
    cout << n - count(used + 1, used + n + 1, 1) << "\n";
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int R,C;
    cin >>R>>C;
    vector<vector<char>> c(R,vector<char> (C,'-'));
    vector<vector<int>> dis(R,vector<int> (C,-1));
    int sy,sx,gy,gx;
    int black=0;
    //スタートとゴール
    //cin >> sy >> sx;
    sy = 0,sx =0;
    //cin >> gy >> gx;
    gy =R-1,gx =C-1;
    rep(i,R){
        rep(j,C){
            cin >> c[i][j];
            if(c[i][j]=='#'){
                black++;
            }
        }
    }
    
    queue <pair<int,int>> q;
    int dx[4]={0,1,0,-1};
    int dy[4]={1,0,-1,0};
    dis[sy][sx]=0;
    //cout << dis[sy][sx]<<endl;
    q.push(make_pair(sy,sx));
    clock_t start = clock();
    while(!q.empty()){
        pair<int ,int> p = q.front();
        q.pop();
        //先頭の今決まってる座標を取り出す
        if(p == make_pair(gy,gx)){//ゴール到達
            break;
        }
        for(int i=0;i<4;i++){
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(nx<0||ny<0||nx>=C||ny>=R){
                continue;
            }
            else if(c[ny][nx]=='#'){
                continue;
                //探索しようと思ったら壁
            }
            else if(dis[ny][nx]!=-1){
                continue;
            }
            else{
                dis[ny][nx]= dis[p.first][p.second]+1;
                //cout <<"dis["<<ny<<"]["<<nx<<"]="<<dis[ny][nx]<<endl;
                q.push(make_pair(ny,nx));
                //新しく確定マスをキューに入れる    
            }
        }
    }
    //cout << dis[gy][gx]<<endl;
    if(dis[gy][gx]==-1){
        cout<<-1<<endl;
    }
    else{
    cout<<R*C-black-(dis[gy][gx]+1)<<endl;
    }

}

Measured memory_bytes: 384
A = int(input())
B = int(input())
C = int(input())
X = int(input())

suma = 0
sumb = 0
sumc = 0

la = list([0])
lb = list([0])
lc = list([0])

ls = list()
for i in range(1,A+1):
    suma = suma + 500
    la.append(suma)

for i in range(1,B+1):
    sumb = sumb + 100
    lb.append(sumb)

for i in range(1,C+1):
    sumc = sumc + 50
    lc.append(sumc)

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            ls.append(la[i]+lb[j]+lc[k])
            
print(ls.count(X))

Measured memory_bytes: 76368
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

d = Counter(A)

ans = 0
# print(d)

for i in d.keys():
    if i != d[i]:
        if i < d[i]:
            ans += d[i] - i
        else:
            ans += d[i]
print(ans)


Measured memory_bytes: 18672
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int a=in.nextInt();
		int p=in.nextInt();
		int ans=3*a+p;
		ans=ans/2;
		System.out.println(ans);
	}
}
	

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
int N; int a[2020];
const int MOD = 998244353;
int *dp, *tdp, *dp2;
int dp_[202020];
int dp2_[202020];
int tdp_[202020];
int main()
{
  dp = dp_ + 101010;
  dp2 = dp2_ + 101010;
  tdp = tdp_ + 101010;
  dp[0] = 1; dp2[0] = 1;
  
  int N; scanf("%d", &N);
  for(int i=0; i<N; ++i)
  {
    scanf("%d", a+i);
    for(int j=-300*i; j<=300*i; ++j)
    {
      tdp[j+a[i]] = (tdp[j+a[i]]+dp[j]*2)%MOD;
      tdp[j-a[i]] = (tdp[j-a[i]]+dp[j])%MOD;
    }
    memcpy(dp_, tdp_, sizeof dp_);
    memset(tdp_, 0, sizeof tdp_);
    
    
    for(int j=-300*i; j<=300*i; ++j)
    {
      tdp[j+a[i]] = (tdp[j+a[i]]+dp2[j])%MOD;
      tdp[j-a[i]] = (tdp[j-a[i]]+dp2[j])%MOD;
    }
    memcpy(dp2_, tdp_, sizeof dp2_);
    memset(tdp_, 0, sizeof tdp_);
  }  
  long long ans = 0;
  for(int i=-300*N; i<=0; ++i)
    ans = (ans+dp[i])%MOD;
  
  ans = (ans + MOD-dp2[0]) %MOD;
  
  long long p3 = 1; 
  for(int i=0; i<N; ++i) p3 = p3*3%MOD;
  long long ret = p3+3*(MOD-ans);
  printf("%lld\n", ret%MOD);
  return 0;
}

Measured memory_bytes: 2560
input_ints :: IO [Int]
input_ints = do
    a <- getLine
    return (map read (words a))

from_ints :: (Num a) => [Int] -> [a]
from_ints ns = map fromIntegral ns

hour_angle :: Int -> Int -> Double
hour_angle hour minute = (hour' * angle_per_hour) + (minute' * (angle_per_hour/60))
    where 
        angle_per_hour = 2*pi/12
        [hour', minute'] = from_ints [hour, minute]

minute_angle :: Int -> Double
minute_angle minute = minute' * (2*pi/60)
    where minute' = fromIntegral minute

edges_distance :: Int -> Int -> Int -> Int -> Double
edges_distance h_length m_length hour minute =
    let h_angle = hour_angle hour minute
        m_angle = minute_angle minute
        interior_angle = abs (h_angle - m_angle)
        [h_length', m_length'] = from_ints [h_length, m_length]
        distance = sqrt(h_length'^2 + m_length'^2 - (2 * h_length' * m_length' * (cos interior_angle)))
    in distance

main = do
    [h_length ,m_length ,hour ,minute] <- input_ints
    let distance = edges_distance h_length m_length hour minute
    putStrLn (show distance)


Measured memory_bytes: 4460
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    while(cin>>n>>m,n,m){
        int vege[1000];
        for(int i=0;i<n;i++)cin>>vege[i];
        sort(vege,vege+n);
        for(int i=1;n-m*i>=0;i++)vege[n-m*i]=0;
        for(int i=1;i<n;i++)vege[0]+=vege[i];
        cout<<vege[0]<<endl;
    }
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
int n, num[20];
long long dfs(int l, int r, int x, int y)
{
	if (l + 1 >= r)return 0;
	long long res = 1e18;
	for (int i = l + 1; i <= r - 1; i++)
		res = min(res, dfs(l, i, x, x + y) + dfs(i, r, x + y, y) + 1LL * (x + y) * num[i]);
	return res;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> num[i];
	cout << num[1] + num[n] + dfs(1, n, 1, 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	ll h, w;
	cin >> h >> w;
	ll ans = LINF;
	for (ll i = 1; i <= h; i++) {
		ll s1 = i * w;
		if (s1 >= h * w) break;
		ll s2 = (h - i) / 2 * w;
		ll s3 = (h - i) * w - s2;
		ll ds = max(s1, max(s2, s3)) - min(s1, min(s2, s3));
		ans = min(ans, ds);
		
		s2 = w / 2 * (h - i);
		s3 = (h - i) * w - s2;
		ds = max(s1, max(s2, s3)) - min(s1, min(s2, s3));
		ans = min(ans, ds);
	}

	for (ll i = 1; i <= w; i++) {
		ll s1 = i * h;
		if (s1 >= h * w) break;
		ll s2 = (w - i) / 2 * h;
		ll s3 = (w - i) * h - s2;
		ll ds = max(s1, max(s2, s3)) - min(s1, min(s2, s3));
		ans = min(ans, ds);
		
		s2 = h / 2 * (w - i);
		s3 = (w - i) * h - s2;
		ds = max(s1, max(s2, s3)) - min(s1, min(s2, s3));
		ans = min(ans, ds);
	}

	cout << ans << endl;
}

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

#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<ll,ll>
#define vi vector<ll>
#define vpi vector< pi >
const int N=100010;

int main()
{
	int v[5]={0};
	int x,y;
	for(int i=1;i<=3;i++)
	{
		cin>>x>>y;
		v[x]+=1;
		v[y]+=1;
	}
	int f=0;
	for(int i=1;i<=4;i++)
	{
		f+=(v[i]==1);
		//cout<<<<"\n";
		if(f>2) return cout<<"NO",0;
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;
int main(){
	char str[210];
	cin>>str;
	int t=0;
	int i, j;
	int n;
	int d;
	n=strlen(str);
	for(i=1;i<n/2;i++){
		d=1;
		for(j=0;j<=i-1;j++){
			if(str[j]!=str[j+i]) d=0;
		}
		if(d==1) t=i;
	}
	cout<<t*2;
	return 0;
}

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

const int N = 1e5+5;

int main()
{
    int h[N+5];
    int n;
    cin>>n;
    int m=0,ans=0,a,p;
    cin>>p;
    for(int i=1; i<n; i++)
    {
        cin>>a;
        if(p>=a) m++;
        else m=0;
        ans=max(ans,m);
        p=a;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> L(N);
  for (int i = 0 ; i < N ; i++) {
    cin >> L[i];
  }
  sort(L.begin(),L.end());
  int ans = 0;
  for (int i = 0 ; i < K ; i++) {
    ans += L[N - 1 - i];
  }
  cout << ans;
}

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

const int N = 20;

int b[N];

int main()
{
    int n, m, C;
    scanf("%d%d%d", &n, &m, &C);

    for (int i = 0; i < m; ++i)
        scanf("%d", b + i);

    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        static int sum;
        sum = 0;
        for (int j = 0; j < m; ++j)
        {
            static int x;
            scanf("%d", &x);
            sum += x * b[j];
        }
        ans += sum + C > 0;
    }

    printf("%d", ans);
}


Measured memory_bytes: 256
def insertion_sort(A):
    for i in range(1, len(A)):
        v = A[i]
        j = i - 1
        print(*A)
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            A[j] = v
            j -= 1
    return A

n = input()
A = [int(x) for x in input().split()]
print(*insertion_sort(A))



Measured memory_bytes: 5980
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

class Main {
    static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static final PrintWriter pw = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        String[] inputs = br.readLine().split(" ");
        int[] nums = new int[3];
        for(int i = 0; i < 3; i++) {
            nums[i] = Integer.parseInt(inputs[i]);
        }
        String ans = nums[2] + " " + nums[0] + " " + nums[1];

        pw.println(ans);
        pw.flush();
    }
}


Measured memory_bytes: 20820
import java.io.*;
import java.util.*;

//solution classes here

public class Main {

    //main solution here

    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int x=sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        x^=y;
        y^=x;
        x^=y;
        x^=z;
        z^=x;
        x^=z;
        out.println(x+" "+y+" "+z);
        out.flush();
        out.close();
    }

    //solution functions here


    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

/* *****************************************************************************************************************************
 * I'M NOT IN DANGER, I'M THE DANGER!!!
 * *****************************************************************************************************************************
 */

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

namespace AtCoder.ABC._125
{
    class B
    {
        static void Solve()
        {
            int n = int.Parse(Console.ReadLine());
            int[] v = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int sum = 0;

            for (int i = 0; i < n; i++)
            {
                if (v[i] - c[i] > 0)
                    sum += v[i] - c[i];
            }

            Console.WriteLine(sum);
        }

        static void Main()
        {
            Solve();
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
int main(){
  ll n,max=0,f=0,num;
  cin>>n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
	cin>>a[i];
    if(a[i]==max){
      f=1;
    }else if(a[i]>max){
      max=a[i];
      num=i;
      f=0;
    }
  }
  
  sort(a.begin(),a.end());
  
  if(f==1){
    for(ll i=0;i<n;i++){
      cout<<max<<endl;
    }
  }else{
	for(ll i=0;i<n;i++){
      cout<<(i!=num?max:a[n-2])<<endl;
    }
  }

  
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5,M=105;
ll w[M],v[M],n,dp[M][N];
ll solve(ll idx,ll cur_wt){
    if(idx==n+1)return 0;
    if(dp[idx][cur_wt]!=-1)return dp[idx][cur_wt];
    ll &ans = dp[idx][cur_wt];
    ans=0;
    ans=solve(idx+1,cur_wt);
    if(w[idx]<=cur_wt)ans=max(ans , solve(idx+1,cur_wt-w[idx])+v[idx]);
    return ans;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll cap;cin>>n>>cap;
    for(ll i=1;i<=n;i++)cin>>w[i]>>v[i];
    memset(dp,-1,sizeof(dp));
    cout<<solve(1,cap);
}



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

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

int n,q;
cin >> n >> q;
char s[100000];
vector<int> ans(n);
int l,r;
cin >> s;
int i,j;
for(i=0;i<n;++i){
    if(i==n-1){
        ans[i] = ans[i-1];
        break;
    }
    if(s[i]=='A'&&s[i+1]=='C'){
        if(i!=0){
            ans[i] = ans[i-1] + 1;
        }else{
            ans[i] = 1;
        }
    }else{
        ans[i] = ans[i-1];
    }
}

for(i=0;i<q;++i){
    cin >> l >> r;
    cout << ans[r-2] - ans[l-2] << endl;
}


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sca = new Scanner(System.in);
		long n = sca.nextLong();
		long k = sca.nextLong();
		long ans = 0;
		long kouho_1 = 0;
		long temp = 0;
		long kouho_2 = 0;

		int big_or_small = 0;
		if(n > k) {
			temp = n/k;
			kouho_2 = n - (k*temp);

			temp = k - kouho_2;
			if(temp < kouho_2) {
				ans = temp;
			}
			else {
				ans = kouho_2;
			}
		}
		else if(n < k) {
			kouho_1 = k - n;
			if(kouho_1 < n) {
				ans = kouho_1;
			}
			else {
				ans = n;
			}
		}
		else {
			ans = n - k;
		}

		System.out.println(ans);

		// 後始末
		sca.close();
	}
}

Measured memory_bytes: 23764
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long double f(long double a, long double b, long double c) {
	long double ret = MOD;
	long double d = b * b - 4 * a*c;
//	cout << d << endl;
	if (d > -EPS) {
		d = sqrt(d);
		long double e = (-b + d) / 2 / a;
		if (e >= 0 && e <= 20000000)ret = min(ret, e);
		e = (-b - d) / 2 / a;
		if (e >= 0 && e <= 20000000)ret = min(ret, e);
	}
	return ret;
}

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

	cin >> N;
	vector<int>ret;
	while (N) {
		cin >> W >> H >> R;
		long double vy, vx;
		cin >> vx >> vy;
		vector<long double>x(N);
		vector<long double>y(N);
		for (int i = 0; i < N; i++) {
			cin >> x[i] >> y[i];
		}
		long double d = sqrt(vx*vx + vy * vy);
		vx /= d, vy /= d;
		//	cout << vx << " " << vy << endl;
		int dif = 10000 / min(W, H) * 2  + 10;
		vector<long double>near(N, MOD);
		for (int i = -dif; i <= dif; i++) {
			for (int j = -dif; j <= dif; j++) {
				for (int k = 1; k < N; k++) {
					long double cx = x[k], cy = y[k];
					if ((i + 10000) & 1) {
						cx = W - cx;
					}
					if ((j + 10000) & 1) {
						cy = H - cy;
					}
					cx += i * (W - 2 * R);
					cy += j * (H - 2 * R);
					//if (f(1, vx*(x[0] - cx) * 2 + vy * (y[0] - cy) * 2, cx*cx + cy * cy + x[0] * x[0] + y[0] * y[0] - cx * x[0] * 2 - cy * y[0] * 2 - R * R * 4) <= 30000) {
					//	cout << cx << " " << cy << " " << f(1, vx*(x[0] - cx) * 2 + vy * (y[0] - cy) * 2, cx*cx + cy * cy + x[0] * x[0] + y[0] * y[0] - cx * x[0] * 2 - cy * y[0] * 2 - R * R * 4) << endl;
					//}
				//	cout << cx << " " << cy << endl;
					near[k] = min(near[k], f(1, vx*(x[0] - cx) * 2 + vy * (y[0] - cy) * 2, cx*cx + cy * cy + x[0] * x[0] + y[0] * y[0] - cx * x[0] * 2 - cy * y[0] * 2 - R * R * 4));
				}
			}
		}
		int ans = -2;
		for (int i = 1; i < N; i++) {
			//		cout << i << " " << near[i] << endl;
			if (near[i] <= 10000 + EPS) {
				if (ans == -2)ans = i;
				else {
					if (near[ans] > near[i])ans = i;
				}
			}
		}
		ret.push_back(ans + 1);
		cin >> N;
	}
	for (auto i : ret)cout << i << endl;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string s;
    cin >> s;
    if(s[0]=='a'){
        if(s[1]=='b'){
            if(s[2]=='c') cout << "Yes";
            else cout << "No";
        }else if(s[1]=='c'){
            if(s[2]=='b') cout << "Yes";
            else cout << "No";
        }else cout << "No";
    }else if(s[0]=='b'){
        if(s[1]=='a'){
            if(s[2]=='c') cout << "Yes";
            else cout << "No";
        }else if(s[1]=='c'){
            if(s[2]=='a') cout << "Yes";
            else cout << "No";
        }else cout << "No";
    }else if(s[0]=='c'){
        if(s[1]=='a'){
            if(s[2]=='b') cout << "Yes";
            else cout << "No";
        }else if(s[1]=='b'){
            if(s[2]=='a') cout << "Yes";
            else cout << "No";
        }else cout << "No";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
P = list(map(int,input().split()))
S = [list(map(int,input().split())) for i in range(M)]

class Union_find():
    def __init__(self, N):
        self.Group = [i for i in range(N)]
        
    def find(self,x):# find(a)=find(b)のとき同じグループ
        while self.Group[x] != x:
            x = self.Group[x]
        return x

    def Union(self,x,y):  # xとyが同じグループになるよう更新
        if self.find(x) != self.find(y):
            self.Group[self.find(y)] = self.Group[self.find(x)] = min(self.find(y),self.find(x))

A = Union_find(N)

for x,y in S:
    A.Union(x-1,y-1)

ANS = 0

for i in range(N):
    P[i]-=1

for i in range(N):
    if A.find(i) == A.find (P[i]):
        ANS += 1

print(ANS)

Measured memory_bytes: 35324
import scala.io.Source.stdin

object Main {
  def euclid(m:Int,n:Int):Int = if(n==0) m else euclid(n,m%n)
  def main(args:Array[String]) =
    stdin.getLines.foreach { s=>
      val n = s.split(" ").map(_.toInt)
      println(euclid(n(0),n(1)))
    }
}

Measured memory_bytes: 43964
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int count = 0;
		for(int i = 105; i <= n; i+=2) {
			int div = 2;
			for(int j = 2; j < i; j++) {
				if(i%j ==0)div++;
			}
			if(div == 8)count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
int main(void){
	int n,m;
	char str[100];

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		sscanf(str,"%d",&n);
		m=(n*n+n+2)/2;
		printf("%d\n",m);
	}
	return 0;
}

Measured memory_bytes: 600
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue> 
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
//#define int LL
using namespace std;
const int N   = 233;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define For(n) for (int i=1;i<=n;++i)
#define rep(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}

int n,ans;
string s;
int f[233];
int solve(int dep)

{
	if (dep>n-1) return 0;
	//if (dep==n) return k;
	if (f[dep]!=-1) return f[dep];
	int k=s[dep]-'0';
	if (dep==n-1) return k;
	int tmp=solve(dep+1)+k;
	if (dep!=n&&k>0) tmp=max(k-1+9*(n-dep-1),tmp);
	return f[dep]=tmp;
}
signed main()
{
	cin>>s;
	n=s.length();
	memset(f,-1,sizeof(f));
	return printf("%d",solve(0)),0;
}


Measured memory_bytes: 256
N = int(input())
A = input().split()
S = 1
if "0" in A:
    print(0)
else:
    for i in range(N):
        S *= int(A[i])
        if S > 10**18:
            break
    if S > 10**18:
        print(-1)
    else:
        print(S)


Measured memory_bytes: 19348
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
#define mod (int)(1e9+7)
using namespace std;
typedef pair<int,int> pii;

int dp[111111][11];
int main(){

  string s;
  cin>>s;

  dp[0][0]=1;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'||s[i]=='?'){
      for(int j=0;j<4;j++){
        dp[i+1][j]+=dp[i][j];
        dp[i+1][j]%=mod;
      }
      dp[i+1][1]+=dp[i][0];
      dp[i+1][1]%=mod;
    }

    if(s[i]=='B'||s[i]=='?'){
      for(int j=0;j<4;j++){
        dp[i+1][j]+=dp[i][j];
        dp[i+1][j]%=mod;
      }
      dp[i+1][2]+=dp[i][1];
      dp[i+1][2]%=mod;
    }
    
    if(s[i]=='C'||s[i]=='?'){
      for(int j=0;j<4;j++){
        dp[i+1][j]+=dp[i][j];
        dp[i+1][j]%=mod;
      }
      dp[i+1][3]+=dp[i][2];
      dp[i+1][3]%=mod;
    }
  }
  cout<<dp[s.size()][3]<<endl;
  return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    char s;
    cin >> s;
    char ans = (char)(s + 1);
    cout << ans << endl; 
return 0;
}

Measured memory_bytes: 3576
double x[100][100],y[100][100],r,z;
main(n,m,i,j,k){for(;scanf("%d%d",&n,&m),m;printf("%.2f\n",r)){
memset(x,0,sizeof(x));
for(i=0;i<n;i++)for(x[0][i]=1,j=0;j<n;j++)scanf("%lf",y[i]+j);
for(i=1;i<m;i++)for(j=0;j<n;j++)for(k=0;k<n;k++)if(x[i][j]<(z=x[i-1][k]*y[k][j]))x[i][j]=z;
for(r=j=0;j<n;j++)r=r<x[m-1][j]?x[m-1][j]:r;
}exit(0);}

Measured memory_bytes: 824
from math import sqrt
from collections import deque
def ggcd(a,b):
    if(b==0):
        return a
    return ggcd(b,a%b)
N=int(input())
def gcd_ext(a, b):
    x, y, lastx, lasty = 0, 1, 1, 0
    while b != 0:
        q = a // b
        a, b = b, a % b
        x, y, lastx, lasty = lastx - q * x, lasty - q * y, x, y
    return (lastx, lasty)
l=[]
pf={}
m=N*2
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
#print(pf)
keys=list(pf.keys())
values=list(pf.values())
for i in range(len(keys)):
    l.append([keys[i],values[i]])
#print(l)
d=deque()
d.append([])

for i in range(len(l)):
    x=list(range(values[i]+1))
    d2 = deque()
    #print(x)
    while len(d)>0:
        l=d.popleft()
        for j in x:
            l2=l[:]
            l2.append(j)
            d2.append(l2)
    d=d2
    #print(d)
ans=float("inf")
x=0
y=0
while len(d)>0:
    l=d.popleft()
    num=1
    res=1
    for i in range(len(l)):
        num=num*pow(keys[i],l[i])
        res=res*pow(keys[i],values[i]-l[i])
    #print(num,res)
    #x*num=k+1のときを考える
    if ggcd(num,res)==1:
        #x*num+y*res=1
        x,y=gcd_ext(num,res)
        if (x==0)or(y==0):
            x1=x+num*res
            y1=y+num+res
            ans=min(ans,x1*num-1)
            x2=x-num*res
            y2=x-num*res
            ans=min(ans,-x2*num)
        else:#どっちかは+でどっちかは-
            if x>y:
                ans=min(ans,x*num-1)
                x1=x-num*res
                ans=min(ans,-x1*num)
            else:
                x1=x+num*res
                ans=min(ans,x1*num-1)
                ans=min(ans,-x*num)
print(ans)



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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long W, H;
	long long x, y;
	cin >> W >> H >> x >> y;

	long double S;
	if(W <= H){
		S = (double)H / 2;
		S *= W;
	}
	else{
		S = (double)W / 2;
		S *= H;
	}
	if( (W % 2 == 0) && (H % 2 == 0) && x == W/2 && y == H/2){
		printf("%.10Lf 1\n", S);
	}
	else{
		printf("%.10Lf 0\n", S);
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
	int i,j,h,w;
	string s;
	cin>>h>>w;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>s;
			if(s=="snuke"){
				s[0]='A'+j;
				cout<<s[0]<<i+1<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 200003
#define M 2003
#define inf 1e18
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    Arena
        
    int n,x;
    cin>>n>>x;
    int l[n+1],i,j;
    for(i=1;i<=n;++i)
        cin>>l[i];
    
    int ans=1;
    int d[n+2];
    d[1]=0;
    for(i=2;i<=n+1;++i)
    {
        d[i]=d[i-1]+l[i-1];
        ans+=(d[i]<=x);
    }   
    cout<<ans;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

class RMQ{
	public:
	int n;
	ll init;
	vector<ll> dat;
	RMQ(){}
	RMQ(int size, ll inf){
		n = 1;
		init = inf;
		while(n < size) n *= 2;
		dat.resize(2 * n - 1, init);
	}
	void update(int k, ll a){
		k += n - 1;
		dat[k] = a;
		while(k > 0){
			k = (k - 1) / 2;
			dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}
	ll find(int s, int t){
		return query(s, t + 1, 0, 0, n);
	}
	ll query(int a, int b, int k, int l, int r){
		if(r <= a || b <= l) return init;
		if(a <= l && r <= b) return dat[k];
		else{
			ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
			ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}
};

int main(){
	int n, q;
	cin >> n >> q;
	RMQ rmqa(n, (1LL << 31) - 1);
	for(int i = 0; i < q; i++){
		int com; ll x , y;
		cin >> com >> x >> y;
		if(com == 0){
			rmqa.update(x, y);
		}else if(com == 1){
			cout << rmqa.find(x, y) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4876
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
using namespace std;
int n,x,ans=1;
int cnt[100005],a[100005];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		cnt[abs((i-1)-(n-i))]++;
	for (int i=1;i<=n;i++)
		scanf("%d",&x),a[x]++;
	for (int i=1;i<=n;i++)
		if (cnt[i]^a[i])
			return puts("0"),0;
	for (int i=1;i<=n;i++)
		if (cnt[i]) ans=ans*cnt[i]%mo;
	printf("%d",ans); 
}

Measured memory_bytes: 1024
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	int SIZE = 80;
	int[] ans;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		for (int l = 0; l < n; l++) {
			// 80ケタの数字は扱えないので文字列に
			char[] a = sc.next().toCharArray();
			char[] b = sc.next().toCharArray();

			// 入力が80ケタを超える
			if (a.length > SIZE || b.length > SIZE) {
				System.out.println("overflow");
				continue;
			}

			// 文字列⇒配列に
			int[] x = new int[a.length];
			int[] y = new int[b.length];
			for (int i = 0; i < a.length; i++) {
				x[i] = a[i] - '0';
			}
			for (int i = 0; i < b.length; i++) {
				y[i] = b[i] - '0';
			}

			// 大きい桁数+1だけ答えの配列をとる
			if (x.length >= y.length) {
				ans = new int[x.length + 1];
			} else {
				ans = new int[y.length + 1];
			}

			int i = x.length - 1;
			int j = y.length - 1;
			int k = ans.length - 1;
			int count = 0;
			boolean flag = false;

			// 同じ桁数の計算
			while (i >= 0 && j >= 0) {
				count++;
				ans[k] += (x[i] + y[j]);
				// 繰り上がり処理
				if (ans[k] >= 10) {
					if (count < SIZE) {
						ans[k - 1] = 1;
						ans[k] -= 10;
					} else {
						flag = true;
					}
				}
				i--;
				j--;
				k--;
			}

			// x>y（桁数）
			if (i > j) {
				while (i >= 0) {
					count++;
					ans[k] += x[i];
					// 繰り上がり処理
					if (ans[k] >= 10) {
						if (count < SIZE) {
							ans[k - 1] = 1;
							ans[k] -= 10;
						} else {
							flag = true;
						}
					}
					k--;
					i--;
				}
			} else {
				while (j >= 0) {
					count++;
					ans[k] += y[j];
					// 繰り上がり処理
					if (ans[k] >= 10) {
						if (count < SIZE) {
							ans[k - 1] = 1;
							ans[k] -= 10;
						} else {
							flag = true;
						}
					}
					k--;
					j--;
				}
			}

			if (flag) {
				System.out.println("overflow");
				continue;
			}

			for (int m = 0; m < ans.length; m++) {
				if (m == 0 && ans[m] == 0) {
					continue;
				}
				System.out.print(ans[m]);
			}
			System.out.println();
		}

		sc.close();
	}

	void run1() {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();

		while (t != 0) {
			BigInteger bi = sc.nextBigInteger().add(sc.nextBigInteger());
			if (bi.toString().length() > 80) {
				System.out.println("overflow");
			} else {
				System.out.println(bi);
			}
		}
	}

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

}

Measured memory_bytes: 17204
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{

	public static void main(String[] args) throws Exception{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		int len = 3;
		int[] num = new int[len];

		for(int i = 0; i < len; i++){
			num[i] = Integer.parseInt(line[i]);
		}

		for(int i = 0; i < len; i++){
			for(int j = len - 1; j > i; j--){
				if(num[j - 1] > num[j]){
					int temp = num[j - 1];
					num[j - 1] = num[j];
					num[j] = temp;
				}
			}
		}

		for(int i = 0; i < len; i++){
			if(i == len - 1){
				System.out.println(num[i]);
			}else{
				System.out.print(num[i] + " ");
			}

		}

	}
}

Measured memory_bytes: 24100
N = int(input())
li_p = list(map(int, input().split()))
li_a = sorted(li_p)
#print(li_a)
#print(li_p)
a = 0
for i in range(N):
  if li_p[i] != li_a[i]:
    a += 1
    
if a <= 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <cmath>

using namespace std;

int mod_num_counter[2030];

int main()
{
    //fill(mod_num_counter,mod_num_counter+2030,0);

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

    int inpt[q][4];

    for (int i = 0; i < q; i++)
    {
        cin >> inpt[i][0] >> inpt[i][1] >> inpt[i][2] >> inpt[i][3];
    }

    long long c_max = pow(m, n);
    int a_kouho[n], a_max[n];
    int max_p = -1;
  	a_kouho[0]=0;
  	for(int i=1;i<n;i++) a_kouho[i] =1;
  	bool end = false;
    while (true)
    {
      	int idx = 0;
      	while(true)
        {
          a_kouho[idx]++;
          if(a_kouho[idx] <= a_kouho[idx+1])
            break;
          
          a_kouho[idx]=1;
          idx++;
          if(idx>=n-1)
          {
            a_kouho[idx]++;
            break;
          }
        }
      if(a_kouho[n-1]>m) break;
      
      
      
      //cout << a_kouho[n-3]<< a_kouho[n-2]<< a_kouho[n-1]<<endl;
        int p = 0;

        for (int i = 0; i < q; i++)
        {
            int ai = a_kouho[inpt[i][0] - 1];
            int bi = a_kouho[inpt[i][1] - 1];
            int ci = inpt[i][2];
            int di = inpt[i][3];
            if (bi - ai == ci)
                p += di;
        }

        if (p > max_p)
        {
            max_p = p;
            for (int i = 0; i < n; i++)
            {
                a_max[i] = a_kouho[i];
            }
        }
    }

    cout << max_p << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main() {
  int N,D,k=0,v;
  cin>>N>>D;
  k=2*D+1;
  if(N%k==0) v=N/k;
else if (N%k!=0) v=N/k+1;
cout<<v;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll d,g;cin>>d>>g;
    ll p[d+1],c[d+1];
    for(ll i=1;i<=d;i++){
        cin>>p[i]>>c[i];
    }
    ll dp[d+1][1001];   //i番までの問題を用いて、合計j個の問題を解く時に得ることができる最大点数
    for(ll i=0;i<=d;i++){
        dp[i][0]=0;
        for(ll j=1;j<=1000;j++){
            dp[i][j]=-1;
        }
    }
    for(ll i=0;i<d;i++){
        for(ll j=0;j<=1000;j++){
            if(dp[i][j]!=-1){
                for(ll k=0;k<=p[i+1] && j+k<=1000;k++){
                    if(k==p[i+1]){
                        dp[i+1][j+k]=max(dp[i+1][j+k],dp[i][j]+(i+1)*100*k+c[i+1]);
                    }else{
                        dp[i+1][j+k]=max(dp[i+1][j+k],dp[i][j]+(i+1)*100*k);
                    }
                }
            }
        }
    }
    ll ans=inf;
    for(ll i=1;i<=d;i++){
        for(ll j=0;j<=1000;j++){
            if(dp[i][j]>=g){
                ans=min(ans,j);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 384