akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define endl "\n"
#define ar array
#define deb(x) cout << #x << " = " << x << endl
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll N = 2e5 + 1;

template <class T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
inline ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }
inline ll sub(ll a, ll b) { return ((a % mod) - (b % mod) + mod) % mod; }
inline ll mul(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }
struct comp
{
    bool operator()(const pair<ll, ll> &x, const pair<ll, ll> &y) const
    {
        return x.first < y.first;
    }
};
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll pwr(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n & 1)
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    else
        return pwr(mul(x, x), n / 2);
}
ll modInv(ll n)
{
    return pwr(n, mod - 2);
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

int main()
{
    IOS;
    int t = 1;
    // cin >> t;
    while (t--)
    {
        const int mod = 998244353;
        int n, k;
        cin >> n >> k;
        vector<array<int, 2>> intervals(k);
        for (auto &[x, y] : intervals)
            cin >> x >> y;
        vector<ll> dp(n + 1), pref(n + 1);
        dp[1] = pref[1] = 1;
        for (int i = 2; i <= n; ++i)
        {
            for (auto [l, r] : intervals)
            {
                int L = max(1, i - r), R = i - l;
                if (L > R)
                    continue;
                // Add dp[L...R]
                dp[i] += (pref[R] - pref[L - 1]) % mod;
                dp[i] = (dp[i] % mod + mod) % mod;
            }
            pref[i] = (pref[i - 1] + dp[i]) % mod;
        }
        cout << dp[n];
    }
}

Measured memory_bytes: 6356
#include<bits/stdc++.h>
using namespace std;
int main(){
  int S,n,s;
  cin>>S;
  n=S%100;
  s=(S-n)/100;
  if(0<n&&n<=12&&0<s&&s<=12)cout<<"AMBIGUOUS"<<endl;
  else if(0<s&&s<=12) cout<<"MMYY"<<endl;
  else if(0<n&&n<=12) cout<<"YYMM"<<endl;
  else cout<<"NA"<<endl;
}
  
  
  

Measured memory_bytes: 3600
import java.io.*;
import java.util.*;
import java.util.ArrayList;
 
class Main
{
  public static void main (String[] arg)
  {
    Scanner scan = new Scanner(System.in);
    
    String hitachi = scan.next(); //整数   
    
    if(hitachi.equals("hi") ||
       hitachi.equals("hihi") ||
       hitachi.equals("hihihi") ||
       hitachi.equals("hihihihi") ||
       hitachi.equals("hihihihihi") ){
      
      System.out.println("Yes");
    }
    
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21588
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

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

    List<Integer> answers = Arrays.asList(a, b);
    List<Integer> target = Arrays.asList(1, 2, 3);
    int ans = target.stream()
            .filter(n -> !answers.contains(n))
            .collect(Collectors.toList())
            .get(0);
    System.out.println(ans);
  }
}

Measured memory_bytes: 30292
#include<stdio.h>
 
#define MAX 100006
 
struct Node{
  int p;
  int l;
  int r;
};
 
struct Node C[MAX];
 
int n, H, D[MAX];
 
int getDepth(int u){
  int d = 0;
   
  while(C[u].p >= 0){
    u = C[u].p;
    d++;
  }
   
  return d;
}
 
void printTree(int u){
  int t;
 
  if(C[u].p == -1) printf("node %d: parent = %d, depth = %d, root, ", u, C[u].p, D[u]);
   
  else if(C[u].l == -1) printf("node %d: parent = %d, depth = %d, leaf, ", u, C[u].p, D[u]);
   
  else printf("node %d: parent = %d, depth = %d, internal node, ", u, C[u].p, D[u]);
     
  printf("[");
 
  t = u;
 
  if(C[t].l != -1){
    printf("%d", C[t].l);
 
    if(C[C[t].l].r == -1) printf("]\n");
 
    else printf(",");
 
    t = C[t].l;
 
    while(C[t].r != -1){
      printf(" %d",C[t].r);
       
      if(C[C[t].r].r == -1) printf("]\n");
 
      else printf(",");
 
      t = C[t].r;
    }
  }
   
  else printf("]\n");
}
 
main(){
  int i, j, d, v, c, l, r;
   
  scanf("%d", &n);
   
  for(i = 0; i < n; i++){
    C[i].p = C[i].l = C[i].r = -1;
  }
   
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
 
    for(j = 0; j < d; j++){
      scanf("%d", &c);
 
      C[c].p = v;
       
      if(j == 0) C[v].l = c;
       
      else if (j >= 1) C[r].r = c;
      r = c;
    }
  }
   
  for(i = 0; i < n; i++) D[i] = getDepth(i);
   
  for(i = 0; i < n; i++) printTree(i);
  return 0;
}

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

