akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */



int main() {
    long long d;
    string n;
    cin >> n >> d;
    
    //dp[i][j][k] := 左からi桁目,　桁和がj(mod D), flag, の時の数え上げdp
    vector<vector<vector<long long> > > dp(n.size() + 1, vector<vector<long long> > (d + 1, vector<long long> (2, 0ll)));
    dp[0][0][0] = 1;
    for(int i = 0; i < n.size(); i++){
        for(int j = 0; j <= d; j++){
            
            //cout << "( ";
            for(int k = 0; k < 2; k++){
                //cout << dp[i][j][k] << " ";
 
                int num = (int)(n[i] - '0');
                for(int l = 0; l <= 9; l++){
                    int nj = j;
                    if(l != 0) nj++;
                    if(nj > d) continue;
                    if(k == 0 && l <= num){
                        dp[i + 1][nj][l != num] += dp[i][j][k];
                    }else if(k == 1){
                        dp[i + 1][nj][k] += dp[i][j][k];
                    }
                }
            }
 
            //cout << ") ";
        }
        //cout << endl;
    }
 
 
    //cout << endl;
    cout << (dp[n.size()][d][0] + dp[n.size()][d][1]) << endl;
 
    return 0;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c =s.toCharArray();

    for(int i=0; i<s.length(); i++){
        if(i%2 == 0){

        System.out.print(c[i]);
    }
}
}
}

Measured memory_bytes: 47592
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
ll a[105][2];
ll d[105][100005];
int n, w; 

int main(){
	cin >> n >> w;
	for(int i = 1; i <= n; ++i){
		cin >> a[i][0] >> a[i][1];
	}
	memset(d, 0, sizeof(d));
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= w; ++j){
			if(j < a[i][0])  d[i][j] = d[i - 1][j];
			else{
				ll x = d[i - 1][j];
				ll y = a[i][1] + d[i - 1][j - a[i][0]];
				d[i][j] = max(x, y);
			}
		}
	}
	cout << d[n][w] << endl;
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

ll dp[2001][2001];

int main(){
  int n,m;cin>>n>>m;
  vector<int> s(n), t(m);
  rep(i, n)cin>>s[i];
  rep(i, m)cin>>t[i];

  dp[0][0]=1;
  rep1(i, n)dp[i][0]=1;
  rep1(i, m)dp[0][i]=1;

  rep(i, n)rep(j, m){
    if(s[i]==t[j])dp[i+1][j+1] = dp[i+1][j]+dp[i][j+1];
    else dp[i+1][j+1] = dp[i+1][j]+dp[i][j+1]-dp[i][j];
    dp[i+1][j+1]=(dp[i+1][j+1]+MOD)%MOD;
  }

  cout<<dp[n][m]<<endl;

  return 0;
}

Measured memory_bytes: 31488
#include<stdio.h>

int main(void){
	int c[131072]={0},i,r=0,n,x,m;
	scanf("%d",&n);
	for(i = 1;i <= n;i++){scanf("%d",&m);c[m]++;}
	m = 0;
	for(i = 1;i <= 114514;i++){
		if(c[i] == 0){continue;}
		if(c[i] % 2 == 1){r+=((c[i]-1)/2);}
		else{r+=((c[i]-1)/2);m++;}
	}
	if(m % 2 == 1){r+=((m+1)/2);}
	else{r+=(m/2);}
	printf("%d\n",n-2*r);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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;
}

ll M = 1000000007;

void solve()
{
	int k;
	cin>>k;
	int delta=10%k;
	//ll sum=1;
	ll t=0;
	vector<ll>cand(1e6);
	ll ds=1;
	rep(i,1e6){
		ds*=10;
		ds%=k;
		cand[i]=ds;
	}
	rep(i,1e6+1){
		ll j=i;
		if(!i){
			t=1;
		}
		else{
			t+=cand[i-1]%k;
		}
		t%=k;	
		if(t*7%k==0){
			cout<<i+1<<endl;
			return;
		}
	}
	cout<<-1<<endl;
	return;
		

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 11124
n = int(input())
a = list(map(int, input().split()))

num = [0]*(10**5 + 1)

for x in a:
    num[x] += 1

ans = num[0] + num[1] + num[2]

for i in range(1, 10**5):
    tmp = num[i-1] + num[i] + num[i+1]
    if tmp > ans:
        ans = tmp

print(ans)


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

int main() {
	int N;
	cin >> N;
	vector<P> a;
	rep(i, N) {
		int A;
		cin >> A;
		a.push_back(make_pair(A, i+1));
	}
	sort(a.begin(), a.end());
	rep(i, N) {
		if (i != N - 1) {
			cout << a[i].second << " ";
		}
		else {
			cout << a[i].second << endl;
		}
	}

}

Measured memory_bytes: 1780
import java.io.*;
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 area = a*b;
		int perimeter = a*2+b*2;
		
		System.out.println(area + " " + perimeter);
	}
}

