akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    
    int root(int x) {
        if (par[x] < 0) {
            return x;
        }
        
        return par[x] = root(par[x]);
    }
    
    bool merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        
        if (rx == ry) {
            return false;
        }
        
        if (par[rx] > par[ry]) {
            swap(rx, ry);
        }
        
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }
    
    bool is_same(int x, int y) {
        return (root(x) == root(y));
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    vector<int> x(m), y(m), z(m);
    
    rep(i, m) {
        cin >> x[i] >> y[i] >> z[i];
        x[i]--;
        y[i]--;
    }
    
    UnionFind uf(n);
    rep(i, m) uf.merge(x[i], y[i]);
    vector<bool> cnt(n, false);
    int ans = 0;
    
    rep(i, n) {
        int root = uf.root(i);
        
        if (!cnt[root]) {
            cnt[root] = true;
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
const ll mod=1e9+7;
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
const ll N=1e6+8;
const ll INF=1e18;
ll a[106];
ll dp[104][100008],pref[104][100008];
ll n,k;
int main(){
  IOS;
  cin>>n>>k;
  for(ll i=1;i<=n;i++)
  cin>>a[i];
  dp[0][0]=1;
  for(ll j=1;j<=k;j++)
  dp[0][j]=0;
  for(ll i=1;i<=n;i++)
  dp[i][0]=1;
  for(ll j=0;j<=k;j++)
  {
    if(j==0)
    pref[0][j]+=dp[0][j];
    else 
    {
     pref[0][j]+=pref[0][j-1]+dp[0][j];
    }
  }
  for(ll i=1;i<=n;i++){
    for(ll j=1;j<=k;j++){
      if(j<=a[i])
      dp[i][j]=pref[i-1][j]%mod;
    else{
      dp[i][j]=(pref[i-1][j]-pref[i-1][j-a[i]-1])%mod;
    }
  }
  for(ll j=0;j<=k;j++){
     if(j==0)
    pref[i][j]+=dp[i][j];
    else 
    {
     pref[i][j]+=pref[i][j-1]+dp[i][j];
    }
  }
}
cout<<dp[n][k]<<endl;
}

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


void solve(long long N, std::vector<long long> h){
    long long dp[N+1] = {0};
    dp[2] = abs(h[1]-h[0]);
    for(int i=2;i<N;i++){
        dp[i+1] = min(dp[i]+abs(h[i]-h[i-1]),dp[i-1]+abs(h[i]-h[i-2]));
    }
    cout << dp[N] << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, std::move(h));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=100;i>0;i--){
    	if(a%i==0&&b%i==0)k--;
    	if(k==0){
    		cout<<i;
    		break;
    	}
    }
	return 0;
}


Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

int mod = 1e9 + 7;
ll power(ll a,ll n){
    if(n == 0) return 1;
    ll p = power(a,n/2);
    p = (p * p) % mod;
    if(n % 2) p = (p * a) % mod;
    return p;
}
int main()
{   
    ll n;
    cin>>n;
    ll p = power(10,n);
    p -= power(9,n);
    p += mod;
    p %= mod;
    p -= power(9,n);
    p += mod;
    p %= mod;
    p += power(8,n);
    p %= mod;
    cout<<p<<endl;
    return 0;
}   
    

Measured memory_bytes: 3632
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h = S/3600;
		int m = (S - h*3600)/60;
		int s = (S - h*3600)%60;
		System.out.println(h + ":" + m + ":" + s);
	}

}

Measured memory_bytes: 26168
lis = input().split()
N, Y = [int(x) for x in lis]

