akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long 
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)


#define N 200005


  vector<int> path;


  vector<int> adj[N];
  vector<int> vis(N,false);

  int cycle = -1;

  void dfs(int s)
  {

    if(!vis[s])
    {
      vis[s] = true;
      path.push_back(s);
      for(auto i : adj[s])
      {
      
        if(!vis[i])
          {
            dfs(i);
          }
          else
          {
            cycle = i;
          }
      }

    }
  }

int32_t main()
{


    IOS

    int n,k;
    cin >> n >> k;


    vector<int> v(n+1);
    for(int i = 1; i <= n; i++)
    {
      int x;
      cin >> x;
      adj[i].push_back(x);
     // trace2(i,x);
    }


    dfs(1);



    if(k < path.size())
    {
      cout << path[k];
      return 0;
    }
    else if(cycle == -1)
    {
      cout << path[k%(path.size())];
      return 0;
    }
    

    // for(auto i :path)
    // {
    //   cout << i << " ";
    // }



    // cout << endl;

    int ans1;

    for(int i = 0; i < path.size(); i++)
    {
      if(path[i] == cycle)
      {
        ans1 = i;
        break;
      }
    }


    for(int i = 0; i <= n; i++)vis[i] = false;


    path.clear();
    dfs(cycle);

    // for(auto i :path)
    // {
    //   cout << i << " ";
    // }



    // cout << endl;

    cout << path[(k-ans1)%(path.size())];



    return 0;
}

Measured memory_bytes: 28128
#include <stdio.h>

int main(void){
  int n,i;
  int fib[45];

  fib[0] = fib[1] = 1;

  scanf("%d",&n);

  for( i=2 ; i<=n ; i++ ){
    fib[i] = fib[i-1] + fib[i-2];
  }

  printf("%d\n",fib[n]);

  return 0;
}

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

using ll = long long;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    ll x = 0;
    for(int i = 0; i < n; ++i) {
        x ^= a[i];
    }

    int ans = 0;
    vector<bool> used(n);
    for(ll b = 30, mask = (1LL << 30) - 1; b >= 0; --b, mask >>= 1) {
        if(!(x & (1LL << b))) continue;
        for(int i = 0; i < n; ++i) {
            if(used[i]) continue;
            if((a[i] & (1 << b)) && (a[i] & mask) == 0) {
                used[i] = true;
                ans += 1;
                x ^= a[i];
                a[i]--;
                x ^= a[i];
                break;
            }
        }
    }

    if(x != 0) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 640
n,s=`dd`.split;n=n.to_i;%w(SS SW WS WW).find{|_|a=_.chars;2.upto(n+1){|i|a[i]=(a[i-1]==?W)^(a[i-2]==?W)^(s[~-i%n]==?o)??S:?W};a[0,2]==a[n,2]&&$><<a[0..-3]*''}||(p -1)

