akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 5;

class LinearSieve {
    public:
        vector<int> lp, pr;
        LinearSieve() {}
        LinearSieve(int n) {
            lp.resize(n + 1);
            init(n);
        }

        void init(int x) {
            FOR (i, 2, x + 1) {
                if (lp[i] == 0) {
                    lp[i] = i;
                    pr.push_back(i);
                }
                for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && (ll)i * pr[j] <= x; ++j) {
                    lp[i * pr[j]] = pr[j];
                }
            }
        }

        bool isPrime(int x) { return lp[x] == x; }

        vector<int> factorlist(int x) {
            vector<int> res;
            while (x != 1) {
                res.push_back(lp[x]);
                x /= lp[x];
            }

            return res;
        }

        vector<pair<int, int> > factorize(int x) {
            vector<int> p = factorlist(x);
            if (p.size() == 0) return {};
            vector<pair<int, int> > res(1, make_pair(p[0], 0));
            rep (i, p.size()) {
                if (res.back().first == p[i]) {
                    res.back().second++;
                } else {
                    res.emplace_back(p[i], 1);
                }
            }

            return res;
        }
};

template<typename T>
T modpower(T a, T n, T mod) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template<typename T>
T modinv(T a, T mod) {
    return modpower(a, mod - 2, mod);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    LinearSieve ls = LinearSieve(N);
    int n;
    cin >> n;
    ll res = 0;
    map<int, int> mp;
    vector<ll> a(n);
    
    rep (i, n) {
        cin >> a[i];
        auto v = ls.factorize(a[i]);
        rep (j, v.size()) {
            mp[v[j].first] = max(mp[v[j].first], v[j].second);
        }
    }
    ll l = 1;
    for (auto p : mp) {
        rep (i, p.second) {
            l *= p.first;
            l %= MOD;
        }
    }
    rep (i, n) {
        ll tmp = l * modinv(a[i], MOD);
        res += tmp;
        res %= MOD;
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 4984
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int n;
	char s[110], t[110];
	cin >> n;
	cin >> s >> t;
	int cnt = 0;
	rep(i, n) {
		if (strncmp(s + i, t, n - i) == 0) {
			cout << 2 * n - (n - i) << endl;
			return 0;
		}
	}
	cout << 2 * n << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    int[] x = new int[n];
    for (int i = 0; i < n; i++) {
        x[i] = sc.nextInt();
    }

    int[] y = new int[n];
    for (int i = 0; i < n; i++) {
        y[i] = sc.nextInt();
    }

    System.out.println(calc(1, x, y, n));
    System.out.println(calc(2, x, y, n));
    System.out.println(calc(3, x, y, n));
    System.out.println(calc(0, x, y, n));
  }

  public static double calc(int p, int[] x, int[] y, int n) {
      if (p == 0) {
        return IntStream.range(0, n)
            .mapToDouble(i -> Math.abs(x[i] - y[i]))
            .max()
            .getAsDouble();
      }

      double d = 0;
      for (int i = 0; i < n; i++) {
          d += Math.pow(Math.abs(x[i] - y[i]), p);
      }
      return Math.pow(d, (double)1 / p);
  }
}


Measured memory_bytes: 32596
#include<stdio.h>

int main(){
    int i,x;
	i = 1;
	while (1){
    scanf("%d",&x);
	if ( x == 0 ) {
		break;
	} else {	
        printf("Case %d: %d\n", i, x);
	    i++;
	}
	}
    return 0;
}


Measured memory_bytes: 2052
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NY = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int thousand = -1;
            int five_thousand = -1;
            int ten_thousand = -1;
            for(int i = 0; i<=NY[0];i++){
                for(int j = 0; j<=NY[0]-i;j++){
                    int sum = 1000*i+5000*j+10000*(NY[0]-j-i);
                    if(sum == NY[1] && (NY[0]-j-i)>=0){
                        thousand = i;
                        five_thousand = j;
                        ten_thousand = NY[0]-j-i;
                        break;
                    }
                }
            }
            Console.WriteLine("{0} {1} {2}",ten_thousand,five_thousand,thousand);
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 27512
n=int(input())
a=str(input())
b=str(input())
c=str(input())
ans=0
for i in range(n):
  if a[i]==b[i] and b[i]==c[i]:
    ans=ans
  elif a[i]!=b[i] and b[i]!=c[i] and c[i]!=a[i]:
    ans=ans+2
  else:
    ans=ans+1