Measured memory_bytes: 26072
import collections

def main():
    N  = int(input()) 
    A=list(map(int, input().split()))
    C = collections.Counter(A)
    B = list(set(A))
    B.sort()
    lenb = len(B)
    Boo = [True]*lenb
    ZENBU = [False]*(10**6+4)

    if C[1]>1:
        print(0)
        return
    if C[1]==1:
        print(1)
        return

    for i in range(lenb):
        temp = 2
        if ZENBU[B[i]]==False:
            while B[i]*temp < 1000002:
                ZENBU[B[i]*temp] = True
                temp+=1

    cnt = 0
    for i in range(lenb):
        if ZENBU[B[i]]==False and C[B[i]]==1:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 150652
let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
let ( n, m ) = ( arr[0], arr[1] )

var i = 0
var p = 0
var c = 0

var ac = Array(count: n, repeatedValue: 0)
var w = Array(count: n, repeatedValue: 0)
for i in 0..<m {
  let arr1=readLine()!.characters.split{$0==" "}.map{String($0)}
  
  var q: Int! = Int(arr1[0])! - 1
  if (ac[q] == 1 ) {
    continue
  }
  if (arr1[1] == "AC") {
    p += w[q]
    ac[q] = 1
    c += 1
    continue
  } else {
    w[q] += 1
  }  
}

print(c,p)

Measured memory_bytes: 4208
let n, t = stdin.ReadLine().Split() |> fun x -> int x.[0], int x.[1]
let x = [for _ in 1..n -> stdin.ReadLine().Split() |> fun x -> int x.[0], int x.[1]] |> List.filter (fun (_, y) -> y <= t) |> List.sort
if x.Length = 0 then printfn "TLE" else printfn "%d" (fst x.[0])

Measured memory_bytes: 15128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M;
  cin >> N >> M;
  int a[N], b[N], c[M], d[M];
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> c[i] >> d[i];
  }
  for (int i = 0; i < N; i++) {
    int x = INT_MAX, y;
    for (int j = 0; j < M; j++) {
      if (abs(a[i]-c[j])+abs(b[i]-d[j]) < x) {
        x = abs(a[i]-c[j])+abs(b[i]-d[j]);
        y = j+1;
      }
    }
    cout << y << endl;
  }
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    string s;
    cin>>s;
    long long sum=0;
    for(int i=0;i<(int)s.size();i++){
        sum+=(s[i]-'0');
    }
    if(sum%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const double PI = acos(-1);
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Int N, K; cin >> N >> K;
    vector<int> A(N), F(N);
    for (auto &a : A) cin >> a;
    for (auto &f : F) cin >> f;
    sort(begin(A), end(A));
    sort(begin(F), end(F));
    Int ok = 1e13, ng = -1;
    while (abs(ok - ng) > 1) {
        Int mid = (ok + ng) / 2;
        Int sum = 0;
        for (int i = 0; i < N; i++) {
            sum += max(0LL, A[i] - mid / F[N - 1 - i]);
        }
        (sum <= K ? ok : ng) = mid;
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static List<long> lvlpaty = new List<long>();
    static List<long> lvlsou = new List<long>();

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var x = long.Parse(spl[1]);

        lvlpaty.Clear();
        lvlsou.Clear();

        lvlpaty.Add(1);
        lvlsou.Add(1);

        for (int i = 1; i <= n; i++) {
            lvlpaty.Add(1 + lvlpaty[i - 1] * 2);
            lvlsou.Add(3 + lvlsou[i - 1] * 2);
        }

        return patiy(n, ref x);
    }

    static long patiy(int level, ref long x) {
        if(lvlsou[level] <= x) {
            x -= lvlsou[level];
            return lvlpaty[level];
        }
        if(level == 0) {
            x--;
            return 1;
        }

        long r = 0;

        x--;
        if (x == 0) return r;

        r += patiy(level - 1,ref x);
        if (x == 0) return r;

        r++; x--;
        if (x == 0) return r;

        r += patiy(level - 1, ref x);
        if (x == 0) return r;

        x--;
        return r;
    }
}


Measured memory_bytes: 11220
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int n;
    scan(n);
    auto h = readArr!(int)();
    int cnt;
    foreach (i ; 0 .. n) {
        bool ok = true;
        foreach (j ; 0 .. i) {
            if (h[j] > h[i]) {
                ok = false;
                break;
            }
        }
        cnt += ok;
    }
    writeln(cnt);
}

























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