pair<int, int> get_match(int x, int y)
{
    if (x < y)
        return make_pair(x, y);
    else
        return make_pair(y, x);
}

vector<vector<int>> graph;
vector<int> depth;
vector<bool> visited;

int dfs(int v)
{
    if (visited.at(v))
    {
        if (depth.at(v) == 0)
        {
            return -1;
        }
        return depth.at(v);
    }

    visited.at(v) = true;
    int res = 1;
    for (auto u : graph.at(v))
    {
        int res_u = dfs(u);
        if (res_u < 0)
        {
            return -1;
        }
        res = max(res, res_u + 1);
    }
    depth.at(v) = res;
    return res;
}

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

    vector<vector<int>> A(N, vector<int>(N - 1));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N - 1; j++)
        {
            cin >> A.at(i).at(j);
            A.at(i).at(j)--;
        }
    }

    map<pair<int, int>, int> m_to_v;
    vector<pair<int, int>> v_to_m;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N - 1; j++)
        {
            pair<int, int> m = get_match(i, A.at(i).at(j));
            if (m_to_v.count(m) == 0)
            {
                int v = m_to_v.size();
                m_to_v[m] = v;
                v_to_m.push_back(m);
            }
        }
    }

    graph = vector<vector<int>>(m_to_v.size());
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N - 2; j++)
        {
            pair<int, int> m0 = get_match(i, A.at(i).at(j)), m1 = get_match(i, A.at(i).at(j + 1));
            int v0 = m_to_v.at(m0), v1 = m_to_v.at(m1);
            graph.at(v0).push_back(v1);
        }
    }

    depth = vector<int>(m_to_v.size(), 0);
    visited = vector<bool>(m_to_v.size(), false);
    int res = 0;
    for (unsigned int v = 0; v < m_to_v.size(); v++)
    {
        int d = dfs(v);
        if (d < 0)
        {
            cout << -1 << endl;
            return 0;
        }
        res = max(res, d);
    }
    cout << res << endl;
}

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

static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int BLACK = 1;

int n, M[MAX][MAX];

void dijkstra() {
    int u, minv;
    int color[MAX], d[MAX];
    for (int i = 0; i < n; i++) {
        color[i] = WHITE;
        d[i] = INFTY;
    }

    // 0 start
    d[0] = 0;
    while (true) {
        // choose u
        minv = INFTY;
        u = -1;
        for (int i = 0; i < n; i++)
        {
            if (color[i] != BLACK && d[i] < minv) {
                u = i;
                minv = d[i];
            }
        }

        if (u == -1) {
            break;
        }

        // move u
        color[u] = BLACK;

        // update distance
        for (int v = 0; v < n; v++){
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if (d[v] > d[u] + M[u][v])
                    d[v] = d[u] + M[u][v];
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main() {
    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = INFTY;
        }
    }

    int u, k, c, v;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            M[u][v] = c;
        }
    }

    dijkstra();
}


Measured memory_bytes: 3108
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;