print(ans)

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

int main() {

  string S;
  cin >> S;

  string res = "AC";

  if ((int) S.at(0) != 65) {
    res = "WA";
  }

  int countC = 0;
  int positionC = 0;

  for (int i = 2; i < S.size() - 1; i++) {

    int s = (int) S.at(i);

    if (s == 67) {
      countC++;
      positionC = i;
    }

  }

  if (countC != 1) {
    res = "WA";
  }

  for (int i = 1; i < S.size(); i++) {

    int s = (int) S.at(i);

    if (i != positionC) {
      if (s < 97 || 122 < s) {
        res = "WA";
        break;
      }
    }

  }

  cout << res << endl;

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
graph = [[] for j in range(n)]

for i in range(m):
    a,b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

used = [False]*n
used[0] = True

def DFS(v,used):
    if all(used):
        return 1
    ans = 0
    for i in graph[v]:
        if used[i]:
            continue
        used[i] = True
        ans += DFS(i,used)
        used[i] = False
    return ans
  
print(DFS(0,used))


Measured memory_bytes: 9144
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	static int N;
	public static void main(String[] args) {
		//0 48 || 1 49 || B 66
		String S=sc.next();
		StringBuffer str = new StringBuffer();

		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)==66) {
				if(str.length()!=0) {
					str.deleteCharAt(str.length()-1);
				}
			}else {
				str.append(S.charAt(i));
			}
		}
		p(str.toString());
		
	}
	static int a,b,c;
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21972
import java.util.Scanner;

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

            int count = 0;
            for (int i = 0; i < N; i++) {
                count += countAC(s[i]);
            }

            int countBA = 0;
            int countB = 0;
            int countA = 0;
            for (int i = 0; i < N; i++) {
                if (s[i].charAt(0) == 'B' && s[i].charAt(s[i].length() - 1) == 'A') {
                    countBA++;
                } else if (s[i].charAt(0) == 'B') {
                    countB++;
                } else if (s[i].charAt(s[i].length() - 1) == 'A') {
                    countA++;
                }
            }

            if (countBA - 1 >= 0) {
                count += countBA - 1;
                countBA = 1;
                if (countA > 0) {
                    count++;
                    countA--;
                }
                if (countB > 0) {
                    count++;
                    countB--;
                }
            }
            count += Math.min(countA, countB);

            System.out.println(count);
        }
    }

    private static int countAC(String s) {
        int count = 0;
        for (int i = 1; i < s.length(); i++) {
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'B') {
                count++;
            }
        }
        return count;
    }
}


Measured memory_bytes: 32000
#include <stdio.h>
 