# 10000円札、5000円札、1000円札がそれぞれA, B, C枚とする。
maxA = min(Y // 10000, N)
d = Y
bl = True

for A in range(maxA + 1):
    d = Y - 10000 * A
    n = N - A
    maxB = min(d // 5000, n)
    
    for B in range(maxB + 1):
        dd = d - 5000 * B
        C = n - B
                
        if 1000 * C == dd:   
            print('{} {} {}'.format(A, B, C))
            bl = False
            break
    
    if not bl:
        break

if bl:
    print('-1 -1 -1')

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto sttart = high_resolution_clock::now()
#define etime auto sttop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(sttop-sttart); cout<<"\nTime taken : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
const ll maxN = 3e3 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

ll dp[maxN][maxN];

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	FIO
	int n; cin >> n;
	int a[n];
	FOR(i, n) cin >> a[i];
	// dp[i][j][turn] -> if range was this then what would have been the ans
	for (int l = n - 1; l >= 0; l--) {
		for (int r = l; r < n; ++r) {
			if (l == r) {
				dp[l][r] = a[l];
			}
			else {
				dp[l][r] = max(a[l] - dp[l + 1][r], a[r] - dp[l][r - 1]);
			}
		}
	}
	cout << dp[0][n - 1];
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    vi A(N);
    rep(i, N) {
        cin >> A[i];
    }

    int cnt = 0;
    int cnt2 = 0;
    vector<bool> x(8);
    rep(i, N) {
        if (A[i] >= 3200) {
            cnt2++;
            continue;
        }

        if (A[i] <= 399) {
            if (!x[0]) {
                cnt++;
                x[0] = true;
            }
        } else if (A[i] <= 799) {
            if (!x[1]) {
                cnt++;
                x[1] = true;
            }
        } else if (A[i] <= 1199) {
            if (!x[2]) {
                cnt++;
                x[2] = true;
            }
        } else if (A[i] <= 1599) {
            if (!x[3]) {
                cnt++;
                x[3] = true;
            }
        } else if (A[i] <= 1999) {
            if (!x[4]) {
                cnt++;
                x[4] = true;
            }
        } else if (A[i] <= 2399) {
            if (!x[5]) {
                cnt++;
                x[5] = true;
            }
        } else if (A[i] <= 2799) {
            if (!x[6]) {
                cnt++;
                x[6] = true;
            }
        } else if (A[i] <= 3199) {
            if (!x[7]) {
                cnt++;
                x[7] = true;
            }
        }
    }

    if (cnt == 0 && cnt2 != 0) {
        cout << 1;
    } else {
        cout << cnt;
    }
    cout << " ";
    if (cnt2 == 0) {
        cout << cnt;
    } else {
        cout << (cnt + cnt2);
    }
    cout << endl;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  int a, p;
  cin >> a >> p;
  cout << (3*a+p)/2 << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


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

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int k = Integer.parseInt(in.next());
            long ans = 0;

            for (int i = 1; i <= k; i++) {
                for (int j = 1; j <= k; j++) {
                    for (int l = 1; l <= k; l++) {
                        ans += gcd(i, gcd(j, l));
                    }
                }
            }

            // 出力
            out.println(ans);

        }

        public static int gcd(int num1, int num2) {
            if (num2 == 0) return num1;
            else return gcd(num2, num1 % num2);
        }

    }
}



Measured memory_bytes: 35812
from math import ceil
n, k = map(int, input().split())
a = list(map(int, input().split()))
ok = 10**10
ng = 0


def judge(x):
    cnt = 0
    for aa in a:
        cnt += (x + aa - 1) // x - 1
        # print(cnt)
    return cnt <= k


# print(judge(4))
# print(judge(5))
# print(judge(3))

while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if judge(mid):
        ok = mid
    else:
        ng = mid
print(ok)


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

int main() {
    int a, b, c, x, y;
    cin>>a>>b>>c>>x>>y;
    
    int cost1, cost2, cost3, cost4, min_cost;
    //A+AB, B+AB, A+B, ABの4通りしかあり得ない
    //A+AB (x>y)
    cost1 = 2*y*c+(x-y)*a;
    //B+AB (x<y)
    cost2 = 2*x*c+(y-x)*b;
    //A+B
    cost3 = x*a+y*b;
    //AB
    cost4 = max(2*x*c, 2*y*c);
    
    if(x<y){
        min_cost=min(min(cost2,cost3),cost4);
    }else{
        min_cost=min(min(cost1,cost3),cost4);
    }
    cout<<min_cost<<endl;
    
    return 0;
}