Measured memory_bytes: 16956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t A, B, N;
  cin >> A >> B >> N;
  int64_t M = min(B - 1, N);
  int64_t ans = (floor((A * M) / B) - A * floor(M / B));
  cout << ans << endl;
}

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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	n--;
	int sum = 1, ans = 1;
	while ((sum + k - 1) / k <= n)
	{
		n -= (sum + k - 1) / k;
		sum += (sum + k - 1) / k;
		ans++;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3116
#include<iostream>
int main(){
    int n;
    std::cin>>n;
    
    int a[n];
    for(int i=0;i<n;i++){
        std::cin>>a[i];
    }
    int cnt=0,max=0;
    
    for(int i=0;i<n;i++){
        if(a[i]==0){
            cnt=0;
        }else{
            cnt++;
            if(cnt>max){
                max=cnt;
            }
        }
    }
    std::cout<<max+1<<"\n";
    return 0;
}
    


Measured memory_bytes: 3116
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
using namespace std;

int main(){
	string S;
	cin>>S;
	int	len = S.length();
	int L = len - 2;
	int min;
	for(int i=0;i<L;i++){
		string t = S.substr(i, 3);
		int t_int = atoi(t.c_str());
		if(i==0){
			min = abs(t_int-753);
		}
		if(i!=0 && abs(t_int-753)<min){
			min = abs(t_int-753);
		}
	}
	cout<<min;
	return 0;
}	


Measured memory_bytes: 256
/* blog: https://misteer.hatenablog.com/entry/ARC095-E */

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using Bool = bool;
using Int = long long int;
using String = std::string;
template <class T>
using Vector = std::vector<T>;

// 各関数は上から下に流れるようになっている
// ! で始まるコメントは自分が踏んだバグ
struct {
    Int h, w;
    Vector<Int> col;
    Vector<String> s, t;
    // sは入力 tは行を並び替えた後、転置したもの
    Bool possible;

    void operator()() {
        possible = false;
        std::cin >> h >> w;

        s.resize(h), t.resize(w);
        for (auto& x : s) std::cin >> x;
        for (auto& y : t) y.resize(h);  // ! tのresizeし忘れ

        col.resize(h);
        enumcol_center();
    }

    // 真ん中の行の列挙　
    // ! これを後回しにして、中心の全列挙をミスる
    void enumcol_center() {
        if (h % 2 == 0) {
            enumcol(0, 0);
        } else {
            for (Int x = 0; x < h; ++x) {
                col[h / 2] = x;
                enumcol(1 << x, 0);
            }
        }
    }

    // bは固定済みの行　iはいくつのペアを固定したか
    void enumcol(Int b, Int i) {
        Int x;
        for (x = 0; x < h; ++x) {
            if (!((b >> x) & 1)) break;
        }
        if (x == h) {
            align();
            return;  // ! ここでreturnしないとhを固定し始める
        }

        for (Int y = x + 1; y < h; ++y) {
            if (!((b >> y) & 1)) {
                col[i] = x;
                col[h - i - 1] = y;
                enumcol(b | (1 << x) | (1 << y), i + 1);
            }
        }
    }

    // colに従ってtを埋める
    void align() {
        for (Int y = 0; y < w; ++y) {
            for (Int x = 0; x < h; ++x) {
                t[y][x] = s[col[x]][y];
            }
        }
        check_center();
    }

    // 真ん中の行の列挙　
    // ! enumcol_center()と同じく
    void check_center() {
        if (w % 2 == 0) {
            check(0);
        } else {
            for (Int x = 0; x < w; ++x) {
                // 回文判定
                String z = t[x];
                std::reverse(z.begin(), z.end());
                if (z == t[x]) check(1 << x);
            }
        }
    }

    // 両端から、互いに逆なペアを決めていく
    // bは決定済みの行番号
    void check(Int b) {
        Int x;
        for (x = 0; x < w; ++x) {
            if (!((b >> x) & 1)) break;
        }

        if (x == w) {
            possible = true;
            return;  // ! ここで枝刈りしないと、全文字が同じケースで非常に時間がかかる
                     //   なんならYESを出力してexit()を呼んでもいい
        }

        String z = t[x];
        std::reverse(z.begin(), z.end());

        for (Int y = x + 1; y < w; ++y) {
            if (!((b >> y) & 1)) {
                if (t[y] == z) {
                    check(b | (1 << x) | (1 << y));
                    return;
                }
            }
        }
    }
} solve;

int main() {
    solve();
    std::cout << (solve.possible ? "YES" : "NO") << std::endl;
    return 0;
}


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

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();

        int[] ab = new int[N + 1];
        for (int i = 0; i < N; i++) {
            ab[i] = (in.i() << 8) + in.i();
        }
        ab[N] = Integer.MAX_VALUE;
        Arrays.sort(ab);

        int[] cd = new int[N];
        Arrays.setAll(cd, i -> (in.i() << 8) + in.i());
        Arrays.sort(cd);

        int[] list = new int[N];
        int size = 0;

        int ans = 0;
        for (int i = 0, j = 0; i < N; i++) {
            int c = cd[i] >> 8;
            int d = cd[i] & (1 << 8) - 1;
            while ((ab[j] >> 8) < c) {
                list[size++] = ab[j++] & (1 << 8) - 1;
            }

            int max = -1;
            int l = -1;
            for (int k = 0; k < size; k++) {
                if (list[k] < d && max < list[k]) {
                    max = list[l = k];
                }
            }
            if (l > -1) {
                ans++;
                list[l] = list[--size];
            }
        }

        System.out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 33416
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <iomanip>

using namespace std;

typedef struct {
	int num;
	int a;
}Student;

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

	int n;
	cin >> n;
	vector<Student> student(n);
	for (int i = 0; i < n; i++) {
		student[i].num = i + 1;
		cin >> student[i].a;
	}

	sort(student.begin(), student.end(), [](Student& a, Student& b) {return a.a < b.a; });
	
	for (int i = 0; i < n; i++) {
		cout << student[i].num << " ";
	}

	return 0;
}

Measured memory_bytes: 1664
def gather(sub, boundary): # sub string
    a = [0 for _ in range(len(sub))]
    if boundary %2 == 1:
        r_count = (len(sub)+1) //2
        l_count = (len(sub))//2
    else:
        l_count = (len(sub)+1) //2
        r_count = (len(sub))//2
    a[boundary-1] = r_count
    a[boundary] = l_count
    return a