int main() {
  uint32_t N = 0;
  std::array<uint32_t, 100> A;
  std::cin >> N;
  for (size_t i = 0; i < N; i++) std::cin >> A[i];

  uint32_t count = 0;
  for (size_t i = 0; i < N - 1; i++) {
    uint32_t min_index = i;
    for (size_t j = i + 1; j < N; j++) {
      if (A[min_index] > A[j]) min_index = j;
    }
    if (min_index != i) {
      uint32_t temp = A[i];
      A[i] = A[min_index];
      A[min_index] = temp;
      count++;
    }
  }

  for (uint32_t i = 0; i < N - 1; i++) std::cout << A[i] << " ";
  std::cout << A[N - 1] << std::endl;
  std::cout << count << std::endl;

  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  vector<int> X={a%10,b%10,c%10,d%10,e%10};
  sort(X.begin(),X.end());
  int W=0,k;
  for(k=0;k<5;k++){
    if(X[k]!=0){
      W=X[k];
      k++;
      break;
    }
  }
  vector<int> Y={a,b,c,d,e};
  for(int i=0;i<5;i++){
    Y[i]/=10;
  }
  int Z=0;
  for(int i=0;i<5;i++){
    Z+=Y[i]*10;
  }
  cout<<Z+W+(5-k)*10<<endl;
}



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

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define rep(i, N) for(ll i=0; i<(N); ++i)

//sqrtN -> 最大値のみに対応できればいいので，それを使う
const int sqrtN = 512;
struct SqrtDecomposition {
  int N, K;
  vector<int> data;
  vector<int> bucketData;
  const int INIT_VALUE = 0;
  
  SqrtDecomposition(int n) : N(n) {
    //分割数
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, INIT_VALUE);
    bucketData.assign(K, INIT_VALUE);
  }
  //ここまで共通
  
  void change(int x, int y, int v) {
    for(int k = 0; k < K; ++k) {
      int l = k * sqrtN;
      int r = (k + 1) * sqrtN;
      if(y <= l || x >= r) continue;  //完全に区間外
      if(l >= x && y >= r) {  //完全に区間内
        bucketData[k] += v;
      } else {
        //一部区間内
        for(int i = max(x, l); i < min(y, r); ++i) {
          data[i] += v;
        }
      }
    }
  }
  
  // [x, y)
  int get(int x) {
    int k = x / sqrtN;
    
    return data[x] + bucketData[k];
  }
};

int main() {
  //range sum query
  int n, q;
  cin >> n >> q;
  
  SqrtDecomposition dec(n);
  vector<string> res;
  rep(_, q) {
    int c;
    cin >> c;
    if(c == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      --s;// --t;
      dec.change(s, t, x);
    } else {
      int i;
      cin >> i;
      --i;
      cout << dec.get(i) << endl;
    }
  }
}



Measured memory_bytes: 3136
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, n) for (i64 i = 0; i < (i64)(n); ++i)
#define reps(i, s, n) for (i64 i = s; i < (i64)(n); ++i)