Measured memory_bytes: 256
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 trans = A - B;
		int ans = C -trans;
		if(C - trans < 0) {
			ans = 0;
		}
		System.out.println(ans);
		
		

	}

}

Measured memory_bytes: 21204
a, b, c = readline.split.map(&:to_i)
# /a + /b < /c
# (/a + /b) ^2 < /c ^2
# a + b + 2/ab < c
# a + b - c < - 2/ab
# a + b - c < 0 -> (a + b - c)^2 > 4ab 
# a + b - c >= 0 -> False
if a + b - c < 0 and (a + b - c) * (a + b - c) > 4 * a * b
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#
# abc167 c
#
import sys
from io import StringIO
import unittest
from collections import deque


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 = """3 3 10
60 2 2 4
70 8 7 9
50 2 3 9"""
        output = """120"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 3 10
100 3 1 4
100 1 5 9
100 2 6 5"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2"""
        output = """1067"""
        self.assertIO(input, output)


def resolve():
    N, M, X = map(int, input().split())
    CA = [list(map(int, input().split())) for _ in range(N)]

    ans = float("inf")
    for bit in range(1 << N):
        S = [0]*(M+1)
        for i, ca in enumerate(CA):
            if (1 << i) & bit == 1 << i:
                S = list(map(sum, zip(S, ca)))
        if min(S[1:]) >= X:
            ans = min(ans, S[0])

    if ans == float("inf"):
        ans = -1

    print(ans)


def resolve_dfs():
    global N, M, X, CA
    N, M, X = map(int, input().split())
    CA = [list(map(int, input().split())) for _ in range(N)]

    b = deque()
    ans = dfs(0, b)
    if ans == float("inf"):
        ans = -1

    print(ans)


def dfs(n, B):
    if n == N:
        S = [0]*(M+1)
        for i, ca in enumerate(CA, 1):
            if i in B:
                S = list(map(sum, zip(S, ca)))
        if min(S[1:]) < X:
            return float("inf")
        else:
            return S[0]

    ans = float("inf")
    B.append(n+1)
    ans = min(ans, dfs(n+1, B))
    B.pop()
    ans = min(ans, dfs(n+1, B))

    return ans


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


Measured memory_bytes: 16232
#include <iostream>
using namespace std;
int d = 0;
int GCD(int a, int b)
{
    if (b == 0)
        return a;
    return GCD(b, a % b);
}
int main()
{
    int n, X, city_place;
    scanf("%d%d", &n, &X);
    while (n--)
    {
        scanf("%d", &city_place);
        d = GCD(d, abs(city_place - X));
    }
    printf("%d", d);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n;
	while(cin>>n){
		int cnt=0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					for(int l=0;l<10;l++){
						if(i+j+k+l==n){
							cnt++;
						}
					}
				}
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}


Measured memory_bytes: 3032
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> C(N - 1);
	vector<Int> S(N - 1);
	vector<Int> F(N - 1);
	vector<Int> time(N);

	for (Int i = 0; i < N-1; i++) {
		cin >> C[i] >> S[i] >> F[i];
	}

	Int temp;
	for (Int i = 0; i < N-1; i++) {
		for (Int j = i; j < N-1; j++) {
			if (time[i] <= S[j]) {
				time[i] = S[j]+C[j];
			}
			else {
				temp = (time[i] + F[j] - 1) / F[j];
				time[i] = temp * F[j] + C[j];
			}
		}
	}

	for (Int i = 0; i < N; i++) {
		printf("%lld\n", time[i]);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long double
#define vi vector<ll>
#define set set <int, greater <int> >
#define mapci map<char,ll>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(),v.end()
//to compare floating point number
#define comp(a,b) return( abs(a-b) < 1e-9)
#define mod (1e9)+7
#define el "\n";



int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	fast
        ll  d,t,s ,x;        
        cin>>d>>t>>s;
        x=ceil(d/s);
        if(x<=t)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    
}