int main(void)
{
  int a, b, c;
  int flag=0;
  scanf("%d",&a); scanf("%d",&b); scanf("%d",&c);
  if(a==b)
    flag+=1;
  if(b==c)
    flag+=1;
  if(c==a)
    flag+=1;
  if(flag==1)
    puts("Yes");
  else 
    puts("No");
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
using namespace std;
typedef long long ll;

ll keisan(bitset<10> bs, vector<int> s, ll d, int i, int n){
  ll sum;
  if(i == n){
    return 0;
  }
  sum = d * s.at(n - 1 - i);
  if(bs.test(i)){
    d = 1;
  }else{
    d *= 10;
  }
  return keisan(bs, s, d, i + 1, n) + sum;
}

int main(){
  string S;
  cin >> S;
  int n = S.size();

  vector<int> s(n);
  for(int i = 0; i < n; i++){
    s.at(i) = S.at(i) - '0';
  }

  ll result = 0;
  for(int bit = 0; bit < (1 << (n - 1)); bit++){
    bitset<10> bs(bit);
    ll d = 1;
    ll sum = keisan(bs, s, d, 0, n);
    result += sum;
  }
  cout << result << endl;

}

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

using namespace std;

int main(){
  int a;
  cin >> a;
  vector<bool> b(1e6,true);
  for(int i=2;i<=1e6;i++){
    if(b[i]){
      for(int j=2;j*i<1e6;j++){
        b[i*j]=false;
      }
    }
  }
  for(int i=a;i<1e6;i++){
    if(b[i]){
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 384
// atcoder/keyence2019/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    vec<lli> a(n), b(n);
    cin >> a >> b;
    const vec<lli> c = a;

    int cnt = 0;
    lli x = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] < b[i]) {
        x += b[i] - a[i];
        a[i] = b[i];
        ++cnt;
      }
    }

    vec<int> v;
    for (int i = 0; i < n; ++i) {
      v.push_back(i);
    }
    sort(v.begin(), v.end(), [&] (int i, int j) { return b[i] - a[i] < b[j] - a[j]; });

    each (i, v) {
      lli y = min(a[i] - b[i], x);
      x -= y;
      a[i] += y;
      if (y) ++cnt;
    }
    cout << (x ? -1 : cnt) << endl;
  }

  return 0;
}


Measured memory_bytes: 3324
def norm_of(n, k)
    ret = 0
    while n * (2 ** ret) < k
        ret += 1
    end
    ret
end

n, k = gets.split.map(&:to_i)

norms = [nil] * (n + 1)

(1..n).each{|index|
    if norms[index] == nil
        val = norm_of(index, k)
        count = 0
        while index * (2 ** count) <= n
            norms[index * (2 ** count)] = val - count
            count += 1
        end
    end
}

puts norms[1..-1].map{|it| it < 1 ? 1.0 : 1.0 / (2 ** it)}.inject(:+) / n


Measured memory_bytes: 3324
#include<iostream>
using namespace std;
int main(){
	int H, W,i,j,k;
	for (i = 0; i < 1000; i++){
		cin >> H >> W;
		if (W == 0 && H == 0){
			break; 
		}else{
			for (j = 0; j < H; j++){
				for (k = 0; k < W; k++){
					cout << "#";
				}
				cout << endl;
			}
			cout << endl;

		}
	}
	return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);

int main()
{
	ll a,b;
	cin >> a >> b;
	ll c=a*b;
	if(c%2LL==0LL)
	{
		cout << "Even\n";
	}
	else
	{
		cout << "Odd\n";
	}
	return 0;
}


Measured memory_bytes: 256
n=int(input())
mansion=[[[0]*10 for i in range(3)] for j in range(4)]
for i in range(n):
    b, f, r, v=(int(x) for x in input().split())
    b=b-1
    f=f-1
    r=r-1
    mansion[b][f][r]=mansion[b][f][r]+v
for i in range(4):
    for j in range(3):
        for k in range(10):
            if(k!=9):
                print(" "+str(mansion[i][j][k]), end="")
            else:
                print(" "+str(mansion[i][j][k]))
    if(i!=3):
        print("####################")


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