void solve() {
    string S;
    cin >> S;
    int N = (int)S.size();
    reps(i, 0, N) {
        reps(j, i, N) {
            string t = "";
            reps(k, 0, i) t += S[k];
            reps(k, j, N) t += S[k];
            if (t == "keyence") {
                cout << "YES\n";
                return;
            }
        }
    }
    cout << "NO\n";
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

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

int main(){
    string s;
    cin >> s;
    char l = s[s.length()-1];
    if(l=='3')cout << "bon" << endl;
    else if(l=='0'||l=='1'||l=='6'||l=='8')cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main()
{   int a,b,ans=0;
    scanf("%d%d",&a,&b);
    if(a>b){
        ans+=a;
        a--;
    }else{
        ans+=b;
        b--;
    }
    if(a>b){
        ans+=a;
        a--;
    }else{
        ans+=b;
        b--;
    }
    printf("%d",ans);

    return 0;
}


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

ll F(ll A, ll X){ return A / X; }

ll F(ll L, ll R, ll X){ return F(R, X) - F(L - 1, X); }

ll lcm(ll x, ll y){ return x * y / __gcd(x, y); }

int main(){
	ll A, B, C, D; cin >> A >> B >> C >> D;
	
	cout << B-A+1 - F(A,B,C) - F(A,B,D) + F(A,B,lcm(C,D)) << '\n';
}


Measured memory_bytes: 256
S=input()
num = len(S) - 1

for i in range(2**num):
    l = ['-']*num
    for j in range(num):
        if(i>>j)&1:
            l[num-j-1] = "+"

    formula=""
    for l_num,l_m in zip(S,l+[""]):
        formula += l_num + l_m #足していく

    if eval(formula)==7:
        print(formula+"=7")
        break

Measured memory_bytes: 3060
/*
 *  Author  : StelaYuri
 * Language : GNU G++ 14
 */

//#pragma comment(linker,"/STACK:1024000000,1024000000")
//#pragma GCC optimize(3)
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<functional>
#include<iomanip>
//#include<unordered_map>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define multiCase int T;cin>>T;for(int t=1;t<=T;t++)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repp(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define perr(i,a,b) for(int i=(a);i>(b);i--)
#define pb push_back
#define eb emplace_back
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=0x3f3f3f3f;
const ll LINF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-12;
const double PI=acos(-1.0);
const double angcst=PI/180.0;
const ll mod=1e9+7;
ll max_3(ll a,ll b,ll c){if(a>b&&a>c)return a;if(b>c)return b;return c;}
ll min_3(ll a,ll b,ll c){if(a<b&&a<c)return a;if(b<c)return b;return c;}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll qmul(ll a,ll b){ll r=0;while(b){if(b&1)r=(r+a)%mod;b>>=1;a=(a+a)%mod;}return r;}
ll qpow(ll a,ll n){ll r=1;while(n){if(n&1)r=(r*a)%mod;n>>=1;a=(a*a)%mod;}return r;}
ll qpow(ll a,ll n,ll p){ll r=1;while(n){if(n&1)r=(r*a)%p;n>>=1;a=(a*a)%p;}return r;}

ll dp[2010];

void solve()
{
    ll n;
    cin>>n;
    if(n<3)
    {
        cout<<0<<'\n';
        return;
    }
    per(i,n-3,0)
    {
        dp[i]=1;
    }
    int p=n-3;
    while(p>0)
    {
        per(i,p-3,0)
        {
            dp[i]=(dp[i]+dp[p])%mod;
        }
        p--;
    }
    cout<<dp[0]<<'\n';
}
int main()
{
    closeSync;
    //multiCase
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef vector<int> vi;
struct DFA{
	int Q;		//state
	int A;		//alphabet
	vector<vi> t;
	int q0;
	vi F;
	DFA(){}
	DFA(int Q,int A,vector<vi> t,int q0,vi F) :Q(Q),A(A),t(t),q0(q0),F(F){}
};
struct NFA{
	int Q;
	int A;
	vector<vector<vi> > t;
	int q0;
	vi F;
	NFA(int Q,int A,vector<vector<vi> >t,int q0,vi F) :Q(Q),A(A),t(t),q0(q0),F(F){}
	DFA NFAtoDFA(){
		int DN=1;
		vector<vi> dt(1,vi(A,0));
		vi DF;
		map<vi,int> mp;		//sets->id
		queue<vi> que;
		que.push(vi{q0});
		mp[vi{q0}]=0;
		while(!que.empty()){
			vi vc=que.front();que.pop();
			bool isF=0;
			for(int f:F) for(int v:vc) if(f==v) isF=1;
			if(isF) DF.pb(mp[vc]);
			rep(i,A){
				vi nvc;
				for(int v:vc){
					for(int u:t[v][i]) nvc.pb(u);
				}
				sort(all(nvc));nvc.erase(unique(all(nvc)),nvc.end());
				if(!mp.count(nvc)){
					mp[nvc]=DN++;
					dt.pb(vi(A,0));
					que.push(nvc);
				}
				dt[mp[vc]][i]=mp[nvc];
			}
		}
		return DFA(mp.size(),A,dt,0,DF);
	}
};

typedef long long ll;
ll dp[1000];
bool vis[1000];
vector<int> vc;
DFA M;
void dfs(int v){
	vis[v]=1;
	rep(i,10) if(!vis[M.t[v][i]]) dfs(M.t[v][i]);
	vc.pb(v);
}
int main(){
	while(true){
		int N,a[6],b[6];
		cin>>N;
		if(N==0) break;
		rep(i,N) cin>>a[i]>>b[i];
		int Q=4*N+1,A=10,q0=0;
		vector<int> F;
		F.pb(4*N);
		vector<vector<vi> > t(Q,vector<vi>(A,vi{}));
		rep(i,N){
			int x=a[i]/10,y=b[i]/10;
			rep(j,10){
				if(a[i]<=j&&j<=b[i]) t[4*i][j].pb(4*i+4);
			}
			if(x>0){
				t[4*i][x].pb(4*i+1);
				rep(j,10) if(a[i]<=x*10+j&&x*10+j<=b[i]) t[4*i+1][j].pb(4*i+4);
			}
			if(x+1<y){
				for(int j=x+1;j<y;j++) t[4*i][j].pb(4*i+2);
				rep(j,10) t[4*i+2][j].pb(4*i+4);
			}
			if(x<y){
				t[4*i][y].pb(4*i+3);
				rep(j,10) if(a[i]<=y*10+j&&y*10+j<=b[i]) t[4*i+3][j].pb(4*i+4);
			}
		}
		M=NFA(Q,A,t,q0,F).NFAtoDFA();
		queue<int> que;
		N=M.Q;
		rep(i,N) dp[i]=0,vis[i]=0;
		dp[M.q0]=1;
		vc.clear();
		dfs(M.q0);
		reverse(all(vc));
		for(int v:vc){
			rep(i,10) dp[M.t[v][i]]+=dp[v];
		}
		ll ans=0;
		for(int f:M.F) ans+=dp[f];
		cout<<ans<<endl;
	}
}

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

#define STR_MAX 10001

int main()
{
	int N, i;
	char S[STR_MAX];
	scanf("%d%s", &N, S);

	for (i = 0; S[i] != '\0'; i++) {
		if (S[i] + N <= 'Z') {
			S[i] += N;
		} else {
			S[i] = (S[i] + N - 'Z') + 'A' - 1;
		}
	}
	printf("%s\n", S);

	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define MAX1 100000
#define MAX2 1000000000
int main(void)
{
    int n,i,a[MAX1],sum4=0,sum2=0,sum1=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]%4==0)
            sum4++;
        else if(a[i]%2==0)
            sum2++;
        else if(a[i]%2)
            sum1++;}
    if(sum2==0&&sum4+1>=sum1)
        printf("Yes");
    else if(sum4>=sum1)
        printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 512
def n_c_k(n, k):
    x = y = 1
    for i in range(k): 
        x *= n - i
        x %= mod
        y *= i + 1
        y %= mod
    return x * pow(y, mod - 2, mod) % mod

n, a, b = map(int, input().split())

mod = 10 ** 9 + 7
ans = (pow(2, n, mod) - 1 - n_c_k(n, a) - n_c_k(n, b)) % mod 
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+c==2*b)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n, x;
    cin >> n >> x;

    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];

    int ans = 1;
    int now = 0;
    for(int i = 0; i < n; i++){
        now += l[i];
        if(now <= x)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
counts = {}
best = 0
best_words = []
for idx in range(n):
    string = input()
    if counts.get(string) is None: counts[string] = 1
    else: counts[string] += 1

    score = counts[string]

    if score > best:
        best = score
        best_words = [string]
    
    elif score == best:
        best_words.append(string)

for string in sorted(best_words):
    print(string)

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

using namespace std;

int main( ) {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n;
	t = 1;
	while(t--) {
	 cin >> n;
	 cout << (n * (n + 1)) / 2 << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005
int bit[MAX_N];
int n; //　1-index

void adds(int a, int w){
    for(int x = a; x <= n; x += x & -x) bit[x] += w;
}
int sums(int a){
    int ret = 0;
    for(int x = a; x > 0; x -= x & -x) ret += bit[x];  
    return ret;
}

int main() {
    string s;
    cin >> s;
    n = s.size();
    int a[n+1] = {};
    vector<int> c[26];
    srep(i,1,n+1){
        int x = (int)s[i-1] - 97;
        a[i] = x;
        c[x].push_back(i);
    }
    int now[26] = {};

    int odd = 0;
    rep(i,26)odd += (c[i].size() % 2);
    if(n % 2 == 0){
        if(odd > 0)dame;
    }else{
        if(odd != 1)dame;
    }

    ll ans = 0;
    int flag = 0;
    srep(i,1,n){
        int x = a[i];
        if(c[x].size() % 2 == 1 && now[x] == c[x].size()/2){
            flag = 1;
        }else if(now[x] < c[x].size() / 2){
            // バイナリインデックスツリーいるじゃん.(ここで気づいた)(転倒数絡むから当たり前)
            if(flag == 1)ans += 1;
            ans += n - c[x][c[x].size() - 1 - now[x]] - (sums(n) - sums(c[x][c[x].size() - 1 - now[x]]));
            adds(c[x][c[x].size() - 1 - now[x]], 1);
            //adds(i,1);
        }
        now[x]++;
    }

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 2684
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String s[] = new String[N];
        int t[] = new int[N];
        for(int i=0;i<N;i++){
            s[i] = sc.next();
            t[i] = sc.nextInt();
        }
        String X = sc.next();
        long result = 0;
        boolean flag = false;

        for(int i=0;i<N;i++) {
            if (flag) {
                result += t[i];
            }else if(s[i].equals(X)){
                flag = true;
            }
        }

        System.out.println(result);
    }
}


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

int main() {
 ll n; cin >> n;
 ll sum=0;
 //1+2+3+...と足していった時、mを足したときnをこえる場合、
 //mまでの整数の和でnは表せる。
 for(int i=1;i<=n;i++){
   sum+=i;
   if(sum>=n){
     cout << i << endl;
     return 0;
   }
 }
 return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cmath>

using namespace std;

template <typename T>
T power(T x, int n) {
  T ans{1};
  while (n) {
    if (n % 2) ans *= x;
    x *= x;
    n >>= 1;
  }
  return ans;
}

void solve(int X) {
  int s = sqrt(X)+1;
  int x,ma{1};
  for(int i = 2; i < s; ++i) {
    x = 0;
    for (int j=2; x <= X; ++j) {
      ma = max(x,ma);
      x = power(i,j);
    }
  }
  cout << ma << endl;
}

int main() {
  int X;
  cin >> X;
  solve(X);
  return 0;
}


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

 
const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n,t;
	while(cin >> n >> t){
		vector<int> prices;
		for(int i=0;i<n;i++){
			int p;
			cin >> p;
			prices.push_back(p);
		}
		
		int max_profit = 0;
		int cur_min = prices[0];
		int r=0;
		
		for(int i=1;i<n;i++){
			if(prices[i] - cur_min > max_profit){
				r=1;
				max_profit = prices[i] - cur_min;
			}
			else if(prices[i] < cur_min){
				cur_min = prices[i];
			}
			else if(prices[i] - cur_min == max_profit){
				r++;
			}
		}
		
		cout << r << endl;
	}
	
	return 0;
}



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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
vector<ll> to[200005];
vector<ll> memo(200005);
vector<ll> done(200005);
ll dp(int v, int p = -1)
{
    if (done[v] == 1)
    {
        return memo[v];
    }
    
    // ll max1 = -1;
    // ll min1 = 1000000000;
    ll g = 0;
    for (ll x : to[v])
    {
        if (x == p)
        {
            continue;
        }
        g++;
        // max1 = max(dp(x, v), max1);
        //min1 = min(min1, dp(x, v));
        //res += dp(x, v);
    }

    memo[v] = g;
    done[v] = 1;
    return g;
}
int main()
{
    ll n;
    cin >> n;
    vector<ll> B(n);
    rep(i, n - 1)
    {
        int b;
        cin >> b;
        B[i] = b - 1;
        to[b - 1].push_back(i + 1); //上司の親に部下の子供。
    }
    rep(i, n)
    {
        cout << dp(i) << endl; //一番上司を与えた時に答えを返す。
    }
}

Measured memory_bytes: 18656
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define int long long
#define ll long long
#define ac() cout<<"Yes"<<endl;
#define wa() cout<<"No"<<endl;
#define dd cout<<"---debug---"<<endl;
#define ff(a,b)  for(int (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(int (a)=0;(a)<(b);(a)++)
#define re read()
#define pr(a) print(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1;while(b){if(b&1)ans=ans*a%mod;
a=a*a%mod;b>>=1;}return ans;}
int read(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void print(int x){if(x>=10){print(x/10);}//
putchar(x%10+'0');}
//
const int maxm=1e5+5;
const int mod=1e9+7;
int a[maxm],b[maxm];


signed main(){
    int n=re;
    int ok=1;
    for(int i=1;i<=n;i++){
        int x=re;
      if(x%2!=0)continue;
        if(x%3==0||x%5==0)continue;
        ok=0;
    }
    if(ok){
        cout<<"APPROVED"<<endl;
    }else{
        cout<<"DENIED"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE CPP #-}
module Main where

import qualified Data.Vector.Unboxed as V 
import qualified Data.Map.Strict as M
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Char
import qualified Data.List as L

dump :: (Show a) => a -> IO()
#if __GLASGOW_HASKELL__ >= 800
dump x = print x
#else
dump _ = pure ()
#endif

-- "101010" -> [1,0,1,0,1,0]
readToList :: String -> [Int]
readToList [] = []
readToList (x:xs) = read [x] : readToList xs

 
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

-- "10 10 10" -> [10, 10, 10]
getList :: IO [Int]
getList = (fmap (read . BS.unpack) . BS.words) <$> BS.getLine

-- "10 10 10" -> [10, 10, 10]
getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readmat :: Int -> IO [[Int]]
readmat rows = replicateM rows getList

newtype UF a = UF (M.Map a a) deriving (Show) -- Map node parent

makeuf :: Int -> UF Int
makeuf n = let m = M.fromList $ zip [0..n] [0..n]
            in UF m

unionUF :: (Eq a, Ord a) => a -> a -> UF a -> UF a
unionUF l r uf@(UF m) = let lp = findUF l uf
                            rp = findUF r uf
                        in if lp == rp
                           then uf
                           else if size l uf < size r uf
                                then UF $ M.update (const $ Just rp) lp m
                                else UF $ M.update (const $ Just lp) rp m

findUF :: (Eq a, Ord a) => a -> UF a -> a
findUF x uf@(UF m) = let px = m M.! x
                in if px == x
                   then px
                   else findUF px uf -- TODO 貼り直し

size :: (Eq a, Ord a) => a -> UF a -> Int
size x (UF m) = M.size $ M.filter (\par -> par==x) m

genbit :: Int -> [[Int]]
genbit 0 = []
genbit 1 = [[0],[1]]
genbit len = do
  x <- [0,1]
  map (x:) $ genbit (len-1)

base :: Int
base = 10 ^ 9 + 7

forn :: (Num a, Enum a, Monad m) => a -> (a -> m b) -> m [b]
forn x = forM [0..(x-1)]

count :: (Eq a) => a -> [a] -> Int
count y = length . filter (== y)

main :: IO()
main = do
  let xs = M.fromList $ zip ["SUN","MON","TUE","WED","THU","FRI","SAT"] [7,6..0]
  s <- getLine
  print $ xs M.! s


Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=(a>b)?(a):(b);
#define chmin(a, b) (a)=(a<b)?(a):(b);
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PL;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/




int main(void) {
  ll i, j, k;
  
  ll N, M, L;
  cin >> N >> M >> L;
  
  ll d[333][333];
  for(i=0; i<N; i++) for(j=0; j<N; j++) d[i][j]=INF;
  
  for(i=0; i<M; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    d[a][b]=c; d[b][a]=c;
  }
  
  for(k=0; k<N; k++) for(i=0; i<N; i++)
    for(j=0; j<N; j++) chmin(d[i][j], d[i][k]+d[k][j]);
    
  ll co[333][333];
  for(i=0; i<N; i++) for(j=0; j<N; j++)
    if(d[i][j]<=L) co[i][j]=1;
    else co[i][j]=INF;
  
  for(k=0; k<N; k++) for(i=0; i<N; i++)
    for(j=0; j<N; j++) chmin(co[i][j], co[i][k]+co[k][j]);
  
  ll Q;
  cin >> Q;
  for(ll _=0; _<Q; _++) {
    ll s, t;
    cin >> s >> t;
    s--; t--;
    
    if(co[s][t]==INF) pt(-1);
    else pt(co[s][t]-1); //-1:初めは燃料満タンのため
    
  }
  
  
}



Measured memory_bytes: 2048
N, M = map(int, input().split())

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

total = sum(A)

bodor = total / (4 * M)
cnt = 0

for i in A:
    if i >=  bodor:
        cnt += 1

if cnt >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 81176
h,w = map(int,input().split())
c = [input() for _ in range(h)]

ans = 0
for i in range(w-1):
    cost = [[0] * (h+1) for _ in range(h+1)]
    for ci in range(1,h+1):
        for cj in range(ci,h+1):
            cost[ci][cj] = cost[ci-1][cj-1] + (c[ci-1][i] == c[cj-1][i+1])

    for cj in range(1,h+1):
        for ci in range(cj+1,h+1):
            cost[ci][cj] = cost[ci-1][cj-1] + (c[ci-1][i] == c[cj-1][i+1])

    dp = [[0] * (h+1) for _ in range(h+1)]
    for ci in range(1,h+1):
        for cj in range(1,h+1):
            dp[ci][cj] = min(dp[ci-1][cj], dp[ci][cj-1]) + cost[ci][cj]

    ans += dp[-1][-1]

print(ans)

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<Pi> vec;
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    vec.emplace_back(a, b);
  }
  sort(all(vec));
  vint sum(N+1, 0);
  rep(i, N) sum[i+1] = sum[i]+vec[i].second;
  rep(i, N) sum[i+1] -= vec[i].first;
  vint sum2(N+1, 0);
  rep(i, N) sum2[i+1] = sum[i+1]-vec[i].second;
  int ans = 0, mn = inf;
  rep(i, N) {
    chmin(mn, sum2[i+1]);
    chmax(ans, sum[i+1]-mn);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 18560
L = list(map(int, input().split()))
a = L[0]
b = L[1]
c = L[2]
count = 0
if a==b:
    count+=1
if b==c:
    count+=1
if c==a:
    count+=1
if count==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
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 K = sc.nextInt();

		int total = 0;
		if (K <= A) {
			total = K;
		} else if (K <= A + B) {
			total = A;
		} else {
			total = 2 * A + B - K;
		}

		System.out.println(total);

		sc.close();

	}
}


Measured memory_bytes: 35852
s=input()
t=input()

s_d = ''.join(sorted(s))
t_d = ''.join(sorted(t,reverse=True))

arr = [t_d,s_d]
arr=sorted(arr)

if s==t:
    print('No')
    exit(0)

if arr[0]==s_d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9140
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int main() {
	int n;
	string a;
	cin >> n;
	cin >> a;
	int len;
	for (len = 0; a[len] != '\0'; len++);
	if (len <= n)cout << a << endl;
	else {
		for (int i = 0; i < n; i++)cout << a[i];
		cout << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<cmath>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

ll C[102000][1001];



int main(){
  int N;
  ll M;
  cin>>N>>M;
  ll m=M;
  vector<ll> V;
  int count=0;
  for(int i=2;i<=(int)sqrt(M);i++,count=0){
    if(m%i==0){
      while(m%i==0){
        m/=i;
        count++;
      }
      V.push_back(count);
    }
  }
  if(m!=1) V.push_back(1);
  
  for(int i=0;i<102000;i++){
    for(int j=0;j<=min(i,1000);j++){
      if(j==0) C[i][j]=1;
      else C[i][j]=C[i-1][j]+C[i-1][j-1];
      C[i][j]%=MOD;
    }
  }

  ll ans=1;
  for(int i=0;i<(int)V.size();i++){
    //cout<<V[i]<<endl;
    ans*=C[V[i]+N-1][V[i]];
    ans%=MOD;
  }
  cout<<ans<<endl;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};
int main() {
    lint x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    } else {
        lint s = (2 * x - y) / 3, t = (-x + 2 * y) / 3;
        if (s < 0 or t < 0) {
            cout << 0 << endl;
            return 0;
        } else {
            combination comb(x + y + 1);
            cout << comb(s + t, s).x << endl;
        }
    }

    return 0;
}

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

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int sum = 0;
        int num = 0;
        int count = 0;

        String line;

        while ((line = br.readLine()) != null) {
            count++;
            String[] input = line.split(",");

            int a = Integer.parseInt(input[0]);
            int b = Integer.parseInt(input[1]);

            sum += a * b;
            num += b;
        }

        System.out.println(sum);
        System.out.println((int) ((double) num / count + 0.5));
    }
}