Measured memory_bytes: 3736
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();

		//Deque型のListを生成
		List<Deque<Integer>> list = new ArrayList<Deque<Integer>>();
		for(int i = 0; i < n; i++) {
			list.add(new ArrayDeque<Integer>());
		}

		for(int i = 0; i < q; i++)	{
			int query = sc.nextInt();
			int t = sc.nextInt();

			switch(query){
			case 0:
				int x = sc.nextInt();
				list.get(t).add(x);  //listの中のt番目の要素を取得し、それにaddする
				break;

			case 1:
				if(!(list.get(t).isEmpty())) {
					System.out.println(list.get(t).peekLast());
				}
				break;

			case 2:
				list.get(t).pollLast();
				break;
			}
		}
	}

}



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

const int INF = 1001001001;
vector<int> to[100005];

int main() {
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int v = q.front(); q.pop();
        for (int u : to[v]) {
            if (dist[u] != INF) continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }
    
    cout << "Yes" << endl;
    rep(i, n) {
        if(i == 0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 10628
#include <algorithm>
#include <iostream>

using namespace std;

namespace mod {

template <class T, int M>
class MInt;

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp);

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n);

template <class T, int M>
class MInt {
  T n_;

 public:
  MInt() : n_(0) {}
  MInt(T n) : n_((n % M + M) % M) {}

  MInt &operator+=(const MInt &rhs) {
    n_ += rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator-=(const MInt &rhs) {
    n_ += M - rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator*=(const MInt &rhs) {
    n_ = n_ * rhs.n_ % M;
    return *this;
  }

  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }

  T Get() { return n_; }
};

template <class T, int M>
MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res -= rhs;
}

template <class T, int M>
MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res += rhs;
}

template <class T, int M>
MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res *= rhs;
}

template <class T, int M>
MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res /= rhs;
}

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp) {
  if (exp == 0) {
    return 1;
  }

  auto a = Pow(base, exp / 2);
  a *= a;
  if (exp % 2 == 1) {
    a *= base;
  }

  return a;
}

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n) {
  return Pow(n, static_cast<T>(M - 2));
}
}  // namespace mod

const int md = 1e9 + 7;
using MInt = mod::MInt<long long, md>;

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;

  MInt mn(n), mk(k), m1(1);
  MInt ans = 0;
  for (int i = k; i <= n + 1; i++) {
    MInt mi(i);
    ans += (mn - mi + m1) * mi + m1;
  }

  cout << ans.Get() << '\n';

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int A, B; cin >> A >> B;
    if(1 <= A and A <= 9 and 1 <= B and B <= 9){
        cout << A * B << endl;
    }
    else dame
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // Atcoder
    // template: cpp
    string n;
    cin >> n;
    if(n.at(0) == '7' || n.at(1) == '7' || n.at(2) == '7')
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 3620
a = int(input())
b = int(input())
c = int(input())
x = int(input())
nb = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if (x - 500*i - 100*j - 50*k) == 0:
        nb += 1
print(nb)

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, x;
	cin>>n>>x;
	vector<int> a(n);
	for(auto &y : a){
		cin>>y;
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(x < a[i])break;
		x -= a[i];
		ans++;
	}
	if(ans == n && x > 0)ans--;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N, X, Y; cin >> N >> X >> Y;
	
	int ans[2001] = { 0, };
	for (int i = 1; i <= N; i++)
		for (int j = i + 1; j <= N; j++)
			if (i != j) {
				int dist = min(j - i, abs(i - X) + abs(j - Y) + 1);
				ans[dist]++;
			}

	for (int i = 1; i < N; i++)
		cout << ans[i] << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define oo 2000000000
#define inf 1000000000000000000
#define P1 31
#define P2 37
#define M  1000000007
#define M2 1000000009
#define pii pair<ll,ll>
typedef long long ll;
using namespace std;
const int N = 355001;
const int SQRTN = 320;
const int LOGN = 20;
const long double PI = acos(-1);
const long double TAU = 2*PI;