int main() {
int N;
	cin >> N;
	vector<int> A(N);
	for(auto &x: A) cin >> x;

	long long s = 0;
	for(auto x: A) s += x;

	long long a = s;
	for(int i = 1; i < N; i+=2) a -= 2 * A[i];
	cout << a << " ";
	for(int i = 0; i < N - 1; i++, cout << " ") {
		long long b = 2 * A[i] - a;
		cout << b;
		a = b;
	}
	cout << endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main()
{
    ll a;
    double b;
    cin >> a >> b;
    ll b2 = b * 100 + 0.1;
    ll ans = a * b2;
    cout << ans / 100 << endl;
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	string s;
	int a;
	cin >> s >> a;
	for (int i = 0; i < s.size(); i += a) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using int64=long long;
const int INF=1145141919,MOD=1e9+7;
const int64 LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

vector<int> edge[200010];
pair<int,int> dfs(int from,int par){
    pair<int,int> ret={-1,from};
    for(int to:edge[from]){
        if(to==par) continue;
        pair<int,int> tmp=dfs(to,from);
        ret=max(ret,tmp);
    }
    ret.first++;
    return ret;
}

int main(){
    int n; cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b; cin>>a>>b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    auto d1=dfs(1,0);
    auto d2=dfs(d1.second,0);
    if(d2.first%3!=1) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 26752
#include<bits/stdc++.h>
using namespace std;
int dp[100000],a[100000],i,j,c,n;
int f(int i)
{
	if(dp[i]!=-1)
	return dp[i];
	
	if(i+1<n && i+2<n)
	c=min(f(i+1)+abs(a[i+1]-a[i]),f(i+2)+abs(a[i+2]-a[i]));
	
	else if(i+1<n)
	c=f(i+1)+abs(a[i+1]-a[i]);
	else
	return 0;
	return dp[i]=c;
}
int main()
{cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
memset(dp,-1,sizeof(dp));
cout<<f(0);
return 0;
}


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

int main() {
    string x;
    int sum;
    while (true) {
        cin >> x;
        if (x == "0") { break; }

        sum = 0;
        for (int i = 0; i < x.size(); i++) {
            sum += x.at(i) - '0';
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>



using namespace std;

const int N = 1000;
int c[N+1][N+1];
    
int lcs(string X, string Y){
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for (int i=1;i<=m;i++){
        c[i][0] = 0;
    }
    for (int j=1;j<=n;j++){
        c[0][j] = 0;
    }
    for (int i=1;i<=m;i++){
        for (int j=1;j<=n;j++){
            if(X[i] == Y[j]){
                c[i][j] = c[i-1][j-1] + 1;
            }else{
                c[i][j] = max(c[i][j-1],c[i-1][j]);
            }
            maxl = max(maxl,c[i][j]);
        }
    }
    return maxl;
}

int main() {
    

    string s1,s2;
    int p;
    cin >> p;
    for (int i= 0;i<p;i++){
        cin >> s1 >> s2;
        cout << lcs(s1,s2) << endl;
    }
    return 0;


}


Measured memory_bytes: 7128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1e9 + 7;

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

    int N;
    string S;
    cin >> N >> S;

    REP(i, S.length()) {
        char tmp = S[i];
        S[i] = (int(tmp - 'A') + N) % 26 + 'A';
    }
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import(
	"fmt"
	"sort"
)

func main() {
	nums := make([]int,4)
	for i,_ := range nums{
		fmt.Scan(&nums[i])
	}
	sort.Ints(nums)
	
	if nums[0] == 1 && nums[1] == 4 && nums[2] == 7 && nums[3] == 9 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

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

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a[3];
	for (int i = 0; i < 3; ++i)
	{
		cin>>a[i];
	}
	cout<<a[2]<<" "<<a[0]<<" "<<a[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    fun equalBySLength(s: List<Char>, t: List<Char>): Boolean {
        for (i in s.indices) {
            if (s[i] != t[i]) {
                return false
            }
        }
        return true
    }

    val s = br.readLine()!!.toCharArray().sorted()
    val t = br.readLine()!!.toCharArray().sortedDescending()
    if (s.size < t.size && equalBySLength(s, t)) {
        out.println("Yes")
        return
    }

    for (i in 0 until min(s.size, t.size)) {
        if (s[i] != t[i] && s[i] < t[i]) {
            out.println("Yes")
            return
        }
    }

    out.println("No")
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 39156
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

typedef struct City{
    int x;
    int y;
}City;

double dist(City c1, City c2){
    double dist;
    dist = sqrt((c2.x - c1.x)* (c2.x - c1.x) + (c2.y - c1.y) * (c2.y - c1.y));
    return(dist);
}

int factorial(int n){
    int sum=1;
    for (int i=1;i<=n;i++){
        sum *= i;
    }
    return(sum);
}

int main(){
    int N;
    cin >> N;
    vector<City> list(N);
    vector<int> perm(N);

    for(int i=0;i<N;i++){
        perm.at(i) = i;
    }

    for(int i=0;i<N;i++){
        cin >> list.at(i).x;
        cin >> list.at(i).y;
    }

    double dist_sum = 0;
    double dist_sum_ave = 0;

    do{
        for(int i=0;i<N-1;i++){
            dist_sum += dist(list.at(perm.at(i)),list.at(perm.at(i+1)));
        }
        dist_sum_ave += dist_sum;
        dist_sum = 0;
    }while(next_permutation(perm.begin(),perm.end()));

    cout << setprecision(12) << dist_sum_ave / factorial(N) << endl;

    return(0);
}

Measured memory_bytes: 256
n = int(input())
a_list = [int(input()) for i in range(n)]
#print(a_list)
sorted_a = sorted(a_list)
#print(sorted_a)
max_a = sorted_a[-1]
semi_max_a = sorted_a[-2]

for a in a_list:
    if a == max_a:
        print(semi_max_a)
    else:
        print(max_a)

Measured memory_bytes: 14112
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> l(n),r(n);
    int cur=1;
    for(int i=0;i<n;i++){
        if(s[i]=='x') continue;
        l[i] = cur;
        i += c;
        cur++;
    }
    cur = k;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='x') continue;
        r[i] = cur;
        i -= c;
        cur--;
    }

    vector<int> ans(n);
    for(int i=0;i<n;i++){
        if(l[i]!=0 && l[i]==r[i]){
            ans[i] = i+1;
        }
    }

    for(int i=0;i<n;i++){
        if(!ans[i]) continue;
        cout << ans[i] << endl;
    }
}

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

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

    rep(i, ss.size())
    {
        if (i % 2 == 0)
        {
            cout << ss.at(i);
        }
    }
    cout << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,x;
  while(cin>>n>>x,n+x){
    int ans=-1;
    bool dp[x+1000]={};
    vector<int>v(n);
    for(int i=0;i<n;i++){
      cin>>v[i];
      if(v[i]<=x)
      dp[v[i]]=true;
    }
    sort(v.begin(),v.end());
    for(int i=1;i<x;i++){
      for(int j=0;j<v.size();j++){
	if(dp[i]==true){
	  if(i+v[j]>x){
	    v.pop_back();
	    j--;
	  }else{
	    dp[i+v[j]]=true;
	  }
	}
      }
    }
    int num=x;
    if(num%2==0)num--;
    for(int i=num;i>1;i-=2){
      bool flag=true;
      if(dp[i]==true){
	for(int j=2;j<=sqrt(i);j++){
	  if(i%j==0){
	    flag=false;
	    break;
	  }
	}
	if(flag){
	  ans=i;break;
	}
      }
    }
    if(ans==-1&&dp[2]==false&&dp[1]==false)
      cout<<"NA"<<endl;
    else if(ans!=-1)
      cout<<ans<<endl;
    else{
      if(dp[2]==true)
      cout<<2<<endl;
      else
	cout<<1<<endl;
    }
  }
  return 0;
}

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

using namespace std;

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

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

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

    vector<int> p(n);
    for(auto &x:p)
        cin >> x;
    
    sort(p.begin(),p.end());

    ll sum=0;
    for(int i=0;i<k;i++){
        sum+=p.at(i);
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll a[n];
    ll cnt[60];
    fill(cnt,cnt+60,0);
    ll sum=0;
    ll b[n];
    rep(i,0,n){
        cin>>a[i];
        
        b[i]=a[i]%mod;
        sum+=b[i];
        sum%=mod;
        ll u=a[i];
        rep(j,0,60){
            if(u%2)cnt[j]++;
            u/=2;
        }
    }
    
    ll ans=0;
    rep(i,0,n){
        ll u=a[i];
        sum-=b[i];
        sum+=mod;
        sum%=mod;
        ll summ=sum;
        rep(j,0,60){
            if(u%2){
                cnt[j]--;
                ll y=beki(2,j,mod);
                y%=mod;
                summ+=(n-i-1-cnt[j])*y;
                summ%=mod;
                summ-=(cnt[j]*y)%mod;
                summ+=mod;
                summ%=mod;
            }
            u/=2;
        }
        ans+=summ;
        ans%=mod;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4992
check[30], c, n, a, xor_sum, ans, bit, i;
main() {
  while (1) {
    c = getchar_unlocked();
    if (48 <= c && c <= 57)
      n = n * 10 + c - 48;
    else
      break;
  }

  for (i = 0; i < n; i++) {
    a = 0;
    while (1) {
      c = getchar_unlocked();
      if (48 <= c && c <= 57)
        a = a * 10 + c - 48;
      else
        break;
    }
    xor_sum ^= a;
    a = a ^ (a - 1);

    check[__builtin_popcount(a) - 1] = 1;
  }

  for (bit = 29; bit >= 0; bit--) {
    if (check[bit] && ((1 << bit) & xor_sum)) {
      xor_sum ^= (1 << (bit + 1)) - 1;
      ans += 1;
    }
  }

  printf("%d\n", xor_sum ? -1 : ans);
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string[] input = Console.ReadLine().Split();
      int x = int.Parse(input[0]);
      int a = int.Parse(input[1]);
      int b = int.Parse(input[2]);
      
      int t = b - a;
      if (a>=b){
        Console.WriteLine("delicious");
      }
      else if (x>=t){
        Console.WriteLine("safe");
      }
      else{
        Console.WriteLine("dangerous");
      }
    }
}


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

int main() {
    int m, f, r;

    cin >> m >> f >> r;
    while(m!=-1||f!=-1||r!=-1){
        if(m==-1||f==-1){
            cout << "F" << endl;
        }else if(m+f >=80){
            cout << "A" << endl;
        }else if(m+f < 80 && m+f >=65){
            cout << "B" << endl;
        }else if(m+f < 65 && m+f >=50){
            cout << "C" << endl;
        }else if(m+f < 50 && m+f >=30){
            if(r >=50){
                cout << "C" << endl;
            }else{
                cout << "D" << endl;
            }

        }else{
            cout << "F" << endl;
        }
        cin >> m >> f >> r;
    }

    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int a, b;
int main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> a >> b;
	if ((a+b) % 2 == 0) cout << (a+b)/2 << endl;
	else cout << "IMPOSSIBLE\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N, T, c, c_time[1024] = {0}, ans = 0;
    
    cin >> N >> T;
    for (int i = 0; i < N; i++) {
        cin >> c;
        cin >> c_time[c];
    }

    for (int i = 0; i < 1024; i++) {
        if (c_time[i] != 0 && c_time[i] <= T) {
            ans = i;
            break;
        }
    }
    
    if (ans != 0) {
        cout << ans << endl;
    } else {
        cout << "TLE" << endl;
    }
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

type AB struct {
	A int
	B int
}

type ABS []AB

func (abs ABS) Len() int {
	return len(abs)
}

func (abs ABS) Swap(i, j int) {
	abs[i], abs[j] = abs[j], abs[i]
}

func (abs ABS) Less(i, j int) bool {
	return abs[i].B < abs[j].B
}

func main() {
	sc.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()
	slice := make([]AB, m)
	for i := 0; i < m; i++ {
		slice[i] = AB{A: nextInt(), B: nextInt()}
	}
	n++

	sort.Sort(ABS(slice))

	res := 0
	end := 0 // 最後に選んだ島の位置
	for i := 0; i < m; i++ {
		if slice[i].A >= end {
			end = slice[i].B
			res++
		}
	}

	fmt.Println(res)
}


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

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }

  return 0;
}

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

const int INF = 1 << 30;
typedef long long ll;

int main(void){
  int m[5], n[5];
  while(cin >> m[0] >> n[0] && (m[0] || n[0])){
    for(int i = 1; i < 5; i++) cin >> m[i] >> n[i];
    int maxi = 0, sn;
    for(int i = 0; i < 5; i++){
      if(m[i] + n[i] > maxi){
        maxi = m[i] + n[i];
        sn = i;
      }
    }
    cout << (char)('A' + sn) << " " << maxi << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    int ans=0;
    while(n) {
        n/=k;
        ans++;
    }
    cout<<ans<<endl;
}

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

int main() {
    long long n, m; cin >> n >> m;
    if (n > m) swap(n, m);
    long long ans;
    if (n == 1 && m == 1) {
        ans = 1;
    } else if (n == 1) {
        ans = m - 2;
    } else {
        ans = (n - 2) * (m - 2);
    }
    cout << ans << endl;
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> S(H+2, vector<char>(W+2, '.'));
    for (int i = 1; i < H+1; i++) {
        for (int j = 1; j < W+1; j++) {
            cin >> S[i][j];
        }
    }
    for (int i = 1; i < H+1; i++) {
        for (int j = 1; j < W+1; j++) {
            if (S[i][j] == '#')
                cout << S[i][j];
            else {
                int cnt = 0;
                for (int k = -1; k <= 1; k++) {
                    for (int l = -1; l <= 1; l++) {
                        if (S[i+k][j+l] == '#')
                            cnt++;
                    }
                }
                cout << cnt;
            }
        }
        cout << endl;
    }
}

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

int main()
{
    int64_t a, b, c, d;
    cin>>a>>b>>c>>d;
    int64_t ans;
    
    bool p = (a >= 0), q = (b >= 0), r = (c >= 0), s = (d >= 0);
    if ((p && q && r && s) || (!p && q && r && s)||(p && q && !r && s))
    {
        ans = b * d;
    }
    else if (!p && !q && r && s)
    {
        ans = b * c;
    }
    else if (p && q && !r && !s)
    {
        ans=a*d;
    }
    else if (!p && q && !r && s)
    {
        if ((a * c) > (b * d))
        {
            ans = a * c;
        }
        else
        {
            ans = b * d;
        }
    }
    else if ((!p && !q && !r && s) || (!p && !q && !r && !s)||(!p && q && !r && !s))
    {
        ans = a * c;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
import math
n,l=map(int,input().split())
list0=[]
su,mi=0,9999
for i in range(1,n+1):
    list0=list0+[l+i-1]
    su+=(l+i-1)
    if abs(l+i-1)<abs(mi):mi=l+i-1
print(su-mi)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
ll val(ll a,ll b,ll mid){
    ll res = (a*mid)/b - a*(mid/b);
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,n;
    cin>>a>>b>>n;
    ll go = min(b-1,n);
    cout << val(a,b,go);
    
  

    return 0;
}

    


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
using Int = long long;
using namespace std;
int main()
{
    int H, W; cin >> H >> W;
    string s;
    while (cin >> s) {
        cout << s << '\n' << s << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main(void) {
	string s; cin >> s;
	bool f = false;
	for(auto u : s) if(u == '9') f = true;
	if(f) printf("Yes\n");else printf("No\n");

	return 0;
}

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

class Program
{
    void Run()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        var tasks = new List<Tuple<long, long>>();
        for (int i = 0; i < n; i++)
        {
            long a = sc.NextLong();
            long b = sc.NextLong();
            tasks.Add(Tuple.Create(a, b));
        }
        var sorted = tasks.OrderBy(p => p.Item2).ToList();
        long time = 0;
        for (int i = 0; i < n; i++)
        {
            if (time + sorted[i].Item1 > sorted[i].Item2)
            {
                Console.WriteLine("No");
                return;
            }
            time += sorted[i].Item1;
        }
        Console.WriteLine("Yes");
    }

    static long Count(long a, long b)
    {
        return a / b;
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }

    static long Lcm(long a, long b)
    {
        long d = Gcd(a, b);
        return a * b / d;
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 33320
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int maxn = 1e5+7;
int T[maxn];
int main(){
    int n,m,isok;
    vector<int> A;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>m;
        T[m]++;
    }
    long long res = 1;
    if(n%2==1){
        if(T[0]!=1){
            cout<<0;
            return 0;
        }
        for(int i=2;i<n;i+=2){
            if(T[i]!=2){
                cout<<0;
                return 0;
            }
            res = (res*2)%mod;
        }
        cout<<res;
        return 0;
    }
    for(int i=1;i<n;i+=2){
        if(T[i]!=2){
            cout<<0;
            return 0;
        }
        res = (res*2)%mod;
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n, ans;
vector<Int> a, b;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	a.resize(n);
	b.resize(n);
	for(auto &i:a) cin >> i;
	for(auto &i:b) cin >> i;
	using P = pair<Int, Int>;
	priority_queue<P> pq;
	for(size_t i=0; i<a.size(); ++i)
		if(b[i] > a[i])
			pq.push(P(b[i], i));
	while(!pq.empty()){
		P p = pq.top();
		pq.pop();
		Int d = b[(p.second-1+n)%n] + b[(p.second+1)%n];
		Int t = (b[p.second] - 1) / d;
		t = min(t, (b[p.second] - a[p.second]) / d);
		b[p.second] -= t * d;
		ans += t;
//		for(size_t i=0; i<b.size(); ++i)
//			cout << b[i] << " \n"[i+1==b.size()];
		if(t == 0){
			ans = -1;
			break;
		}else if(b[p.second] > a[p.second]){
			pq.push(P(b[p.second], p.second));
		}
	}
	cout << ans << "\n";
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> town(M*2);
  for (int i=0; i<M*2; i++){
    cin >> town.at(i);
  }
  
  vector<int> count(N);
  
  for(int j=0; j<N; j++) {
  
    for(int i=0; i<M*2; i++) {
      
      if (town.at(i) == j+1){
        count.at(j) += 1;
        
      }
      
    }
    
    cout << count.at(j) << endl;
    
  }
   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

vector<bool> seen;
int cnt;
void dfs(const Graph &G, int v) {
  seen[v] = true;

  for (auto next_v : G[v]) {
      if (seen[next_v]) continue;
      dfs(G, next_v);
  }
  cnt++;
}

int main()
{
    int N,M;
    cin >> N >> M;
    Graph G(N);
    REP(i,M){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    seen.assign(N, false);
    int ans = 0;
    REP(i,N){
        if(seen[i])continue;
        cnt = 0;
        dfs(G, i);
        chmax(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 23512
#include <iostream>


/* 値を入れ替える関数 */
void swap (int *x, int *y) {
    int temp;    // 値を一時保存する変数

    temp = *x;
    *x = *y;
    *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
    int i, j, pivot;
    i = left;
    j = right + 1;
    pivot = left;   // 先頭要素をpivotとする

    do {
        do { i++; } while (array[i] < array[pivot]);
        do { j--; } while (array[pivot] < array[j]);
        // pivotより小さいものを左へ、大きいものを右へ
        if (i < j) { swap(&array[i], &array[j]); }
    } while (i < j);

    swap(&array[pivot], &array[j]);   //pivotを更新

    return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
    int pivot;

    if (left < right) {
        pivot = partition(array, left, right);
        quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
        quick_sort(array, pivot+1, right);
    }
}


int main() {

    int n, count = 0, s;

    std::cin >> n;

    int d[n];

    for (int i = 0; i < n; i++) {
        std::cin >> d[i];
    }

    quick_sort(d, 0, n-1);

    if(n%2 == 0){
        s = n/2 - 1;
    }else{
        s = n/2;
    }

    std::cout << d[s+1] - d[s];


    return 0;
}

Measured memory_bytes: 640
n,m = map(int,input().split())
# A_2=0
# B_2=0
list_A=[]
list_B=[]
sum_num=0
for i in range(n):
    A,B = map(int,input().split())
    list_A.append(A)
    list_B.append(B)


list_AB = []
for i in range(n):
    list_AB.append( (list_A[i], list_B[i]))

list_AB.sort()
list_A , list_B = zip(*list_AB)
# list_A.sort()
# list_B.sort()
# print(list_A)
# print(list_B)


m_1=m
for i in range(n):
    m_2=m_1
    m_1=m_1-int(list_B[i])
    if m_1<0:
        sum_num=sum_num + int(list_A[i])*m_2
    else:
        sum_num=sum_num +int(list_A[i])*int(list_B[i])
    #print(sum_num)
    #print("m_1",m_1,"m_2",m_2)
    if m_1<0:
        break

print(sum_num)


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

int main() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') cout << 9;
        else if (s[i] == '9') cout << 1;
        else cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256