S = input() + "R"
sub = ""
flag = False
ans = []
boundary = None
for i in range(len(S)):
    if S[i] == "L":
        if not flag: boundary = i - len(ans)
        flag = True
        sub += "L"
    elif flag and S[i] == "R":
        ans += gather(sub, boundary)
        sub = "R"
        flag = False
    else: sub += "R"

ans = [str(a) for a in ans]
ans = ' '.join(ans)
print(ans)

Measured memory_bytes: 10628
s = input()
t = input()
u = None
for i in range(len(s) - len(t) + 1):
    ok = True
    for j in range(len(t)):
        if s[i + j] != t[j] and s[i + j] != '?':
            ok = False
            break
    if ok:
        v = []
        for j in range(i):
            if s[j] == '?': v.append('a')
            else: v.append(s[j])
        for j in t:
            v.append(j)
        for j in range(i + len(t), len(s)):
            if s[j] == '?': v.append('a')
            else: v.append(s[j])
        v = ''.join(v)
        if u is None or v < u: u = v
if u is None: print('UNRESTORABLE')
else: print(u)


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

int main(void){
	int stack[10];
	int pt=0, n;
	while(cin >> n){
		if(n == 0) {
			cout << stack[pt-1] << endl;
			pt--;
		}
		else {
			stack[pt] = n;
			pt++;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
import math
n = int(input())
ans = 10
for i in range(1, int(math.sqrt(n))+1):
  if n%i == 0:
    ans2 = max(len(str(i)), len(str(n//i)))
    #print(i,len(str(i)), len(str(n//i)))
    if ans > ans2:
      ans = ans2
print(ans)
    

Measured memory_bytes: 9016
#include<bits/stdc++.h>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#define ll long long
using namespace std;
  
int main()
{
  
	    
	    ll  i,j,k,l,d,r,n,m;
	    cin>>n;
	    ll ara[n+1];
	    ll count=0;
	   for(i=1;i<=n;i++)
	   {
	   	 cin>>ara[i];
	   	 if(ara[i] & 1 && i&1)
	   	 {
	   	 	count++;
			}
	   }
       cout<<count<<endl;
        
	return 0;
}

Measured memory_bytes: 3640
n = gets.to_i

list = []
n.times{
  command = gets.split
  case command[0]
  when "insert"
    list.unshift(command[1])
  when "delete"
    index = list.find_index(command[1])
    list.delete_at(index) if index
  when "deleteFirst"
    list.shift
  when "deleteLast"
    list.pop
  end
}
puts list.join(" ")

Measured memory_bytes: 97804
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next().toString()
    val t = sc.next().toString()
    val a = sc.nextInt()
    val b = sc.nextInt()
    val u = sc.next().toString()

    abc154a(s, t, a, b, u)
}

fun abc154a(s: String, t: String, a: Int, b: Int, u: String) {
    var a = a
    var b = b
    if (u == s) {
        a--
    } else {
        b--
    }

    println(a.toString() + " " + b.toString())
}

Measured memory_bytes: 31388
X = int(input())
Ans = []
for A in range(201):
  for B in range(A):
    if A ** 5 - B ** 5 == X:
      Ans = [A, B]
    if A ** 5 + B ** 5 == X:
      Ans = [A, B * (-1)]
      break
      
print(Ans[0], Ans[1])

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

int main()
{
  int a, b;
  cin >> a >> b;
  double ad = a, bd = b;

  cout << a / b << " " << a % b << " " << fixed << setprecision(6) << ad / bd << endl;

  return 0;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >>M;
  vector<int> L(M),R(M);
  for (int i=0;i<M;i++){
    cin >>L.at(i)>>R.at(i);
  }
  int mi=0,ma=N;
  for (int i=0;i<M;i++){
    mi=max(mi,L.at(i));
    ma=min(ma,R.at(i));
  }
  if(ma-mi+1>0)cout << ma-mi+1 <<endl;  
  else cout << 0 <<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
string s;

ll dp[2][2][10001][102];
ll lim , tt , k , n , m;
vector < ll > inp ;

ll DP( ll pos , ll isSmall ,ll isStart, ll mod)
{
    if( pos == lim )
    {
        if(mod == 0 ) return 1;
        else return 0;
    }
    ll &ret = dp[isSmall][isStart][pos][mod];
    if(ret!=-1) return ret ;
    ll ses = isSmall ? 9 : inp[pos];
    ll i ;
    ret = 0 ;
  //  cout<<ret<<endl;
    if( !isStart )
    for ( i = 0 ; i <= ses ; i++ )
    {
        ret += DP( pos + 1 , isSmall | i < inp[pos] ,0, (i + mod)%k);
        ret %= 1000000007;
    }
    else
    {
         for ( i = 1 ; i <= ses ; i++ )
    {
        ret += DP( pos + 1 , isSmall | i < inp[pos] ,0, (i + mod)%k);
        ret %= 1000000007;
    }
    ret += DP( pos + 1 , 1 ,1, 0);
    ret %= 1000000007;
    }
    return ret%1000000007 ;
}

ll Cal()
{
    ll sz = s.size();
    for(ll i=0;i<sz;i++)
    {
        inp.pb(s[i]-'0');
    }
    lim = sz;
    return ((DP( 0 , 0 , 1 , 0 )+1000000007-1)%1000000007);
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>s>>k;
    ll ans = Cal();
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 33280
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
using mat = vector<vector<ll>>;
using vec = vector<ll>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){

int A,B;
cin>>A>>B;
if(B%A==0)cout<<A+B<<endl;
else cout<<B-A<<endl;
return 0;
}

Measured memory_bytes: 3608
A, B, C, D = map(int, input().split())

x0 = C // B
x1 = C % B

y0 = A // D
y1 = A % D

if x1 == 0:
  y0 += 1
if y1 == 0:
  x0 += 1

if x0 - y0 <= 0:
  print('Yes')
else:
  print('No')

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

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

    int n;
    ll k;
    cin >> n >> k;

    const int D = 60;
    const int MAX_N = 200005;
    vector<vector<int>> to(D, vector<int>(MAX_N)); // from j to 2<<i

    rep(i, n){
        cin >> to[0][i];
        --to[0][i];
    }

    rep(i, D-1){
        rep(j, n) to[i+1][j] = to[i][to[i][j]];
    }

    int v = 0;
    for(int i = D-1; i >= 0; --i){
        ll l = 1ll<<i;
        if(l <= k){
            v = to[i][v];
            k -= l;
        }
    }

    cout << v+1 << endl;

    return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b && a!=c){
        cout << "Yes" << endl;
    }
    else if(a==c && a!=b){
        cout << "Yes" << endl;
    }
    else if(b==c && b!=a){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

typedef long long ll;

#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
const ll MAX = 1e6;
/* end defineing */

signed main()
{
  int n;
  vector<ll> a;
  int arr[200010] = {};
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  // sort(a.begin(), a.end());

  for (int i = 1; i <= n; i++)
  {
    arr[i] = arr[i - 1] + a[i - 1];
  }
  // for (int i = 0; i <= n; i++)
  // cout << arr[i] << " ";
  // cout << endl;

  ll mn = INF;
  for (int i = 1; i < n; i++)
  {
    mn = min(mn, abs((arr[n] - arr[i]) - arr[i]));
  }
  cout << mn << endl;
}


Measured memory_bytes: 3956
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 1e17 , MOD=1e9+7;
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int32_t main(){
    boost;
    
    
    int k;
    
    cin>>k;
    int a,b;
    cin>>a>>b;
    for(int i =a; i <= b ; i++ ){
        if(i%k==0){
            cout<<"OK\n";
            return 0;
        }
    }
    cout<<"NG\n";
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),M=in(),K=in();
	for(int i=0;i<=N;i++){
		for(int j=0;j<=M;j++){
			if(M*i+N*j-2*i*j==K){
				out("Yes");
				return 0;
			}
		}
	}
	out("No");

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int N, W,w, v;
Int dp[108000];

int main(){
  cin >> N >> W;
  for(int i = 0;i < N;i++){
    cin >> w >> v;
    for(int i = W;i >= w;i--){
      dp[i] = max(dp[i], dp[i-w] + v);
    }
  }
  Int res = 0;
  for(int i = 0;i <= W;i++)res = max(res, dp[i]);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        x: i64,
        a: i64,
        b: i64,
    }

    if (x-a).abs()<(x-b).abs() {
        println!("A");
    } else {
        println!("B");
    }
    

}


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

using namespace std;

int main()
{
  while(1){
    int n,sum;
    cin>>sum;
    if(sum == 0){
      break;
    }

    n = 0;
    for(int i = 0;i < 9;++i){
      int book;
      cin>>book;
      n += book;
    }

    int ans = sum - n;
    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 3048
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){
  string c;
  int num=0;
  cin>>c;
  for(int i=0;i<4;i++){
    if(c[i]=='+') num++;
    else num--;
  }
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

def fact(n):
    i = 2
    res = []
    while i*i <= n:
        while n % i == 0:
            res.append(i)
            n /= i
        i += 1
    res.append(n)
    return sorted(res)

def dfs(array, a, b, pos):
    if len(array) == pos:
        return max(len(str(a)), len(str(b)))
    return min(dfs(array, a*array[pos], b, pos + 1), dfs(array, a, b*array[pos], pos + 1))

N = int(raw_input())
f = fact(N)
print dfs(f, 1, 1, 0)


Measured memory_bytes: 4008
#include<iostream>
#include<vector>

using namespace std;

int main() {
    
    long long N, M, a[100000];

    cin >> N >> M;

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

    vector<long long> dp(100000, 0);
    dp[0] = 1;
    for (int i = 0; i < M; i++) {
        dp[a[i]] = -1;
    }

    for (int i = 0; i < N; i++) {
        if (dp[i] == -1) continue;
        if (dp[i + 1] != -1) {
            dp[i + 1] += dp[i];
            dp[i + 1] %= 1000000007;
        }
        if (dp[i + 2] != -1) {
            dp[i + 2] += dp[i];
            dp[i + 2] %= 1000000007;
        }
    }

    cout << dp[N];

    return 0;
} 


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

string s = "keyence";

int main() {
    string S;
    cin >> S;
    ll N = S.length();
    bool exist = S == s;
    REP(i, N) {
        FOR(j, N, i) {
            ll index = 0;
            bool e = true;
            REP(n, N) {
                if (n >= i && n <= j)
                    continue;

                if (index >= s.length()) {
                    e = false;
                    break;
                }
                if (s[index] != S[n]) {
                    e = false;
                    break;
                }
                index++;
            }
            if (e && index == s.length())
                exist = true;
        }
    }

    if (exist)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
let () =
  let rec read () =
    try let (a,b,n) = Scanf.scanf "%d %d %d\n" (fun x y z -> (x,y,z)) in
        let a2 = if a >= b then a - (a/b)*b else a in
        let rec loop x sum = function
            0 -> sum
          | i ->
             let j = (x/b) in
             loop ((x mod b)*10) (sum+j) (i-1)
        in
        Printf.printf "%d\n" (loop (a2*10) 0 n);
        read ()
    with End_of_file -> ()
  in read ()
;;

Measured memory_bytes: 2248
import java.util.*;

public class Main {
    private static final int MOD = (int) (1e9+7);

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int h= scanner.nextInt();
        int w = scanner.nextInt();
        char[][] grid = new char[h][w];
        for(int i = 0 ; i < h ; ++i){
            grid[i] = scanner.next().toCharArray();
        }
        int[][] dp = new int[h+1][w+1];
        for(int i = h-1 ; i>=0 ; --i){
            for(int j = w-1 ; j>=0 ; --j){
                if(i==h-1&&j==w-1){
                    dp[i][j] =1;
                }else if(grid[i][j]=='#'){
                    dp[i][j] = 0;
                }else{
                    dp[i][j] = (dp[i+1][j]%MOD + dp[i][j+1]%MOD)%MOD;
                }
            }
        }
        System.out.println(dp[0][0]);
    }
}

Measured memory_bytes: 49076
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(c, b / a);

  return 0;
}

Measured memory_bytes: 3644
n, m = map(int, input().split())
now_step = 0
# count=1*a+2*bとなるような、0以上の全てのa,bについて、1をa個、2をb個並べる並べ方を返す.
# [1,(a+b)]からa個を選ぶ選び方と同じ
# ただし、これはnumber-1とnumber-2が分かっている場合は、number-1から1つ、あるいはnumber-2から二つ進む進み方の和で表せる
# よって、counte_steps(number) = count_steps(number-1) + count_steps(number-2)
# 初期値はcount_steps(1) = 1, count_steps(2) = 2,count_steps(0) = 1
checked_steps = {-1:0, 0:1, 1:1}
divide_num = 1000000007 

for i in range(2, n+1):
    checked_steps[i] = (checked_steps[i-1] + checked_steps[i-2]) % divide_num

all_count = 1
for i in range(m):
    a = int(input())
    if(a < now_step):
        continue
    all_count = (all_count * checked_steps[a - 1 - now_step]) % divide_num
    now_step = a + 1
all_count = (all_count * checked_steps[n - now_step]) % divide_num
print(all_count)

Measured memory_bytes: 17900
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
ll num = 0;//ルンルン数の個数
ll K;
long returnspecidicdigit(long a,long b){
//aの右からb番目を返す
 long a_default = a, b_default = b;
 while(b>0){
  a /= 10;
  if(a<0) {
   cout << "与えられた引数が不正です.a= " << a_default << " :b=" << b_default << endl;
   return 0;
  }
 }
 return a%=10;
}
ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
void kansu(ll nownum,ll nowketa){
  if(nowketa==GetDigit(nownum)){
    num++;
    if(num==K){
      cout << nownum << endl;
      return;
    }
    return;
  }
  ll n = returnspecidicdigit(nownum,0);
  for (ll i = -1; i < 2;i++){
    if(9<n+i||n+i<0)
      continue;
    kansu(nownum * 10 + n + i, nowketa);
  }
}

int main()
{
  cin >> K;
  for (int i = 1; i < 10; i++){
    num ++;
    if(num==K){
      cout << i << endl;
      return 0;
    }
  }
  for (int i = 2; i < 11;i++){
    for (int j = 1; j < 10; j++){
      kansu(j, i);
    }
  }
}

Measured memory_bytes: 256
(function(input) {
    var p = input.split('\n');
    var def = p.shift().split(' ').map(Number);
    var n = def[0];
    var q = def[1];
    var ps = p.slice(0, n);
    var queue = [];
    for (var i = 0; i < ps.length; i++) {
        var pss = ps[i].split(' ');
        queue.push({
            id: pss[0], time: Number(pss[1])
        })
    }
    var t = 0;
    while (queue.length > 0) {
        var pss = queue.shift();
        if (pss.time > q) {
            pss.time -= q;
            queue.push(pss);
            t += q;
            continue;
        }
        t += pss.time;
        console.log('%s %d', pss.id, t);
    }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 33428
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (lli i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define print(a) {\
    for (auto i : a) cout << i << ' ';\
    cout << '\n';\
}
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define pii pair<int,int> 
#define pll pair<lli,lli>
#define tiii tuple<int,int,int>
#define all(a) a.begin(), a.end()
#define X first
#define Y second
#define oset tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>
auto SEED = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(SEED);
const int mod = 998244353, x = 864197532, N = 100000;

int main () {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin >> x;
	fop (i,-300,300) {
		fop (j,-300,300) {
			if (i * i * i * i * i - j * j * j * j * j == x) {
				cout << i << ' ' << j << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3656
def __main__():
    n, a, b = list(map(int, input().split()))
    x = list(map(int, input().split()))

    cost = 0
    for i in range(len(x) - 1):
        cost_a = (x[i + 1] - x[i]) * a
        cost += min(cost_a, b)

    print(cost)

__main__()


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

ll INF = 1e+18;
int iINF = 1e9;

int 
main()
{
  int odd = 0;
  vector<pair<int, int>> arr;
  rep(i, 0, 3){
    int tmp; cin >> tmp;
    if(tmp % 2 == 1){
      ++odd;
      arr.push_back({tmp, 1});
    } else{
      arr.push_back({tmp, 0});
    }
  }

  int ans = 0;
  if(odd == 1){
    rep(i, 0, 3){
      if(arr[i].second == 0) arr[i].first += 1;
    }
    ++ans;
  } else if(odd == 2){
    rep(i, 0, 3){
      if(arr[i].second == 1) arr[i].first += 1;
    }
    ++ans;
  }

  int maxi = 0;
  rep(i, 0, 3){
    if(maxi < arr[i].first) maxi = arr[i].first;
  }

  int diff = 0;
  rep(i, 0, 3){
    diff += maxi - arr[i].first;
  }
  ans += diff / 2;
  
  cout << ans << endl;

}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
const ll mod=1e9+7;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a-=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
  }
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}

const int n_max=1e5+5;
int dp[n_max][2];//0 white  1 black
vector<int> g[n_max];

void dfs(int p, int v){
  dp[v][0]=1;
  dp[v][1]=1;
  for(auto i:g[v]){
    if(i==p) continue;
    else {
      dfs(v,i);
    }
    dp[v][0]=mu(dp[v][0],ad(dp[i][0],dp[i][1]));
    dp[v][1]=mu(dp[v][1],dp[i][0]);
  }
  //cout << v << " " << dp[v][0] << " " << dp[v][1] << endl;
}
int main(){
  
  int n;
  cin >> n;
  int x[n-1], y[n-1];
  rep(i,n-1){
    cin >> x[i] >> y[i];
    x[i]--;y[i]--;
    g[x[i]].pb(y[i]);
    g[y[i]].pb(x[i]);
  }
  dfs(-1,0);
  cout << ad(dp[0][0],dp[0][1]) << endl;
  


  
  
  
  return 0;

}


Measured memory_bytes: 14208
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.println((n - h + 1) * (n - w + 1));
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 22612
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(gcd(a,b)+" "+lcm(a,b));
		}
	}
	//最大公約数gcdを求める
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}

	//最小公倍数lcmを求める
	static long lcm (int a, int b) {
		int temp;
		long c = a;
		long d = b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (c*d)/b;
	}
}


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

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = n; i >= 0; --i) {
        if (s.substr(s.size() - i, i) == t.substr(0, i)) {
            cout << 2 * n - i;
            return 0;
        }            
    }
    return 0;
}

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


public class Main {

    String S;

    public void solve() {
        S = next();
        int count = 0;
        for(char c : S.toCharArray()){
            count += c == '1' ? 1 : 0;
        }

        out.println(count);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define ll long long

using namespace std;
int main()
{
   /* vector<int>v;
    vector<int>v1;
    vector<int>v2;
    set <char>s;
    int t,coun1=0,a,ans3,coun2=0,x,y=0,ans1=0,b,sum=0,flag=0,ans2;*/




    long long ai,t,n,a,b,c=0;
    string str;
    string str1;

    cin >> n;
    getchar();
    getline(cin,str);

    a=str.size();


    if( a > n)
    {


    str1= str.substr(0,n)+"...";


     cout << str1 << endl;


    }
    else
    {
        cout << str << endl;
    }



return 0;
}


Measured memory_bytes: 3608
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


class LazySegTree:
    data_unit = 0
    data_f = max
    operator_unit = 0
    
    @classmethod
    def operator_f(cls, x, y):
      return x + y
    
    @classmethod
    def operate(cls, x, y):
      return x + y
    
    def __init__(self, N):
        self.N = N
        self.H = (self.N - 1).bit_length()
        self.data = [self.data_unit] * (N + N)
        self.lazy = [self.operator_unit] * (N + N)

    def build(self, raw_data):
        data = self.data
        f = self.data_f
        N = self.N
        data[N:] = raw_data[:]
        for i in range(N - 1, 0, -1):
            data[i] = f(data[i << 1], data[i << 1 | 1])

    def reflect(self, k):
        x = self.lazy[k]
        if x == self.operator_unit:
            return self.data[k]
        else:
            return self.operate(self.data[k], x)

    def propagate(self, k):
        lazy = self.lazy
        if lazy[k] == self.operator_unit:
            return
        h = self.operator_f
        lazy[k << 1] = h(lazy[k << 1], lazy[k])
        lazy[k << 1 | 1] = h(lazy[k << 1 | 1], lazy[k])
        self.data[k] = self.reflect(k)
        self.lazy[k] = self.operator_unit

    def thrust(self, k):
        for i in range(self.H, 0, -1):
            self.propagate(k >> i)

    def recalc(self, k):
        data = self.data
        f = self.data_f
        while k > 1:
            k >>= 1
            data[k] = f(self.reflect(k << 1), self.reflect(k << 1 | 1))

    def update(self, L, R, x):
        lazy = self.lazy
        h = self.operator_f
        L0 = L = L + self.N
        R0 = R = R + self.N
        self.thrust(L0)
        self.thrust(R0 - 1)
        while L < R:
            if L & 1:
                lazy[L] = h(lazy[L], x)
                L += 1
            if R & 1:
                R -= 1
                lazy[R] = h(lazy[R], x)
            L >>= 1
            R >>= 1
        self.recalc(L0)
        self.recalc(R0 - 1)

    def set_val(self, i, x):
        i += self.N
        self.thrust(i)
        self.data[i] = x
        self.lazy[i] = self.operator_unit
        self.recalc(i)

    def fold(self, L, R):
        f = self.data_f
        L += self.N
        R += self.N
        self.thrust(L)
        self.thrust(R - 1)
        vl = self.data_unit
        vr = self.data_unit
        while L < R:
            if L & 1:
                vl = f(vl, self.reflect(L))
                L += 1
            if R & 1:
                R -= 1
                vr = f(self.reflect(R), vr)
            L >>= 1
            R >>= 1
        return f(vl, vr)

N, M = map(int, readline().split())
R_to_LA = [[] for _ in range(N + 1)]
m = map(int, read().split())
for L, R, A in zip(m, m, m):
    R_to_LA[R].append((L, A))

seg = LazySegTree(N+1)
 
for R in range(1, N + 1):
    x = seg.data[1]
    seg.update(R, R + 1, x)
    for L, A in R_to_LA[R]:
        seg.update(L, R + 1, A)
print(seg.fold(0, N+1))

Measured memory_bytes: 124692
x = [int(input()) for i in range(5)]
y = [0,0,0,0,0]
last = 0
i = 0
while i < 5:
    if 0 < x[i]%10 < x[last]%10:
        last = i
    if x[i]%10 != 0:
        y[i] = x[i]//10*10+ 10
    else:
        y[i] = x[i]//10*10
    i += 1

z = 0
for i in range(5):
    if i != last:
        z += y[i]
    else:
        z += x[i]

print(z)

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

int main() {
  int n;
  cin >> n;
  int ans = (1000 - n%1000)%1000;
  cout << ans << endl;
}

Measured memory_bytes: 3676
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long

int fa[100010],num[100010],n,m,cnt;
bool bo[100010],pd[100010];
ll ans;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline int find(int x)
{
	if (!fa[x]) return x;
	int hh=find(fa[x]);
	num[x]^=num[fa[x]];
	return fa[x]=hh;
}

int main()
{
	n=rd();m=rd();
	for (int i=1;i<=m;i++)
	{
		int x=rd(),y=rd();
		bo[x]=true;bo[y]=true;
		int f1=find(x),f2=find(y);
		if (f1<f2) { swap(f1,f2);swap(x,y); }
		if (f1==f2&&num[x]==num[y]) pd[f1]=1;
		if (f1==f2) continue;
		pd[f2]|=pd[f1];fa[f1]=f2;
		num[f1]=num[x]^num[y]^1;
	}
	for (int i=1;i<=n;i++) if (!bo[i]) cnt++;
	ans=(ll)cnt*(n-cnt)*2+(ll)cnt*cnt;
	cnt=0;
	for (int i=1;i<=n;i++) if (bo[i]&&!fa[i]) cnt++;
	ans+=(ll)cnt*cnt;
	cnt=0;
	for (int i=1;i<=n;i++) if (bo[i]&&!fa[i]&&!pd[i]) cnt++;
	ans+=(ll)cnt*cnt;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
///////////////////////////////////////////////

ll gcd (ll a, ll b) { return b?gcd(b,a%b): a;}

int main() {
    ll a, b, c, d; cin >> a >> b >> c >> d;

    ll e = c/gcd(c,d)*d;

    ll f = (a-1) - (a-1)/c - (a-1)/d + (a-1)/e;
    ll g = b - b/c - b/d + b/e;
    cout << g-f << endl;

    return 0;
}

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

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

typedef vector<int> vi;

vi ans;

void solve(vi const& a, vi const& k){
    int n=a.size();
    vi prev(1001);
    prev[0]=1;
    rep(i,n){
        vi cur(1001);
        rep(j,1001){
            rep(l,k[i]+1){
                int t=j+l*a[i];
                if(t<1001) cur[t]+=prev[j];
            }
        }
        swap(prev,cur);
    }
    swap(ans,prev);
}

int main(){
    int m;
    while(cin >> m,m){
        vi a(m), k(m);
        rep(i,m) cin >> a[i] >> k[i];
        solve(a,k);
        int g; cin >> g;
        rep(i,g){
            int t; cin>>t;
            cout << ans[t] << endl;
        }
    }
}

Measured memory_bytes: 1204
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String a = n();
		char[] s = a.toCharArray();
		char t = s[0];

		if (t <= 'Z') {
			out("A");
		} else {
			out("a");
		}

	}

	/*
	 * 以下メソッド集
	 */
	static int[] sort(int[] n) {
		Arrays.sort(n);
		return n;
	}

	static long[] sort(long[] n) {
		Arrays.sort(n);
		return n;
	}

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int account(String str) {
		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static int min(int a, int b) {
		return (int) Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 35772
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int W,Q;
int wall[110];
int check(int id,int w){
	for(int i =0;i < W;i++){
		if(wall[i]==-1&&i + w -1 < W){
			bool ok = true;
			for(int j =i;j < i+ w;j++){
				if(wall[j]==-1)continue;
				else {
					ok =false;
				}
			}
			if(ok){
				for(int j = i;j < i + w;j++){
					wall[j] = id;
				}
				return i;
			}
		}
	}
	return -2;
}
void wake(int id){
	for(int i =0;i < W;i++){
		if(wall[i]==id){
			wall[i] = -1;
		}
	}
}
void show(){
	for(int i =0;i < W;i++){
		cout <<wall[i]<<" ";
	}
	cout <<endl;
}
int main(){
	while(cin>>W>>Q,W||Q){
		memset(wall, -1, sizeof(wall));
		for(int i =0;i < Q;i++){
			char p;
			// show();
			// cout <<endl;
			cin>>p;
			if(p=='s'){
				int id,w;
				cin>>id>>w;
				int d = check(id, w);
				if(d==-2){
					cout <<"impossible"<<endl;
				}else{
					cout <<d<<endl;
				}
			}else if(p=='w'){
				int id;
				cin>>id;
				wake(id);
			}
		}
		cout <<"END"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160