Measured memory_bytes: 24108
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;


public class Main {

	public static class pair implements Comparable<pair> {
		int id;
		int ans;

		pair(int x, int y) {

			id = x;
			ans = y;

		}

		public pair() {

		}

		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		}
	}

//	static int mod = (int) 998244353.;
	static int mod=(int)1e9+7;
	static ArrayList<Integer> gr[];
	static int[][] ar;
	static Scanner sc = new Scanner(System.in);
	static int pri[] = new int[(int) 1e6 + 5];
	static StringBuilder out = new StringBuilder();

	static long dp[][];

	public static void main(String[] args) throws IOException {
		int t =1;// sc.nextInt();
		
		while (t-- > 0) {
		
			int n=sc.nextInt();
			gr=new ArrayList[n];
			for(int i=0;i<n;i++) {
				gr[i]=new ArrayList<>();
			}
			
			for(int i=0;i<n-1;i++) {
				int u=sc.nextInt();
				int v=sc.nextInt();
				u--;
				v--;
				gr[u].add(v);
				gr[v].add(u);
			}
			long ans=0;
			dp=new long[n][2];
			ans+=solve(0,-1,0);
			ans+=solve(0,-1,1);
			System.out.println(ans%mod);
			
		}

		System.out.println(out);
	}
	static int set;
	static long solve(int root,int pa,int c) {
		
		
		long res=1;
		if(dp[root][c]!=0)return dp[root][c];
		for(Integer ch: gr[root]) {
			long ans=0;
			if(ch==pa)continue;
			
				ans+=solve(ch,root,1);
			
			if(c==1) {
				ans+=solve(ch,root,0);
			}
			ans%=mod;
			res*=ans;
			res%=mod;
		}
		return dp[root][c]=res%mod;
		
		
	}


}

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