int main(void){
	ll N,M,d[110][110],a[1010],b[1010],c[1010],ans=0;
	scanf("%lld%lld",&N,&M);
	reg(i,1,N){
		reg(j,1,N){
			if(i==j){
				d[i][j]=0;
			}else{
				d[i][j]=1e12;
			}
		}
	}
	rep(i,M){
		scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
		d[a[i]][b[i]]=c[i];
		d[b[i]][a[i]]=c[i];
	}
	reg(k,1,N){
        reg(i,1,N){
            reg(j,1,N){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    //↑ワーシャルフロイド
    //↓判定
    rep(i,M){
    	bool ok=false;
    	reg(j,1,N){
    		if(d[j][a[i]]+c[i]==d[j][b[i]]){
    			ok=true;
    			break;
    		}
    	}
    	if(!ok)ans++;
    }
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;


int main(){
    int N,X;
    cin >> N >> X;
    int d=N;
    int m[N];
    for(int i=0; i<N; i++){
        cin >> m[i];
        X-=m[i];
    }
    sort(m,m+N);
    d+=X/m[0];
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<utility>

using namespace std;

const char *dir= "NEEESWWWNEEESWWWNEEESWWW";

class dice {
public:
	int f[6];
	void rollN() {
		int t=f[0];
		f[0]=f[1];
		f[1]=f[5];
		f[5]=f[4];
		f[4]=t;
	}
	void rollE() {
		int t=f[0];
		f[0]=f[3];
		f[3]=f[5];
		f[5]=f[2];
		f[2]=t;
	}
	void rollS() {
		int t=f[0];
		f[0]=f[4];
		f[4]=f[5];
		f[5]=f[1];
		f[1]=t;
	}
	void rollW() {
		int t=f[0];
		f[0]=f[2];
		f[2]=f[5];
		f[5]=f[3];
		f[3]=t;
	}
	void roll(char dir) {
		if(dir=='N') rollN();
		else if(dir=='E') rollE();
		else if(dir=='S') rollS();
		else if(dir=='W') rollW();
	}
	void normalize() {
		int m1=0, m2;
		for(int i=1; i<6; i++) {
			if(f[m1] > f[i]) m1=i;
		}
		m2=(m1==5)?1:0;
		for(int i=0; i<6; i++) {
			if(i==m1||i+m1==5) continue;
			if(f[m2]>f[i]) m2=i;
		}
		m1=f[m1];
		m2=f[m2];
		for(int i=0; i<24; i++) {
			if(f[0]==m1&&f[1]==m2) break;
			roll(dir[i]);
		}
	}
};

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

	dice d[100];
	int n;
	cin>>n;
	for(int i=0; i<n; i++) {
		cin>>d[i].f[0]>>d[i].f[1]>>d[i].f[2]>>d[i].f[3]>>d[i].f[4]>>d[i].f[5];
		d[i].normalize();
	}
	for(int i=0; i<n; i++) {
		for(int j=0; j<i; j++) {
			int k;
			for(k=0; k<6&&d[i].f[k]==d[j].f[k]; k++);
			if(k==6) {
				cout<<"No\n";
				return 0;
			}
		}
	}
	cout<<"Yes\n";
	return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define endl              "\n"
#define pb              push_back
#define fir               first
#define sec               second
#define all(v)            ((v).begin()), ((v).end())
#define sz(v)            ((int)((v).size()))
#define ll              long long
#define ld              long double
#define lp(i, n)        for(int i = 0 ; (int)i<n ; i++)
#define loop(i, x, n)       for(int i=x ; (int)i<=n ; i++)
#define isPowerOfTwo(s) (!(s & (s-1)))
typedef vector<int> vi;
typedef deque<int> de;
void origi() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
void tiranga() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    char c = s[0];
    int res = 0;
    lp(i, n) {
        if (c != s[i])
            c = s[i], res++;
    }
    cout << ++res;
}
int main() {
#ifndef ONLINE_JUDGE.
    //freopen("input.txt", "r", stdin);
#else
#endif
    
    origi();
    tiranga();
    //cout << sumOfDig(123654);
   // genLarge(10, 10);
   // genSmall(10);

}


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

int H,W;
char A[1007][1007];

//
// BFS(幅優先探索)
//
int D[1007][1007];
int vx[4] = {0,-1,0,1};
int vy[4] = {1,0,-1,0};

int bfs(){
    int ans = 0;
    queue<pair <int,int> > Q;

    // 初回で黒の場合はQに突っ込む
    for(int y = 1; y< H+1;y++){
        for(int x = 1;x < W+1;x++){
            if(A[x][y] == '#'){
                D[x][y] = 0;
                Q.push(make_pair(x,y));
            }
        }
    }

    pair <int,int> p;

    while(!Q.empty()){
        p = Q.front(); Q.pop();

        for(int i = 0;i < 4;i++){
            int nx = p.first  + vy[i];
            int ny = p.second + vx[i];

            if(nx >= 1 && nx <= W && ny >= 1 && ny <= H && A[nx][ny] == '.'){
                Q.push(make_pair(nx,ny));
                D[nx][ny] = D[p.first][p.second] + 1;
                A[nx][ny] = '#';
                if(D[p.first][p.second] + 1 > ans){
                    ans = D[p.first][p.second] + 1;
                }
            }
        }

    }

    return ans;
}


int main(){
    cin >> H >> W;
    for(int y = 1; y< H+1;y++){
        for(int x = 1;x < W+1;x++){
            cin >> A[x][y];
        }
    }

    int ans = bfs();
    cout << ans << endl;
}

Measured memory_bytes: 13328
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int h;
    int w;
    int k;
    char s[999][999];
    int a[999][999]={};
    int tmp=0;
    // int zero=0;
    int count=999;
    
    cin >> h >> w >> k;
    
    for(int i=0; i<=h-1; i++){
        
        cin >> s[i];
        
        for(int j=0; j<=w-1; j++){
            
            if(s[i][j]=='#'){
                
                tmp += 1;
                a[i][j] = tmp;
                count = min(i, count);
                
            }
            
        }
        
    }
    
    tmp = 0;
    
    for(int i=0; i<=h-1; i++){
        
        tmp = 0;
        // zero = 0;
        
        for(int j=0; j<=w-1; j++){
            
            /*
            
            if(j==0&&a[i][j]==0){ // sento=0
                
                zero = 1;
                continue;
                
            }
            
            */
            
            if(a[i][j]==0){
                
                a[i][j] = tmp;
                
            } else {
                
                if(tmp==0){
                    
                    for(int p=0; p<=j-1; p++){
                        
                        a[i][p] = a[i][j];
                        
                    }
                    
                }
                
                tmp = a[i][j];
                
            }
            
        }
        
    }
    
    if(a[0][0]==0){
        
        for(int i=0; i<=count-1; i++){
            
            for(int j=0; j<=w-1; j++){
                
                a[i][j] = a[count][j];
                
            }
            
        }
        
    }
    
    for(int i=0; i<=h-1; i++){
        
        if(a[i][0]==0){
            
            for(int j=0; j<=w-1; j++){
                
                a[i][j] = a[i-1][j];
                
            }
            
        }
        
    }
    
    // cout << "debug : " << count << endl; // debug
    
    for(int i=0; i<=h-1; i++){
        
        for(int j=0; j<=w-1; j++){
            
            cout << a[i][j];
            
            if(j<=w-2){
                
                cout << " ";
                
            }
            
        }
        
        cout << endl;
        
    }

    return 0;
    
}

Measured memory_bytes: 5504
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int n;
	string str;
	cin>>n;
	cin>>str;
	int dp[5005][5005];
    int maxx = 0;
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
		{
			if(str[i-1] == str[j-1] && dp[i-1][j-1] < j-i)
				dp[i][j] = 1 + dp[i-1][j-1];
			else
				dp[i][j] = 0;
            maxx = max(maxx, dp[i][j]);
		}
    }
    cout<<maxx;
	return 0;
}


Measured memory_bytes: 98176
#!/mnt/c/Users/moiki/bash/env/bin/python
# N,M = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
a = [ [ea, e] for e,ea in enumerate(a)]

min_ = min(a)
max_ = max(a)


if min_[0] < 0 and abs(min_[0]) > abs(max_[0]):
    cnt = 0
    for i in range(N):
        if a[i][0] > 0:
            cnt += 1
    cnt += N-1
    print(cnt)

    for i in range(N):
        if a[i][0] > 0:
            print(min_[1] +1, i+1)
    for i in range(N-1, 0,-1):
        print(i+1, i)

    
else:
    cnt = 0
    for i in range(N):
        if a[i][0] < 0:
            cnt += 1

    cnt += N-1
    print(cnt)


    for i in range(N):
        if a[i][0] < 0:
            a[i][0] += max_[0]
            print(max_[1] + 1, i+1)
    for i in range(N-1):
        # a[i+1] = a[i] + a[i+1]
        print(i+1, i+1+1)

            # print(
    
        
    


Measured memory_bytes: 38384
import collections

n = int(input())
a = list(map(int, input().split()))
count = collections.Counter(a)
ans = sum(a)

q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    diff = (c - b) * count[b]
    count[c] += count[b]
    count[b] = 0
    ans += diff
    print(ans)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S, ans; cin >> S;
    // cout << stoi(S.substr(0, 2)) << endl;
    bool flag1 = false, flag2 = false; // YY formatが確定な時
    int i1 = stoi(S.substr(0, 2)), i2 = stoi(S.substr(2, 2));
    if (i1 >= 13 || i1 <= 0){flag1 = true;}
    if (i2 >= 13 || i2 <= 0){flag2 = true;}
    if (flag1 && flag2){
        cout << "NA" << endl;
    } else if (flag1 && !flag2){
        cout << "YYMM" << endl;
    } else if (!flag1 && flag2){
        cout << "MMYY" << endl;
    } else {
        cout << "AMBIGUOUS" << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>

int max(int x, int y) {
    if (x > y) {
        return x;
    } else {
        return y;
    }
}

int main (void) {
    int N, i, j, a[100000], b[100000], c[100000], total_a[100000], total_b[100000], total_c[100000];
    scanf("%d", &N);

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

    total_a[0] = a[0];
    total_b[0] = b[0];
    total_c[0] = c[0];

    for (i = 0; i < N - 1; i++) {
        total_a[i + 1] = max(total_b[i], total_c[i]) + a[i + 1];
        total_b[i + 1] = max(total_a[i], total_c[i]) + b[i + 1];
        total_c[i + 1] = max(total_a[i], total_b[i]) + c[i + 1];
    }

    printf("%d", max(total_a[N - 1], max(total_b[N - 1], total_c[N - 1])));

    return 0;
}

Measured memory_bytes: 2560
/*
ID: flashysport101
LANG: C++
TASK:
*/
#include <bits/stdc++.h>
using namespace std;

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

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define F0R(i, a, b) for (int i = (a); i < (b); i++)
#define FOR(i, a) for (int i = 0; i < (a); i++)
#define F0RR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define FORR(i, a) for (int i = (a) - 1; i >= 0; i--)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define n << "\n"
#define k << " " <<

const int MOD = 1000000007;
const ll INF = 1e18;
const int MAXN = 1e5;
const string name = "drink";

int N, K, height[MAXN];
ll dp[MAXN];

int main() {
  cin >> N >> K;
  FOR(i,N) dp[i] = INF, cin >> height[i];
  dp[0] = 0;
  FOR(i,N) {
    if(i < K) F0R(j,1,i+1) {
      dp[i] = min(dp[i-j] + abs(height[i] - height[i-j]), dp[i]);
    }
    else F0R(j,1,K+1) {
      dp[i] = min(dp[i-j] + abs(height[i] - height[i-j]), dp[i]);
    }
  }
  cout << dp[N-1] n;
}





Measured memory_bytes: 1408
program number_div
	implicit none
	character(200000)::s
    character(3):: ans
    integer:: i, n, idx
    
    
    read(*,*) s
    n = 0
	do i = 1, len(trim(s))
        n = n + iachar(s(i:i))-iachar('0')
    end do
    if (mod(n,9) == 0) then; ans = 'Yes'; else; ans = 'No'; endif
    write(*,'(a)') ans
end program


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    unsigned long long p[m],y[m];
    unsigned long long x[m];
    for(int i=0;i<m;i++){
        cin>>p[i]>>y[i];
        x[i]=(p[i]<<47)+(y[i]<<17)+i;
    }
    sort(x,x+m);
    int c=1;
    y[(x[0]<<47)>>47]=c;
    for(int i=1;i<m;i++){
        if(x[i]>>47==x[i-1]>>47)c++;
        else c=1;
        y[(x[i]<<47)>>47]=c;
    }
    for(int i=0;i<m;i++){
        x[i]=p[i]*1000000+y[i];
        printf("%012lu\n",x[i]);
    }
}

Measured memory_bytes: 3840
package main

import "fmt"
import "os"
import "bufio"
import "bytes"
import "strconv"

const NEW_LINE byte = 10
const SPACE string = " "

type long int64
type float float32
type double float64

var reader *bufio.Reader
var buffer[][]byte
var pointer int

func InitReader() {
    reader = bufio.NewReaderSize(os.Stdin,4096)
}

func ReadLine() []byte {
    retBytes,_ := reader.ReadBytes(NEW_LINE)
    return retBytes
}

func Next() string {
    if pointer < len(buffer) {
        ret := buffer[pointer]
        pointer++
        return string(ret)
    }

    bs := ReadLine()
    bs = bs[0:len(bs)-1]
    buffer = bytes.Split(bs,[]byte(SPACE))
    pointer = 0
    return Next()
}

func NextLine() string {
    b := ReadLine()
    return string(bytes.TrimSpace(b))
}

func NextInt() int {
    s := Next()
    i,_ := strconv.ParseInt(s,10,32)
    return int(i)
}

func NextLong() long {
    s := Next()
    l,_ := strconv.ParseInt(s,10,64)
    return long(l)
}

func NextFloat() float {
    s := Next()
    f,_ := strconv.ParseFloat(s,32)
    return float(f)
}

func NextDouble() double {
    s := Next()
    d,_ := strconv.ParseFloat(s,64)
    return double(d)
}

func main() {
    InitReader()

    r := NextInt()
    g := NextInt()
    b := NextInt()

    if (r * 100 + g * 10 + b) % 4 == 0 {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

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

using namespace std;

int main(void) {
	
	int n,m,i;
	cin >>n >>m;
	
	int x[m];
	for (i=0 ; i<m ; i++) {
		cin >>x[i];
	}
	
	sort(x,x+m);
	int d[m-1];
	for (i=0 ; i<m-1 ; i++) {
		d[i]=x[i+1]-x[i];
	}
	sort(d,d+m-1);
	
	int ans=0,j;
	if (n>=m) {
		ans=0;
	} else {
		i=1;
		while (1) {
			if (n==m-i) {
				for (j=0 ; j<i ; j++) {
					ans+=d[j];
				}
				break;
			}
			i++;
		}
	}
	
	cout <<ans <<endl;
	
	return 0;
}

Measured memory_bytes: 1024
def solution(a):
    a = [a[i] - i - 1 for i in xrange(len(a))]
    a = sorted(a)
    b = a[len(a) >> 1]
    return sum([abs(i - b) for i in a])

def main():
    n = int(raw_input().strip())
    a = [int(i) for i in raw_input().strip().split()]
    print solution(a)

if __name__ == '__main__':
    main()

Measured memory_bytes: 21976
N = int(input())
X = input()

n1 = X.count("1")
Xn = int(X, 2)

Xms = (Xn % (n1 - 1)) if n1 > 1 else 0
Xml = Xn % (n1 + 1)

p2s = [1]
p2l = [1]
s2 = 1
l2 = 1
for i in range(N - 1):
    s2 = (s2 * 2) % (n1 - 1) if n1 > 1 else 0
    l2 = (l2 * 2) % (n1 + 1)
    p2s.append(s2)
    p2l.append(l2)


def f(n):
    if n == 0:
        return 0
    return f(n % bin(n).count("1")) + 1


dp = [0] * ((10 ** 5) * 2 + 1)
for i in range(1, len(dp)):
    dp[i] = f(i)


for i in range(N):
    cnt = 0
    p2 = 2 ** (N - i - 1)
    Xim = 0

    if X[i] == "1" and n1 == 1:
        print(cnt)
    elif X[i] == "1":
        print(dp[(Xms - p2s[-i - 1]) % (n1 - 1)] + 1)
    else:
        print(dp[(Xml + p2l[-i - 1]) % (n1 + 1)] + 1)



Measured memory_bytes: 103076
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using graph = vector<vector<long long int>>;
using wgraph = vector<vector<pair<long long int, long long int>>>;
long long int INF = 1001001001001001LL;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(long long int i = 0; i < (n); i++)
#define rrep(i,n) for(long long int i = 1; i <= (n); i++)
#define drep(i,n) for(long long int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(long long int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  string s, t; cin >> s >> t;
  int ans = 0;
  rep(i, 3) ans += (s[i] == t[i]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,a[200010],b[200010],ans[200010];
set<int>st;
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    reverse(b,b+n);
    rep(i,n){
        if(a[i]==b[i]){
            int l=i,r=i,x=a[i],pos=l;
            for(int j=l;j<n;j++){
                if(a[j]==b[j])r=j;
            }
            rep(k,n){
                if(pos>r)break;
                if(a[k]!=x&&b[k]!=x){
                    swap(b[pos],b[k]);
                    pos++;
                }
            }
            break;
        }
    }
    rep(i,n){
        if(a[i]==b[i]){
            puts("No");
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    rep(i,n)cout<<b[i]<<" ";
    cout<<endl;
    return 0;
}


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

int main() {
  string s;cin>>s;
  bool ans=true;
  if(s[0]!='A')ans=false;
  int cnt=0;
  for(int i=2;i<s.size()-1;i++){
    if(s[i]=='C')cnt++;
  }
  if(cnt!=1)ans=false;
  int a=0;
  rep(i,s.size()){
    if(islower(s[i]))a++;
  }
  if(s.size()-a!=2)ans=false;
  if(ans)cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
}

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

int n,ans;

void rec(int sum,int s,int lim){

  if(sum == n){
    ans++;
    return;
  }

  if(sum > n || lim >= 4) return;

  for(int i = s ; i*i <= n ; i++){
    rec(sum + i*i , i , lim+1);
  }

}

int main(){

  while(cin >> n ,n){
    ans = 0;
    rec(0,1,0);    

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll x[100005];
ll y = 0;
int main(){
	scanf("%d",&n);
	rep(i,n){
		scanf("%lld",&x[i]);
	}
	sort(x,x+n);
	ll ans = x[0]%mod;
	for(int i=1;i<n;i++){
		ans = ans * __gcd(1LL*i,x[i]) % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
n = int(input())
ans = float("INF")
for i in range(1, n):
    t = list(str(n - i))
    t = [int(m) for m in t]
    u = list(str(i))
    u = [int(m) for m in u]
    if ans > int(sum(t) + sum(u)):
        ans = int(sum(t) + sum(u))
print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
import itertools

MOD = 2019  # type: int

def solve(L: int, R: int):
    if R - L + 1 >= 2019:
        print(0)
    else:
        m = 2019
        for i, j in itertools.combinations(range(R-L+1), 2):
            if m > ((i+L)*(j+L) % 2019):
                m = (i+L) * (j + L) % 2019
        print(m)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    int n;
    cin >> n;
    vector<int> a(n);

    rep(i,n){
        cin >> a[i];
    }

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

    int cnt = 1;
    int ans = 0;
    int now = a[0];

    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            cnt+=1;
        }
        else{
            if(cnt<now){
                ans += cnt;
            }
            else{
                ans+=cnt-now;
            }
            now=a[i];
            cnt=1;
        }
    }
    if(cnt<now){
        ans += cnt;
    }
    else{
        ans+=cnt-now;
    }


    cout << ans;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1), cnt(n + 1);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    ++cnt[a[i]];
  }
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans += 1ll * cnt[i] * (cnt[i] - 1) / 2;
  }
  for (int i = 1; i <= n; ++i) {
    int x = a[i];
    ll cur = ans - 1ll * cnt[x] * (cnt[x] - 1) / 2 + 1ll * (cnt[x] - 1) * (cnt[x] - 2) / 2;
    printf("%lld\n", cur);
  }
}

Measured memory_bytes: 4096
#include<stdio.h>
int main()
{
	int A, B;
	int a, b, c, i;
	scanf("%d", &a);
	for (i = 1; i <= 9; i++)
		for (b = 1; b <= 9; b++)
			if (a == i * b)
			{printf("Yes\n"); return 0;
              }
				printf("No");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[100009],dp[100009],k;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    for(ll i=0; i<n; i++)
        cin>>a[i];
    for(ll i=1; i<n; i++)
    {
        dp[i]=LLONG_MAX;
        for(ll j=max(0LL,i-k); j<i; j++)
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 5180
import Control.Monad                                                                                                       
import Data.List                                                                                                           
                                                                                                                           
main :: IO ()                                                                                                              
main = do                                                                                                                  
  [n,m] <- map read . words <$> getLine :: IO [Int]                                                                        
  as <- replicateM n getLine                                                                                               
  bs <- replicateM m getLine                                                                                               
                                                                                                                           
  putStrLn $ if isMatch n m as bs then "Yes" else "No"                                                                     
                                                                                                                           
isMatch :: Eq a => Int -> Int -> [[a]] -> [[a]] -> Bool                                                                    
isMatch n m as bs                                                                                                          
  | n < m = False                                                                                                          
  | otherwise = if isInfixOf bs $ map (take m . drop (n-m)) as                                                             
                then True                                                                                                  
                else isMatch (n-1) m as bs

Measured memory_bytes: 1020
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

void pv(const vector<vi> &v){
	rep(i, 4) rep(j, 8) cerr<<v[i][j]<<(j==7?"\n":" ");
}

int main(){
	int cs;
	cin >> cs;
	vector<vi> goal(4, vi(8));
	rep(i, 4) rep(j, 7) goal[i][j] = (i + 1) * 10 + j + 1;
	
	while(cs--){
		vector<vi> v(4, vi(8));
		rep(i, 4) rep(j, 7){
			cin >> v[i][j + 1];
			if(v[i][j + 1] % 10 == 1){
				int t = v[i][j + 1] / 10 - 1;
				swap(v[i][j + 1], v[t][0]);
			}
		}
		if(v == goal){
			cout << 0 << endl;
			continue;
		}
		set<vector<vi> > s;
		queue<pair<vector<vi>, int> > q;
		q.push(mp(v, 0));
		s.insert(v);
		while(!q.empty()){
			v = q.front().first;
			int c = q.front().second; q.pop();
			
			int pos[50] = {};
			rep(i, 4) rep(j, 8) pos[v[i][j]] = i * 10 + j;
			rep(i, 4) rep(j, 8) if(v[i][j] == 0){
				int t = v[i][j - 1] + 1;
				if(t == 1 || t % 10 == 8) continue;
				t = pos[t];
				
				swap(v[i][j], v[t / 10][t % 10]);
				if(!s.count(v)){
					if(v == goal){
						cout << c + 1 << endl;
						goto END;
					}
					s.insert(v);
					q.push(mp(v, c + 1));
				}
				swap(v[i][j], v[t / 10][t % 10]);
			}
		}
		cout << -1 << endl;
		END:;
	}
	return 0;
}

Measured memory_bytes: 24836
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
        cout << "YES";
    else 
        cout << "NO";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    
    if(a%2==1 && b%2==1){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23764
n,m=map(int,input().split())
a=[]
for _ in range(m):
    s,c=map(int,input().split())
    a.append((s-1,c))
for i in range(0,1001):
    r=str(i)
    j=1
    if len(r)==n:
        for idx,char in a:
            if r[idx]!=str(char):
                j=0
                break
        if j:
            print(r)
            exit()
print(-1)
            

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200)
    cout << s;
  else
    cout << "red";
}


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

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

using namespace std;

bool scope(int &a, int &b)
{
    return a > b; //降順
}

int main()
{
    int k, t;  cin >> k >> t;
    vector<int> a(t);   rep(i, t) cin >> a[i];

    sort(a.begin(), a.end(), scope);

    int sum = 0;
    for(int i = 1; i < t; i++){
        sum += a[i];
    }

    cout << max(a[0] - 1 - sum, 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main(){
    float d=0, t=0, s=0;
    cin >> d >> t >> s;

    float v = d/t;

    if(v<=s){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3728
#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
	
#define WHATS(var)cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
	os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it;
		i++;
	} 
	return os;
}
using ll=long long ;

int main() {
	ios::sync_with_stdio(false);
	// int a,b,c,d;cin>>a>>b>>c>>d;
	// cout<<(int(b>d))<<endl;

	int N;cin>>N;
	int answer=-1;
	for(int i=1;i<50000;++i){
		int j=i*108;
		j/=100;
		if(j==N){
			answer=i;
			break;
		}
	}
	if(answer==-1)cout<<":("<<endl;
	else cout<<answer<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//Fast io
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
//Class shorthands
#define ll long long
#define db long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
//Function Shorthands
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define po pop_back
#define eb emplace_back
//Code Shorthands
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
//Constants
#define hell 1000000007
#define PI acos(-1.0)
using namespace std;
bool check(ll a, ll b, ll c){
	int m = max({a,b,c});
	if(a==b || a==c || b==c) return false;
	return a+b+c-m>m;
}
void solve(){
	ll x,k,d;
	cin>>x>>k>>d;
	x = max(x, -1*x);
	ll f = x/d;
	if(f>k){
		cout<<x-k*d<<endl;
	}
	else{
		k-=f;
		if(k%2==0) cout<<x-f*d<<endl;
		else cout<<-1*(x-(f+1)*d)<<endl;
	}
}

int main(){
	io;
	int t = 1;
	//cin>>t;
	while(t--){
		solve();
	}
}

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

int main() {
  ll N; cin >> N;
  ll tmp = sqrt(N); int ans = 11;
  rep(i,1,tmp+1) {
    if (N % i ==0) {
      ll tmp = max((ll)i,N / i);
      int a =0;
      while (tmp !=0) {
        a++;
        tmp /= 10;
      }   
      ans = min(a,ans);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3676
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int res = Math.min(b/a, c);
        System.out.println(res);

    }

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h1,m1;
    cin >> h1 >> m1;
    int h2,m2;
    cin >> h2 >> m2;
    int k;
    cin >> k;
    int m,h;
    if (m2 - m1 >= 0){
      m = m2 - m1;
      h = h2 - h1;
    }
    else{
      m2 += 60;
      h2 -= 1;
      m = m2 - m1;
      h = h2 - h1;
    }
    cout << h * 60 + m - k << endl;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root=NIL;
Node treeMinimum(Node );
Node treeMaximum(Node );
Node treeSearch(Node , int );
Node treeSuccessor(Node );
void treeDelete(Node );
void insert(int );
void inorder(Node );
void preorder(Node );

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Node treeMinimum(Node x){
  if(x->left == NIL) return x;
  
  else treeMinimum(x->left);
  
  return x;
}

Node treeMaximum(Node x){
  if(x->right == NIL) return x;
  
  else treeMaximum(x->right);
  
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL) return u;
  
  else if(k == u->key) return u;
  
  else if(k < u->key) return treeSearch(u->left,k);
  
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node a;

  
  if(x->right != NIL) return treeMinimum(x->right);
  a = x->parent;
  
  while(1){
    if(a == NIL && x->key != a->right->key) break;
    x = a;
    a = a->parent;
  }
  
  return a;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  
  if(z->left == NIL) y=z;
  else if(z->right == NIL) y=z;
  else y = treeSuccessor(z);

  
  if(y->left!=NIL) x=y->left;
  else x = y->right;


  if(x!=NIL) x->parent = y->parent;
  
  
  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y!=z) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right;
    
  }
  z->parent = y;
  
  if(y == NIL) root = z;
  
  else if(z->key < y->key) y->left = z;
  
  else y->right = z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u==NIL) return ;
  
  printf(" %d",u->key);
  
  preorder(u->left);
  
  preorder(u->right);
}





Measured memory_bytes: 20448