akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long K = scan.nextLong();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt()-1;
        }
        int loop_length = 1;
        int current = 0;
        Map<Integer, Integer> used = new HashMap<>();
        used.put(0, 1);
        while (!used.containsKey(A[current])) {
            current = A[current];
            loop_length += 1;
            used.put(current, loop_length);
        }
        int prefix_length = used.get(A[current])-1;
        if (K <= loop_length) {
            current = 0;
            while(0 < K) {
                current = A[current];
                K -= 1;
            }
            System.out.println(current+1);
            return;
        }
        long remain = K - prefix_length;
        loop_length -= prefix_length;
        remain %= loop_length;
        current = 0;
        while (0 < prefix_length) {
            current = A[current];
            prefix_length -= 1;
        }
        while (0 < remain) {
            current = A[current];
            remain -= 1;
        }
        System.out.println(current+1);
    }
}



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

int main() {
	int H, W;
	cin >> H >> W;
	vector<int> b(26);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char a;
			cin >> a;
			b[a - 'a']++;
		}
	}
	int c = H % 2 * W + W % 2 * H;
	if (H % 2 && W % 2) c--;
	if (c % 2) {
		vector<int>::iterator d = find_if(b.begin(), b.end(), [](int& a) { return a % 2; });
		if (d == b.end()) {
			cout << "No";
			return 0;
		}
		(*d)--;
		c--;
	}
	if (find_if(b.begin(), b.end(), [](int& a) { return a % 2; }) != b.end()) {
		cout << "No";
		return 0;
	}
	while (c != 0) {
		vector<int>::iterator d = find_if(b.begin(), b.end(), [](int& a) { return a % 4; });
		if (d == b.end()) {
			vector<int>::iterator e = find_if(b.begin(), b.end(), [](int& a) { return a != 0; });
			*e -= 2;
			c -= 2;
		}
		else {
			*d -= 2;
			c -= 2;
		}
	}
	c = H % 2 * W + W % 2 * H;
	if (H % 2 && W % 2) c--;
	if (H * W == c) cout << "Yes";
	else {
		if (find_if(b.begin(), b.end(), [](int& a) { return a % 4; }) != b.end()) cout << "No";
		else cout << "Yes";
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int a[100000],b[100000];
int cnt=0;
int c,i,j;
int main(void){
	while(1){
		scanf("%d %d",&a[cnt],&b[cnt]);
		if((a[cnt]==0)&&(b[cnt]==0)) break;
		cnt++;
	}//cnt1大きい

	for(c=0;c<cnt;c++){
		for(i=0;i<a[c];i++){
			for(j=0;j<b[c];j++){
				printf("#");
			}
			printf("\n");//次の行
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int c[3][3], b[3], a[3];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	rep(i,3)rep(j,3) cin >> c[i][j];
	for(int a0 = -100; a0 <= 100; ++a0){
		a[0] = a0;
		rep(j,3) b[j] = c[0][j] - a[0];
		rep(j,3) a[j] = c[j][0] - b[0];
		bool ok = true;
		rep(i,3)rep(j,3){
			if(a[i]+b[j] != c[i][j]) ok = false;
		}
		if(ok){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import math
from itertools import combinations
N,D = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]

combination = list(combinations(range(N),2))

cnt = 0
for i,j in combination:
  distance = 0
  for k in range(D):
    distance += abs(X[i][k] - X[j][k]) ** 2
  distance = math.sqrt(distance)
  if distance == math.floor(distance):
    cnt += 1
    
print(cnt)

Measured memory_bytes: 9132
#include "bits/stdc++.h"
 
using namespace std;
 
#define ll long long int
#define FOR(i,a,b) for(ll i = a;i<b;i++)
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
int main(){
    boost;
    ll n;
    cin>>n;
    map<ll,ll>m;
    ll sm = 0;
    FOR(i,0,n){
        ll x;
        cin>>x;
        m[x]+=1;
        sm+=x;
    }
    
    ll q;
    cin>>q;
    while(q--){
        ll b,c;
        cin>>b>>c;
        if(m[b]){
            m[c]+=m[b];
            ll diff = (c-b)*m[b];
            m[b] = 0;
            sm+=diff;
        }
        cout<<sm<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 9352
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <cstring>

int n, k;
std::vector<int> cat[10];

int dp[11][2010];

int main() {
    for(int i = 0; i < 10; ++i) {
        cat[i].push_back(0);
    }
    std::cin >> n >> k;

    for(int i = 0; i < n; ++i) {
        int a, b;
        std::cin >> a >> b;
        --b;
        cat[b].push_back(a);
    }
    for(int i = 0; i < 10; ++i) {
        std::sort(cat[i].begin() + 1, cat[i].end(), std::greater<int>());
    }
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    for(int i = 0; i < 10; ++i) {
        for(int j = 1; j < cat[i].size(); ++j) {
            cat[i][j] += cat[i][j - 1] + (j - 1) * j - (j - 2) * (j - 1);
        }
        for(int m = 0; m <= k; ++m) {
            if(dp[i][m] != -1) {
                for(int j = 0; j < cat[i].size(); ++j) {
                    dp[i + 1][m + j] = std::max(dp[i + 1][m + j], dp[i][m] + cat[i][j]);
                }
            }
        }
    }

    std::cout << dp[10][k] << std::endl;
}

Measured memory_bytes: 3248
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = 0;
        ans = (1900*m + 100*(n-m))*(int) Math.pow(2,m);
        System.out.println(ans);
    }
}


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

using namespace std;

typedef long long ll;

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

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

	vector<int> v(m, 0);
	rep(i, n){
		int k;
		cin >> k;

		rep(i, k){
			int a;
			cin >> a;
			v[a-1]++;
		}
	}

	int ans = 0;
	rep(i, m) if(v[i] == n) ans++;

	cout << ans << endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int main(){
    int a,b;
    cin>>a>>b;
    if(b%a==0){
        cout<<a+b<<endl;
    }
    else{
        cout<<b-a<<endl;
    }
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int counter = 0;

  for (int i = 0; i < N-2; i++) {
    if (S.substr(i, 3) == "ABC") counter++;
  }

  cout << counter << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n,r;cin>>n>>r;
    if(n<10)r+=100*(10-n);
    cout<<r;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
    long long a;
    double b;
    cin>>a>>b;
    long long d=b*100+0.5;
    long long c=a*d;
    long long e=c/100;
    cout<<e;
    return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef int64_t Int;
const double pi = M_PI;

int main()
{
    int H, W;

    while (true)
    {
        cin >> H >> W;
        if (H == 0 && W == 0)
        {
            break;
        }

        for (int j = 0; j < W; j++)
        {
            cout << '#';
        }
        cout << endl;

        for (int i = 1; i < H - 1; i++)
        {
            cout << '#';
            for (int j = 1; j < W - 1; j++)
            {
                cout << '.';
            }
            cout << '#';
            cout << endl;
        }
        for (int j = 0; j < W; j++)
        {
            cout << '#';
        }
        cout << endl;
        cout << endl;
    }
}



Measured memory_bytes: 3112
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int x= sc.nextInt();
        int[] a = new int[N];
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);
        int ans = 0;
        boolean flag = false;
        for(int i = 0; i < N; i++){
            //飴が全て配れないかつぴったり配れたときの例外処理
            if(x == a[i]){
                ans++;
                flag = true;
                break;
            }
            //飴が全て配れなかった時ansを-1しないための例外処理
            else if(x < a[i]){
                ans++;
                break;
            }
            else if(x > 0){
                x -= a[i];
                ans++;
            }
        }

        if(flag) System.out.println(ans);
        else if(ans == 0) System.out.println("0");
        //全て配れて飴が余った時はans-1
        else if(x > 0) System.out.println(ans - 1);

    }
}


Measured memory_bytes: 23636
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=1030;
int a[MAXN][MAXN],n,m;
int main()
{
	n=read();m=read();int h=max(n,m);
	a[1][1]=1;
	for(int i=2;i<=h;i++)
	{
		int lm=(1<<(i-1));
		for(int j=lm;j<2*lm;j++)for(int k=0;k<lm;k++)
			a[j][k]=a[j-lm][k];
		for(int j=0;j<lm;j++)for(int k=lm;k<2*lm;k++)
			a[j][k]=a[j][k-lm];
		for(int j=lm;j<2*lm;j++)for(int k=lm;k<2*lm;k++)
			a[j][k]=a[j-lm][k-lm]^1;
	}
	if(n<=m)
	{
		for(int i=1;i<(1<<n);i++)
		{
			for(int j=1;j<(1<<m);j++)write(a[i][j]^a[i-1][j]^a[i][j-1]^a[i-1][j-1]);
			puts("");
		}
	}
	else
	{
		for(int j=1;j<(1<<n);j++)
		{
			for(int i=1;i<(1<<m);i++)write(a[i][j]^a[i-1][j]^a[i][j-1]^a[i-1][j-1]);
			puts("");
		}
	}
	return 0;
}


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

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

using namespace std;
typedef long long ll;


int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	ll ans = 0;
	rep(i, n) {
		while(1) {
			if (a[i] % 2 != 0) break;
			a[i] /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

public class Main {

    public static void main(String[] args)throws Exception {
        InputReader in = new InputReader(System.in);
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
        // write your code here //
        String s1 = in.next();
        String s2 = in.next();
        int count = 0;
        for (int i = 0; i < s1.length(); i++) {
            if(s1.charAt(i) != s2.charAt(i)) {
                count++;
            }
        }
        pw.println(count);

        pw.close();
    }



    /******************************
     ** IO STUFF STARTS FROM HERE**
     ******************************/

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

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        //InputReader in = new InputReader(new FileReader("File_Name"));
        public InputReader(FileReader file) {
            reader = new BufferedReader(file);
            tokenizer = null;
        }

        public String next() {

            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens())
                    tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                return null;
            }

            return tokenizer.nextToken();
        }

        public String nextLine() {
            String line = null;
            try {
                tokenizer = null;
                line =  reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

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

        public boolean hasNext(){
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens())
                    tokenizer = new StringTokenizer(reader.readLine());
            }
            catch (Exception e) {
                return false;
            }
            return true;
        }
    }
}

Measured memory_bytes: 36976
#include <stdio.h>

int main(void)
{
	int n, i, p;
	int NotPlusOneNumCount = 0;

	scanf("%d", &n);

	//1,2,3...Nの並びと、与えられた数列Pで一致しない箇所があれば flag を 1 増やす
	for (i = 0; i < n; i++) {
		scanf("%d", &p);
		if (p != i + 1) {
			NotPlusOneNumCount++;
		}
		//not_plus_one_countが2より大きいとき、昇順にできない
		if (NotPlusOneNumCount > 2) {
			printf("NO\n");
			return 0;
		}
	}

	printf("YES\n");

	return 0;
}

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

#include <atcoder/all>

// #LIB#

using namespace std;
using namespace atcoder;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#ifdef ONLINE_JUDGE
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');
#endif

int main() {
  ll n;
  cin >> n;
  vector<ll> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  vector<ll> xr(n + 1), yr(n + 1);
  dsu g(n);
  rep(i, n) {
    xr[x[i]] = i;
    yr[y[i]] = i;
  }
  set<ll> left_ys;
  repr(x, 1, n + 1) {
    auto i = xr[x];
    auto ly = left_ys.lower_bound(y[i]);
    if (ly != left_ys.begin()) {
      auto c = ly;
      ll ymin;
      while (c != left_ys.begin()) {
        --c;
        g.merge(i, yr[*c]);
        updatemin(ymin, *c);
      }
      while (ly != left_ys.begin()) {
        auto c = ly;
        --c;
        left_ys.erase(c);
      }
      left_ys.insert(ymin);
    }
    left_ys.insert(y[i]);
  }
  rep(i, n) cout << g.size(i) << endl;
}


Measured memory_bytes: 13696
#
# abc042 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1000 8
1 3 4 5 6 7 8 9"""
        output = """2000"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """9999 1
0"""
        output = """9999"""
        self.assertIO(input, output)


def resolve():
    N, K = map(int, input().split())
    D = list(input().split())

    for i in range(100000):
        if i < N:
            continue
        for d in D:
            if str(i).count(d) != 0:
                break
        else:
            print(i)
            break


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16188
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 1000000000
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define AU(i,x)    for(auto i=x.begin(); i!=x.end(); ++i)
# define ALL(A) A.begin(),A.end()
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int N=100005;
///Code begin..................................................................
inline LL Scan() {
    LL x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}


int main()
{
    int n, tmp, sum=0;
    scanf("%d",&n); tmp=n;
    while (n) sum+=n%10, n/=10;
    puts(tmp%sum==0?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    final  static int[] rate = {399,799,1199,1599,1999,2399,2799,3199};
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        boolean[] color = new boolean[8];
        int freeColorCount=0;
        for(int i = 0;i<n;i++) {
            a[i] = sc.nextInt();
            for(int j = 0;j<rate.length;j++){
                if(a[i]<=rate[j]){
                    color[j] =true;
                    break;
                }
                if(a[i]>rate[rate.length-1]){
                    freeColorCount++;
                    break;
                }
            }
        }
        int ans= 0;
        for(int i = 0;i<color.length;i++)if(color[i])ans++;
        System.out.print(ans==0?1:ans);
        System.out.println(" "+(ans+freeColorCount));
    }
}


Measured memory_bytes: 38540
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS

solve :: U.Vector Char -> Int -> Int
solve !s !d = min d $ U.maximum $ U.scanr' (\(c1,c2) !x -> if c1 == c2 then x + 1 else 0) 0 $ U.zip s (U.drop d s)

main = do
  n <- readLn :: IO Int
  s <- BS.getLine
  let s' = U.generate (BS.length s) $ BS.index s
  print $ maximum [solve s' d | d <- [1..n]]


Measured memory_bytes: 2172
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
	int a;

	int num = 0;

	cin >> a;

	num += a % 10;
	num += (a/10) % 10;
	num += (a/100) % 10;


	cout << num << endl;
	
	return 0;
}	


Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define _ << " " <<
#define all(v) v.begin(), v.end()

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b;
	cin >> a >> b;
	cout << (3 * a + b) / 2;
	return 0;
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define MAX 1000000001





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

    vector<ll> a(n);
    vector<ll> in(n+1,0);

    rep(i,n){
        cin>>a.at(i);
        in.at(a.at(i))++;
    }

    ll sum=0;
    for(int i=1;i<=n;i++){
        sum += in.at(i)*(in.at(i)-1)/2;
    }

    ll v;
    rep(i,n){
        v = -in.at(a.at(i))+1;
        cout<<sum+v<<endl;
    }
}

Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include <algorithm>
#include <functional>

using namespace std;

int main (void){
    int N,L;
    cin >> N >> L;

    int sum = 0;

    int a;
    int min = 10000;
    int mina = 10000;
    for (int i=0; i < N;i++){
        sum = sum + (L+i);
        if(abs(L+i) < min ){
            min = abs(L+i);
            mina = L+i;
        } 
    }

    sum = sum - mina;
    cout << sum;




    return 0; 
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;


int main(){
    
    char c;
    cin>>c;
    cout<<char(c+1)<<endl;
    
    return 0;

}
/*


*/


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

int main()
{
    char a[100];
    scanf("%s",a);
    int len  = strlen(a);
    int ans = 0;
    for(int i = 0; i < len; i++)
    {
        if(a[i] == '+') ans++;
        else ans--;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <stdio.h>

using namespace std;
using ll = long long;
using ld = long double;
template <class T> using vec = std::vector<T>;
template <class T> using vvec = std::vector<std::vector<T>>;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    int N; cin >> N;
    vec<int> v(N);
    REP(i, 0, N) cin >> v[i];
    sort(v.begin(), v.end());

    ld result = v[0];
    REP(i, 1, N)
    {
        result += v[i];
        result /= 2;
    }

    cout << fixed << setprecision(10) << result << endl;

    return 0;
}


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

using System.Collections;

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        s = s.Replace('1', '*').Replace('9', '1').Replace('*', '9');

        Console.WriteLine(s);
    }
    
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N, M, X; cin >> N >> M >> X;
  vector<vector<int>> A(N, vector<int>(M+1));
  for(int i=0;i<N;i++){
    for(int j=0;j<M+1;j++){
      cin >> A[i][j];
    }
  }
  int ans=10000000;
  for(int i=0;i<(1<<N);i++){
    int d[N];
    bool ok=true;
    int C=0;
    for(int j=0;j<N;j++){
      if(i>>j&1){
        d[j]=1;
      }
      else d[j]=0;
      C+=d[j]*A[j][0];
    }
    for(int j=1;j<=M;j++){
      int a=0;
      for(int k=0;k<N;k++){
        a+=d[k]*A[k][j];
      }
      if(a<X) ok=false;
    }
    if(ok) ans=min(C,ans);  
  }
  if(ans==10000000){
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){

	int n, i=1, x;

	scanf("%d", &n);

	do {
		x = i;
		if (x % 3 == 0) printf(" %d", i);
		else {
			do {
				if (x % 10 == 3) {
					printf(" %d", i);
					break;
				}
				else x /= 10;
			} while (x);
		}
	} while (++i <= n);

	printf("\n");

return 0;

}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s,a,b;
	cin>>n;
	cin>>s;
	a=s.substr(0,n/2);
	b=s.substr(n/2);
	if(a==b){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main(){
  string S;
  cin>>S;
  int ans=0;
  for(int i=1;i<S.length();i++){
    if(S[i]!=S[i-1]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt(); // 1
    int B = sc.nextInt(); // 0
    int C = sc.nextInt(); // -1
    int K = sc.nextInt(); // total

    int sum = 0;

    if(A<K){
      K = K -A;
      sum +=A;
    }else{
      System.out.println(K);
      return;  
    }
    if(B<=K){
      K = K - B;
    }else{
      System.out.println(K);
      return;  
    }
    System.out.println(sum-K);  
    return;
  }
}





Measured memory_bytes: 35736
#include <bits/stdc++.h>
using namespace std;
#define int long long //int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
template <class A, class B>
bool chmax(A &a, const B &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using P = pair<int, int>;
#define all(x) (x).begin(), (x).end()
constexpr int inf = 0x3f3f3f3f;
 
signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
 
  int N, L;
  cin >> N >> L;
  vector<P> a;
  rep(i, 0, N) {
    int p, d;
    cin >> p >> d;
    a.emplace_back(p, d * 2 - 1);
  }
  sort(all(a));
 
  int ans = 0;
  int now = 0;
 
  rep(i, 0, N) now -= (a[i].first - (i + 1)) * a[i].second;
  ans = now;
  reps(i, 0, N) {
    now += (L - N) * a[i].second;
    chmax(ans, now);
  }
 
  cout << ans << '\n';
  return 0;
}


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

int main()
{
  	int n, l;
  	cin>>n>>l;
  	vector<string> v;
  	for(int i = 0; i < n; i++)
    {
    	string a;
      	cin>>a;
      	v.push_back(a);
    }
  	sort(v.begin(), v.end());
  	for(int i = 0; i < n; i++)
    {
    	cout<<v[i];
    }
  	cout<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a,b,c,x;

  scanf("%d %d %d",&a,&b,&c);

  if (a > b) {x = a;a = b;b = x;}
  if (b > c) {x = b;b = c;c = x;}
  if (a > b) {x = a;a = b;b = x;}

  printf("%d %d %d\n",a,b,c);

  return 0;

}
  

Measured memory_bytes: 596
n=int(input())
ab=[list(map(int,input().split())) for i in range(n-1)]
data=[[] for i in range(n+1)]
for u in ab:
    a,b=u
    data[a].append(b)
    data[b].append(a)
flag=[0]*(n+1)
s=[1]
g=[n]
flag[1]="B"
flag[n]="W"
while s or g:
    H=[]
    for u in s:
        for v in data[u]:
            if flag[v]==0:
                flag[v]="B"
                H.append(v)
    s=H
    H=[]
    for u in g:
        for v in data[u]:
            if flag[v]==0:
                flag[v]="W"
                H.append(v)
    g=H
Bcount=0
Wcount=0
for i in range(1,n+1):
    if flag[i]=="B":
        Bcount+=1
    elif flag[i]=="W":
        Wcount+=1
if Bcount>Wcount:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 35564
"""
オーソドックスなDP
メモリ効率を考えるとdp部分は３要素だけで足りるか
"""
N = int(input())

H = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[0] - H[1])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))

print(dp[-1])


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

#define ED return 0;
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) int(pow(x,y))
const long mod = 1000000007;

int main() {
    string s;
    cin >> s;
    bool test1 = false;
    bool test2 = false;
    bool test3 = true;
    for(int i = 0;i < s.size();i++){
        if(i == 0 && s.at(0) == 'A'){
            test1 = true;
            continue;
        }
        if(i > 1 && i < s.size() - 1){
            if(s.at(i) == 'C' && test2 == false){
                test2 = true;
                continue;
            }
        }
        if((s.at(i) >= 'A') && (s.at(i) <='Z')){
            test3 = false;
        }
    }
    if(test1 && test2 && test3){
        cout << "AC" << endl;
        ED
    }
    cout << "WA" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int n;
	int a;
	scanf("%d", &n);
	a = n % 10;
	if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) {
		printf("hon\n");
	}
	else if (a == 0 || a == 1 || a == 6 || a == 8) {
		printf("pon\n");
	}
	else {
		printf("bon\n");
	}
}

Measured memory_bytes: 1600
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define all(A) A.begin(),A.end()
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
typedef std::vector<int> vi;
typedef std::pair<int,int> pi;
typedef std::vector<pi> vp;
typedef long long ll;
#define popcnt(x) __builtin_popcount(x)
#define LSOne(x) ((x) & (-(x)))
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
#define what_is(x) cerr << #x << " is " << x << endl
#define bit_lg(x) (assert(x > 0),__builtin_ffsll(x) - 1)
const double PI = acos(-1);
template<class A,class B>
std::ostream& operator << (std::ostream& st,const std::pair<A,B> p) {
	st << "(" << p.first << ", " << p.second << ")";
	return st;
}
using namespace std;




int main(){
#ifdef HOME
	freopen("in.in", "r", stdin);
#endif
	int h1, m1; cin >> h1 >> m1;
	int h2, m2; cin >> h2 >> m2;
	int K; cin >> K;
	
	int len = (h2*60 + m2) - (h1*60 + m1);
	
	cout << len - K << endl;
	
	return 0;
}


Measured memory_bytes: 3672
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

class C
{
public:
	ll n;
	int c3;
	int c5;
	int c7;

	C(ll n, int c3, int c5, int c7)
	{
		this->n = n;
		this->c3 = c3;
		this->c5 = c5;
		this->c7 = c7;
	}
};
int main()
{	
	ll N;
	cin >> N;

	queue<C> q;
	q.emplace(3, 1, 0, 0);
	q.emplace(5, 0, 1, 0);
	q.emplace(7, 0, 0, 1);

	int count = 0;

	while (true)
	{
		auto c = q.front(); q.pop();

		if (c.n > N) break;

		if (c.c3 >= 1 && c.c5 >= 1 && c.c7 >= 1) count++;

		q.emplace(10 * c.n + 3, c.c3 + 1, c.c5    , c.c7    );
		q.emplace(10 * c.n + 5, c.c3    , c.c5 + 1, c.c7    );
		q.emplace(10 * c.n + 7, c.c3    , c.c5    , c.c7 + 1);
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define P pair<int,int>

signed main(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(abs(a-b)>1000000000000000000)puts("Unfair");
	else if(k%2){
		cout<<b-a<<endl;
	}
	else cout<<a-b<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  int N;
  cin >> N;
  int x[N], y[N], h[N];

  for(int i=0;i<N;i++){
    cin >> x[i] >> y[i] >> h[i];
  }

  int xtop_ans, ytop_ans;
  

  for(int xtop=0;xtop<=100;xtop++){
    for(int ytop=0;ytop<=100;ytop++){
      int minus[N];
      int norm[N];

      for(int i=0;i<N;i++){
        minus[i] = abs(xtop-x[i]) + abs(ytop-y[i]);
      }
      int origin;
      for(int i=0;i<N;i++){
        if(h[i]){
          origin = i;
          break;
        }
      }
      bool find = true;
      
      for(int i=0;i<N;i++){
        if(h[origin]+minus[origin]-minus[i]>0){
          if(h[i] != h[origin]+minus[origin]-minus[i]){
            find = false;
            break;
          }
        }else{
          if(h[i]!=0){
            find = false;
            break;
          }
        }
      }

      if(find){
        xtop_ans = xtop;
        ytop_ans = ytop;
        int topheight = h[origin] + minus[origin];
        cout << xtop_ans << " " << ytop_ans << " "<< topheight <<endl;
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
#define ld long double
#define inf 1000000000
using namespace std;
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
#define N 200005
#define lc (o<<1)
#define rc (o<<1|1)
int n,a[N],tr[2][N<<1];
int Min(int x,int y){ return a[x]<a[y]?x:y; }
void up(int typ,int o){ tr[typ][o]=Min(tr[typ][lc],tr[typ][rc]); }
void build(int typ,int o,int l,int r){
	if (l==r){ tr[typ][o]=2*l-typ; return; }
	int mid=l+r>>1;
	build(typ,lc,l,mid); build(typ,rc,mid+1,r);
	up(typ,o);
}
int qry(int typ,int o,int l,int r,int x,int y){
	if (x<=l && r<=y) return tr[typ][o];
	int mid=l+r>>1,ret=0;
	if (x<=mid) ret=Min(ret,qry(typ,lc,l,mid,x,y));
	if (y>mid) ret=Min(ret,qry(typ,rc,mid+1,r,x,y));
	return ret;
}
void modify(int typ,int o,int l,int r,int x){
	if (l==r){ a[l]=inf; return; }
	int mid=l+r>>1;
	if (x<=mid) modify(typ,lc,l,mid,x); else modify(typ,rc,mid+1,r,x);
	up(typ,o);
}
struct node{
	int l,r,x,y,tg; node(){}
	node(int l_,int r_,int tg_){
		l=l_,r=r_,tg=tg_;
		if (l+1==r) x=l,y=r;
		else{
			if (!tg) x=qry(tg^1,1,1,n/2,(l+1)/2,r/2),y=qry(tg,1,1,n/2,(x+1)/2,r/2);
			else x=qry(tg^1,1,1,n/2,(l+1)/2,r/2),y=qry(tg,1,1,n/2,(x+2)/2,(r+1)/2);
		}
	}
	bool operator < (const node &t) const{ return a[x]>a[t.x]; }
};
priority_queue<node> q;
void ins(int x,int y,int tg){ if (x<y) q.push(node(x,y,tg)); }
int main(){
	n=read();
	rep (i,1,n) a[i]=read(); a[0]=inf;
	build(1,1,1,n/2); build(0,1,1,n/2);
	q.push(node(1,n,0));
	rep (step,1,n/2){
		node tmp=q.top(); q.pop();
		printf("%d %d ",a[tmp.x],a[tmp.y]);
		ins(tmp.l,tmp.x-1,tmp.tg);
		ins(tmp.x+1,tmp.y-1,tmp.tg^1);
		ins(tmp.y+1,tmp.r,tmp.tg);
	}
	return 0;
}
/*
4
3 2 4 1
8
4 6 3 2 8 5 7 1
*/

Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> P;

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int A, B; cin >> A >> B;
    cout << max(A+B, max(A+A-1, B+B-1)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
int main(){
    string a;
    cin>>a;
    int ans=0,check=0;
    for(int bit=0;bit<(1<<3);bit++){
        check=a.at(0)-'0';
         for(int i=0;i<3;i++){
             if(bit&(1<<i)){
               check+=a.at(i+1)-'0';
             }
            else check-=a.at(i+1)-'0';
         }
         if(check==7){
             ans=bit;
             break;
         }
    }
    int j=0;
    for(int i=0;i<7;i++){
        if(i%2==0)cout<<a.at(i/2);
        else{
            if(ans&(1<<j))cout<<'+';
            else cout<<'-';
            j++;
        }
    }
    cout<<"=7"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
 
using namespace std;
 
int n;
int a[80001],b[80001];
int k[80001];
 
int duel(){
    int cnt=0,cnt2=0;
    int f=0,win=0;
    for(int i=0;i<n;i++){
        if(b[f]>=a[i]){
            //printf("%d %d %d %d\n",f,b[f],i,a[i]);
            win++,f++;
        }
        k[i]=win;
    }
    for(int i=0;i<n-1;i++){
        //printf("%d%c",i-k[i]+1,i==n-1?'\n':' ');
        if(i-k[i]+1>(i+1)/2)return i+1;
    }
    return -1;
}
 
int main(void){
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        memset(k,0,sizeof(k));
        for(int i=0;i<n;i++)scanf("%d",&a[i]);
        for(int i=0;i<n;i++)scanf("%d",&b[i]);
        sort(a,a+n,greater<int>() );
        sort(b,b+n,greater<int>() );
        int res=duel();
        if(res==-1)printf("NA\n");
        else printf("%d\n",res);
    }
    return 0;
}

Measured memory_bytes: 1996
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int A, B, C;
  cin >> A >> B >> C;
  bool ans = A <= C && C <= B;
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 998244353
#define int long long
#define pb push_back
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
using namespace std;
int n,a,b,k,fac[300001];
int getpow(int a,int p) {
	if (!p) return 1;
	int temp=getpow(a,p/2),ans=temp*temp; ans%=MOD;
	if (p&1) ans*=a; ans%=MOD;
	return ans;
}
int getC(int k,int n) {
	if (k>n||k<0) return 0;
	return fac[n]*getpow(fac[k]*fac[n-k]%MOD,MOD-2)%MOD;
}
signed main() {
	//freopen("aome.inp","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>a>>b>>k;
	fac[0]=1; fw (i,1,n+1) {fac[i]=fac[i-1]*i; fac[i]%=MOD;}
	int ans=0;
	fw (i,0,n+1) if (a*i<=k) {
		int temp=k-a*i; if (temp%b!=0) continue;
		int j=temp/b;
		ans+=getC(i,n)*getC(j,n); ans%=MOD;
	}
	cout<<ans;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define REP(i, end) FOR(i, 0, end)

using namespace std;

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

	vector<char> charas;		//文字を所持
	vector<bool> available; //2つ以上存在する文字について

	//複数存在する文字をピックアップ
	REP(i, s.size()){
		bool exist = false;		//既に存在するならtrue
		int existlocate = -1;
		REP(j, charas.size())
			if(charas[j] == s[i]){
				exist = true;
				existlocate = j;
			}

		if(!exist){
			charas.push_back(s[i]);
			available.push_back(false);
		}
		else       available[existlocate] = true;		//既に存在したなら、存在したことを保持
	}

	//2つ以上存在しない文字の保持を解除
	REP(i, charas.size()){
		if(!available[i]){
			available.erase(available.begin()+i);
			charas.erase(charas.begin()+i);
			i--;
		}
	}

	//2つ以上存在する文字について、3文字以上離れていたら、その文字はアンバランスの一部になり得ないもしくはなる必要がない
	int begin, end;
	begin = end = -1;

	if(charas.size() == 1 && s.size() == 2){
		begin = 1;
		end = 2;
		goto END;
	}

	REP(i, charas.size()){
		REP(j, s.size()){
			if(charas[i] == s[j]){

				//端に２つあった場合も考慮
				bool edge = (j >= s.size()-2);		//端に２つある場合true

				//3文字以上離れていないなら
				if(s[j+1] == charas[i] || (edge && s[j-1] == charas[i]) || (!edge && s[j+2] == charas[i])){
					begin = (edge ? j:j+1);
					end = (edge ? j+2:j+3);
					goto END;
				}
			}
		}
	}

END:
	cout << begin << " " << end << endl;

}

Measured memory_bytes: 512
#include<stdio.h>

int main(){
  int n,k,ans=1,i;
  scanf("%d %d",&n,&k);
  for(i=0;i<n;i++){
    if(ans*2<ans+k)
      ans=ans*2;
    else
      ans+=k;
  }
  printf("%d\n",ans);
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x, y, z;
	cin >> x >> y >> z;
	x -= z;
	cout << x / (y + z) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  int n, a, b;
  while(cin>>n>>a>>b){
    if((abs(a-b))%2){
      cout<<"Borys"<<endl;
    }
    else{
      cout<<"Alice"<<endl;
    }
  }
  return 0;
}




Measured memory_bytes: 764
#include<iostream>
#include<cstring>
#include<algorithm>


using namespace std;

const long long inf= 1e10+ 123;
const int mx=1e5+123;
int dp[mx], h[mx], n;

int solve( int i)
{
    if(i==n)
        return 0;

    if(dp[i]!= -1)
        return dp[i];

    int ret1, ret2;
    ret1= abs(h[i]- h[i+1])+ solve(i+1);
    if(i+2<=n)
        ret2= abs(h[i]- h[i+2])+ solve(i+2);
    else
        ret2= inf;
    return dp[i]=min(ret1, ret2);
}

int main()
{
    memset(dp, -1, sizeof(dp));

    cin>> n;
    for(int i=1; i<=n; i++)
        cin>> h[i];

    cout<< solve(1)<< endl;

    return 0;
}


Measured memory_bytes: 9040
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;

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

int main(int argc, char const *argv[]) {
    long long n,m;cin>>n>>m;
    vector<long long> a(n);
    for(int i=0;i<n;++i)cin>>a[i];
    sort(a.begin(),a.end());
    long long b = a[0];
    for(int i=1;i<n;++i)b = gcd(b,a[i]);
    if((a[n-1]-m)>=0){
        if(a[n-1]-m==0 || (a[n-1]-m)%b == 0){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;

int main() {
  ll n, m;
  cin >> n >> m;

  vector<string> mp(n);
  vector<string> tp(m);

  rep(i, n) cin >> mp[i];
  rep(i, m) cin >> tp[i];

  for (ll i = 0; i <= n - m; i++) {
    for (ll j = 0; j <= n - m; j++) {
      bool match = true;
      rep(ii, m) rep(jj, m) {
        if (mp[i + ii][j + jj] != tp[ii][jj]) {
          match = false;
          break;
        }
      }
      if (match) {
        puts("Yes");
        return 0;
      }  // j
    }
  }  // i

  puts("No");

  return 0;
}


Measured memory_bytes: 256
from operator import itemgetter

D, G = map(int, input().split())
PC = [list(map(int, input().split())) for _ in range(D)]

def com(d, s, ans):
    if d == D:
        ans.append(s)
        return ans
    a = s[:]
    a.append(1)
    ans = com(d+1, a, ans)
    b = s[:]
    b.append(0)
    ans = com(d+1, b, ans)
    return ans

L = com(0, [], [])
ans = 10000
for l in L:
    point = 0
    probs = 0
    uncom = []
    for i, com in enumerate(l):
        if com == 0:
            uncom.append(i)
        else:
            p, c = PC[i]
            point += (i+1)*100*p + c
            probs += p
    #print(probs, l)
    if point >= G:
        ans = min(ans, probs)
        continue
    uncom.sort(reverse=True)
    re = G - point
    for un in uncom:
        p, c = PC[un]
        #print(re, probs, p)
        if (un+1)*100*(p-1) >= re:
            rem = 1 if re % ((un+1)*100) > 0 else 0
            probs += re // ((un+1)*100) + rem
            re = 0
            break
        re -= (un+1)*100*(p-1)
        probs += p-1
    #print(probs)
    if re > 0:
        continue
    ans = min(ans, probs)
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;

template<typename T>
void chmax(T &a, T &b){
	a = max(a, b);
}

template<typename T>
void chmin(T &a, T &b){
	a = min(a, b);
}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int f(ll a, ll b){
	int na = 0, nb = 0;
	while(a > 0){
		na++;
		a/=10;
	}
	while(b > 0){
		nb++;
		b/= 10;
	}
	return max(na, nb);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	ll a = 0;
	for(int i = 1;i < sqrt(N)+1;i++){
		if(N % i == 0)
			a = i;
	}
	cout << f(a, N/a) << endl;
}


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

int main() {
    int D,G;
    int p[11],c[11];
    cin >> D >> G;
    for(int i=0;i<D;i++){
        cin >> p[i] >> c[i];
    }
    int ans = 1e9;
    for(int bit=0;bit<(1<<D);bit++){
        int s=0,num=0,rest_max=-1;
        for(int i=0;i<D;i++){
            if(1&bit>>i){
                s+=100*(i+1)*p[i]+c[i];
                num+=p[i];
            }else{
                rest_max=i;
            }
        }
        if(s<G){
            int s1 = 100*(rest_max+1);
            int need = (G-s+s1-1)/s1;
            if(need>p[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans,num);
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3544