int main(){
    string S;
    cin >> S;
    int n;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        string f;
        cin >> f;
        if(f == "replace"){
            int a,b;
            string K;
            cin >> a >> b >> K;
            S.replace(a,K.size(),K);
        }else if(f == "reverse"){
            int a,b;
            cin >> a >> b;
            string sub = S.substr(a,b-a+1);
            for(int j = 0; j < sub.size(); j++){
                S[a+j] = sub[sub.size()-1-j];
            }
        }else{
            int a,b;
            cin >> a >> b;
            string sub = S.substr(a,b-a+1);
            cout << sub << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3212
#include <iostream>

using namespace std;

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

  int a, b;
  cin >> a >> b;

  int ans = 0;
  for (int i = a; i <= b; ++i) {
    const int hi = i / 1000;

    const int low = i % 100;
    const int flip = low / 10 + 10 * (low % 10);
    if (hi == flip)
      ++ans;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
c = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
  ans = []
  for j in range(m):
    ans.append(abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]))
  print(ans.index(min(ans)) + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll n,r; cin>>n>>r;
	if(n>=10){
		cout<<r<<'\n';
	}
	else{
		cout<<r+100*(10-n)<<'\n';
	}
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

int main(){

	int x,y,s;
	vector<int> vx;
	vector<int> vy;
	vector<int> vs;

	while(1){
		cin>>x>>y>>s;
		if(x==0 && y==0 && s==0) break;
		vx.push_back(x);
		vy.push_back(y);
		vs.push_back(s);
	}

	for(int l=0; l<vx.size(); l++){
		int ans = -1;
		for(int i=1; i<1000; i++){
			for(int j=1; j<1000; j++){
				if((i*(100+vx[l]))/100 + (j*(100+vx[l]))/100 != vs[l]) continue;
				ans = max(ans , (i*(100+vy[l]))/100 + (j*(100+vy[l]))/100);
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <string>

using namespace std;

bool kaibun(string s){
    int n = s.length();
    for (int i=0; i<n/2; i++)
        if (s[i] != s[n-1-i])
            return false;
    return true;
}

int main(int argc, char** argv){
    string S, T, U;
    cin >> S;
    int N = S.length();
    T = S.substr(0, (N-1)/2);
    U = S.substr((N+1)/2, (N-1)/2);
    if (kaibun(S) && kaibun(T) && kaibun(U)) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256