ll a , b , c , k;
signed main(){
    cin >> a >> b >> c >> k ;
    ll ans = a-b;
    ans = ans*((k&1)?-1:1) ;
    cout <<ans <<endl;

}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n-1);
  rep(i,n) {
    cin >> a[i];
    a[i]--;
  }
  rep(i,n) cin >> b[i];
  rep(i,n-1) cin >> c[i];


  int ans = 0;
  rep(i,n) {    
    ans += b[a[i]];
    if (a[i+1] == a[i]+1) ans += c[a[i]];
  }
  cout << ans << endl;
  return 0;
}

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

typedef pair<int,int> P;

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

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, m, i, j;
  int v[20];
  int c[20];
  int ans = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &v[i]);
  for (i = 0; i < n; i++) {
    scanf("%d", &c[i]);
    if (v[i] - c[i] > 0)
      ans += v[i] - c[i];
  }
  printf("%d\n", ans);

  return 0;
}


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


long long pow(long long p,long long q,long long r){
  if(q==0)return 1;
  else if(q%2==0)return pow(p,q/2,r)*pow(p,q/2,r)%r;
  else return pow(p,q-1,r)*p%r;
}
int main() {
  int n;
  cin>>n;
  long long a[n],b[n];
  for(int i=0;i<n;i++){
    long long k;
    cin>>k;
    a[i]=k;
    b[i]=0;
  }
  long long ans=1,mod=998244353;
  if(a[0]!=0)ans=0;
  for(int i=1;i<n;i++){
    b[a[i]]++;
  }
  if(b[0]==0)b[0]=1;
  else ans=0;
  sort(a,a+n);
  for(int i=1;i<a[n-1]+1;i++){
    ans=ans*pow(b[i-1],b[i],mod)%mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

long long n, k, q;
long long a[100000], point[100000];

int main()
{
	cin >> n >> k >> q;
	for (long long i = 0; i < q; i++)
	{
		cin >> a[i];
	}
	
	for (long long i = 0; i < n; i++)
	{
		point[i] = 0;
	}
	
	for (long long i = 0; i < q; i++)
	{
		point[a[i] - 1]++;
	}
	
	for (long long i = 0; i < n; i++)
	{
		if (point[i] + k - q > 0)
		{
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 2176
#B問題
N = int(input())
C = [int(input()) for i in range(N)]
mod = 10**9+7
D = []

for i in range(N-1):
    if C[i] != C[i+1]:
        D.append(C[i])
D.append(C[-1])

M = len(D)
dp = [0 for i in range(M+1)]
dp[0] = 1
count = [0 for i in range(2*10**5+1)]

for i in range(1,M+1):
    dp[i] = dp[i-1]
    dp[i]+=count[D[i-1]]
    dp[i]%=mod
    count[D[i-1]]+=dp[i-1]
    count[D[i-1]]%=mod
    
print(dp[M])
    
    


Measured memory_bytes: 25972
import sys, math

def calcSum(AList, B, C, Sum):
    Len = AList[B]
    if(Len == 0):
        return Sum
    Sum += (C-B) * Len

    AList[B] = 0
    AList[C] += Len
    return Sum

if(__name__ == "__main__"):
    N= int( input().strip() )

    Max = int(10**5)+1
    AList = [0] * Max
    A_str = input().strip().split()
    N_Queries = int( input().strip() )

    sum = 0
    for i in range(N):
        value = int(A_str[i])
        AList[value] += 1
        sum += value
    BCs = []
    Sums = [sum]
    for i in range(N_Queries):
        BC_str =  input().strip().split()
        B = int(BC_str[0])
        C = int(BC_str[1])
        Sums.append( calcSum(AList, B, C, Sums[-1]) )
        """
        BC = [ int(BC_str[0]), int(BC_str[1]) ]
        BCs.append(BC)
        """

    for i in range(1, 1+N_Queries):
        print(Sums[i])


Measured memory_bytes: 20240
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;

map <char,char> r;
stack<char> t;
int main(void){
	r['[']=']';
	r[']']='[';
	r['(']=')';
	r[')']='(';
	r['{']='}';
	r['}']='{';
	string a,b,c;
	cin >> a;
	int n=a.size();
	rep(i,n){
		if(a[i]=='i'){
			b=a.substr(0,i);
			c=a.substr(i+3,n-i-2);
			reverse(c.begin(),c.end());
			break;
		}
	}
	int ans=3,nb=b.size(),nc=c.size();
	int dp[13][13];
	clr(dp,0);
	rep(i,nb) rep(j,nc){
		dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1]);
		dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
		if(r[b[i]]==c[j])
			dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+2);
	}
	ans+=dp[nb][nc];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1196
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInts(3)
	ans := 0
	if (a[0]*a[1]*a[2])&1 == 1 {
		sort.Sort(sort.IntSlice(a))
		ans = a[0] * a[1]
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func match(s, t string) bool {
	ret := true
	for i := 0; i < len(s); i++ {
		if s[i] == '?' {
			continue
		}
		if s[i] != t[i] {
			ret = false
			break
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	s := getString()
	t := getString()

	N := len(s)
	M := len(t)
	pos := -1
	// search
	for i := 0; i <= N-M; i++ {
		f := match(s[i:i+M], t)
		// out(s[i:i+M], f)
		if f == true {
			pos = i
		}
	}
	// out(pos)
	if pos == -1 {
		out("UNRESTORABLE")
		return
	}
	ans := []byte(s[:pos] + t + s[pos+M:])
	for i := 0; i < N; i++ {
		if ans[i] == '?' {
			ans[i] = 'a'
		}
	}
	out(string(ans))
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
    int W,H,i,j;
    for ( ; scanf("%d %d\n",&H,&W) != EOF; )
    {
    for (i = 0; i < H; i++)
        {
        for (j = 0; j < W; j++)
            putchar('#');
            putchar('\n');
        }
    if (H==0 && W==0)
    break;
    putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

int main(){
  long long N,M,num;
  cin>>N>>M;
  long long year,region;
  string ans;
  vector<vector<long long>> array;
  vector<long long> years,regions;
  //index付きのベクトルを宣言
  map<long long, long long> IDs;
  array.resize(N+10);
  for(long long i=0;i<M;++i){
    cin>>region>>year;
    array[region-1].push_back(year);
    years.push_back(year);
    regions.push_back(region);
  }
  for(long long i=0;i<N;++i){
    sort(array[i].begin(),array[i].end());
  }
  for(long long i=0;i<N;++i){
    num=array[i].size();
    for(long long j=0;j<num;++j){
      year=array[i][j];
      //IDsに(year,IDをくわえる)
      IDs[year]=1000000*(i+1)+j+1;
      }
  }
  for(long long i=0;i<M;++i){
    year=years[i];
    ans=to_string(IDs[year]);
        cout<<setfill('0')<<right<<setw(12)<<ans<<"\n";

  }
return 0;
}

Measured memory_bytes: 14824
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll INF=1000000010;
const ll MOD=1000000007;
const ll LINF=4000000000000000000;
const long double EPS=1e-9;
typedef pair<int,int> P;
int main(){
    ll n,a,b;cin>>n>>a>>b;
    if(a+b-1>n||a*b<n){
        cout<<-1<<endl;
        return 0;
    }
    int s=0;
    for(int i=1;i<=a;i++){
        int st=s+b,en=s+1;
        if(n<a-i+st){
            st=n-(a-i);
        }
        for(int j=st;j>=en;j--){
            cout<<j<<" ";
            s++;
        }
    }
    cout<<endl;
}

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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll prev=0;
    ll cnt=0;
    fr(i,0,n){
        if(prev>a[i]){
            cnt+=prev-a[i];
        }else{
            prev=a[i];
        }
    }
    cout << cnt << "\n";
}   


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
const int MAXN=10005;
const int inf=0x3f3f3f3f;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};
struct node{int x,y;};
int n,m,k,i,j,p1,q1,p2,q2,ans=inf,st[MAXN][MAXN];
char ch,c[MAXN][MAXN];
bool vis[MAXN][MAXN];
queue<node> q;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
    	if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void print(int x)
{
    if (x<0)
        putchar('-'),x=-x;
    if (x>9)
        print(x/10);
    putchar(x%10+'0');
}
signed main(void)
{
	read(n),read(m),read(k);
	read(p1),read(q1),read(p2),read(q2);
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
		{
			ch=getchar();
			while (ch!='.' && ch!='@')
				ch=getchar();
			c[i][j]=ch;
		}
	vis[p1][q1]=1;
	q.push(node{p1,q1});
	while (!q.empty())
	{
		node u=q.front();
		q.pop();
		if (u.x==p2 && u.y==q2)
			ans=min(ans,st[u.x][u.y]);
		for (i=0;i<4;i++)
			for (j=1;j<=k;j++)
			{
				node v=node{u.x+j*dx[i],u.y+j*dy[i]};
				if (v.x<1 || v.x>n || v.y<1 || v.y>m || c[v.x][v.y]=='@' || (st[v.x][v.y]<=st[u.x][u.y] && st[v.x][v.y]))
					break;
				if (!vis[v.x][v.y])
				{
					st[v.x][v.y]=st[u.x][u.y]+1;
					vis[v.x][v.y]=1;
					q.push(v);
				}
			}
	}
	print(ans==inf?-1:ans);
	return 0;
} 

Measured memory_bytes: 20948
#include <stdio.h>


int main (){

    int n,a,b,sumDig,sumAll = 0,temp ,digits;
    int flag = 0;
    scanf("%d %d %d", &n, &a, &b);
    for (int i =1; i <= n; i++){
        sumDig  =0;
        temp = i;
        while (temp != 0){
            digits = temp  % 10;
            sumDig += digits;
            temp /= 10;
            if (sumDig >= a && sumDig <= b){
                flag = 1;
            }else {
                flag = 0;
            }
        }
        if(flag == 1){
            temp = i;
            sumAll += temp ;    
        }
    }
    printf("%d\n", sumAll);


    return 0;
}

Measured memory_bytes: 1732
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define mp make_pair

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
    int sign = 1;
    T ret = 0;
    char c;

    do{
        c = getc();
    }while(c == ' ' || c == '\n');
    if(c == '-')sign = -1;
    else ret = c-'0';
    while(1){
        c = getc();
        if(c < '0' || c > '9')break;
        ret = 10*ret + c-'0';
    }
    return sign * ret;
}

inline void ini(int& x){
    x = getnum<int>();
}

inline void scani(int& x){
    scanf("%d",&x);
}

//end of macro

ll a,b,c,d;

ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

ll solve(ll x){
    return x - (x/c + x/d - x/lcm(c, d));
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    cin>>a>>b>>c>>d;
    // printf("solve %d %d\n",b,solve(b));
    // printf("solve %d %d\n",a-1,solve(a-1));
    cout << solve(b) - solve(a-1) << endl;

    return 0;
}


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

ll mod = 1000000007;
ll ans = 1<<29;

int main() {
    int a,b,c;
    cin >> a>> b>>c;
    for(int i = a;i<=a*b;i+=a){
        if(i%b==c) {cout << "YES" <<endl;
        return 0;}
    }
    cout << "NO" <<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#define N 103
#define W 100003

long long int dp[N][W];
long long int weights[N];
long long int values[N];

long long int min(long long int a, long long int b){
  if(b>a)return a;
  else return b;
}
long long int max(long long int a, long long int b){
  if(a>b)return a;
  else return b;
}

int main(){
  long long int i,j,n,w,tmp;
  scanf("%lld %lld", &n,&w);
  for(i=0;i<n;i++)scanf("%d %lld", &weights[i], &values[i]);
  //dp[i][j]:i番目の品物のまでで重さwの最大価値
  dp[0][0]=0;
  for(i=0;i<n;i++){
    for(j=0;j<=w;j++){
      if(weights[i]>j)dp[i+1][j]=dp[i][j];
      else{
        dp[i+1][j]=max(dp[i][j], dp[i][j-weights[i]]+values[i]);
      }
    }
  }
/*
  for(i=0;i<n+1;i++){
    for(j=0;j<w+1;j++){
      printf("%lld ", dp[i][j]);
    }
    printf("\n");
  }
  */

  printf("%lld\n", dp[n][w]);
  return 0;
}


Measured memory_bytes: 79232
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] input = new int[H][W];
		for (int i = 0; i < H; i++) {
			String[] inputs = sc.next().split("");
			for (int j = 0; j < W; j++) {
				if (inputs[j].equals("#")) {
					input[i][j] = 1;
				} else {
					input[i][j] = 0;
				}
			}
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (input[i][j] == 1) {
					System.out.print("#");
				} else {
					int output = 0;
					if (i - 1 >= 0) {
						for (int k = 0; k < 3; k++) {
							if (j + k - 1 < 0 || j + k - 1 >= W) {
								continue;
							}
							if (input[i - 1][j + k - 1] == 1) {
								output++;
							}
						}
					}
					for (int k = 0; k < 3; k++) {
						if (j + k - 1 < 0 || j + k - 1 >= W) {
							continue;
						}
						if (input[i][j + k - 1] == 1) {
							output++;
						}
					}
					if (i + 1 < H) {
						for (int k = 0; k < 3; k++) {
							if (j + k - 1 < 0 || j + k - 1 >= W) {
								continue;
							}
							if (input[i + 1][j + k - 1] == 1) {
								output++;
							}
						}
					}
					System.out.print(output);
				}
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 39192
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int main() {
    ios_base::sync_with_stdio(false);

    ll n, k;
    cin >> n >> k;
    cout << min({n, n%k, k - n%k}) << endl;
}


Measured memory_bytes: 256
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 2e5 + 10;
pair<int,int> a[MAXN];
int upto[MAXN];
const int MOD = 998244353;
int dp[MAXN];
int seg[4*MAXN];

void update(int node,int s,int e,int idx,int val){
    if(s > e) return;
    if(s == e){ seg[node] = val; return; }
    
    int mid = (s+e)>>1;

    if(idx <= mid) update(2*node,s,mid,idx,val);
    else update(2*node+1,mid+1,e,idx,val);

    seg[node] = max(seg[2*node],seg[2*node+1]);
}

int query(int node,int s,int e,int qs,int qe){
    if(s > e || qs > e || qe < s) return 0;

    if(qs <= s && e <= qe){
        return seg[node];
    }
    int mid = (s+e)>>1;
    return max(query(2*node,s,mid,qs,qe),query(2*node+1,mid+1,e,qs,qe));
}

void solve(){
    int n; cin>>n;

    FOR(i,1,n) cin>>a[i].first>>a[i].second;

    sort(a+1,a+n+1);
   
    FOR(i,1,n) {
        upto[i] = i;
        update(1,1,n,i,i);
    }

    RFOR(i,1,n){
        pair<int,int> xx = {a[i].first + a[i].second - 1,1e9};
        int idx = upper_bound(a+i,a+n+1,xx) - a;
        int x = query(1,1,n,i,idx-1);
        upto[i] = x;
        update(1,1,n,i,upto[i]);
    }

    dp[n+1] = 1;
    int ans = 0;
    RFOR(i,1,n){
        dp[i] = (dp[i+1] + dp[upto[i] + 1])%MOD; 
        // clog<<dp[i]<<endl;
    }

    cout<<dp[1]<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    vector<vector<int> > ct(2, vector<int>(101010, 0));
    REP(i, n){
        ct[i%2][a[i]]++;
    }
    if(max_element(all(ct[0]))-ct[0].begin() == max_element(all(ct[1]))-ct[1].begin()){
        sort(all(ct[0]), greater<int>());
        sort(all(ct[1]), greater<int>());
        cout << min(n-ct[0][0]-ct[1][1], n-ct[0][1]-ct[1][0]) << endl;
    }else{
        cout << n-*max_element(all(ct[0]))-*max_element(all(ct[1])) << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#define MOD 1000000007

int N;
long long int ans = 1;

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

	for (int i = 1; i <= N; ++i)
	{
		ans *= i;
		ans %= MOD;
	}

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

Measured memory_bytes: 128