akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define Int long long
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  int ans = min(B,D)-max(A,C);
  if(ans < 0) cout << 0 << endl;
  else cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long n,d;
    cin>>n>>d;
    long long x[n],y[n];
    for (int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    int ans=0;
    for(int u=0;u<n;u++){
        if(d*d>=x[u]*x[u]+y[u]*y[u])  ans++;
    }
    cout<<ans<<endl;
}


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

int main()
{
	int tt=1;
	//cin>>tt;
	while(tt--)
	{
		int n;
		cin>>n;

		set<int> s;

		for (int i = 0; i < n; ++i)
		{
			int x;
			cin>>x;
			s.insert(x);
		}

		if(s.size() == n)
			cout<<"YES";
		else
			cout<<"NO";
	}
	return 0;
}

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

vector<long> w;
vector<long long> v;
vector<vector<long long>> dp;

int main(void){
  int N;
  long W;
  cin >> N >> W;

  w = vector<long>(N);
  v = vector<long long>(N);
  dp = vector<vector<long long>>(N+20,vector<long long>(W+20));

  for(int i=0;i<N;i++){
    cin >> w[i] >> v[i];
  }

  for(int i=0;i<N;i++){
    for(long long j=0;j<=W;j++){
      dp[i][j] = 0;
    }
  }

  for(int i=0;i<N;i++){
    for(long wi=0;wi<=W;wi++){
      if(wi >= w[i]){
        dp[i+1][wi] = max(dp[i][wi],dp[i][wi-w[i]] + v[i]);
      }else{
        dp[i+1][wi] = dp[i][wi];
      }
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 95104
let () =
  let open Queue in
  let (n:int),(quantum:int) = Scanf.scanf "%d %d\n" (fun a b -> a,b) in
  let (q:(string * int) t) = create () in
  for i=1 to n do
    add (Scanf.scanf "%s %d\n" (fun a b -> a,b)) q
  done;
  let (sum:int ref) = ref 0 in
  while not (is_empty q) do
    match take q with
      p,t when t <= quantum ->
      sum := !sum + t;
      Printf.printf "%s %d\n" p !sum
    | p,t ->
      add (p,t-quantum) q;
      sum := !sum+quantum
  done

Measured memory_bytes: 12684
//たくさんの数式

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    string s;cin>>s;
    int n=s.size()-1,ans=0;
    rep(bit,0,(1<<n)){
        vector<int>a;
        string t="";
        rep(i,0,n){
            t.pb(s[i]);
            if(bit&(1<<i)){
                a.pb(stoll(t));
                t.clear();
            }
        }
        t.pb(s[n]);
        a.pb(stoll(t));
        ans+=accumulate(range(a),0LL);
        a.clear();
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3572
import java.util.*;

// UVa 11504

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int l = in.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = in.next();
		}
		Arrays.sort(s);
		
		for (int i = 0; i < n; i++) {
			System.out.printf("%s", s[i]);
		}
	}
}

Measured memory_bytes: 23592
#include <stdio.h>
#include <string.h>
#include <ctype.h>



int main(int argc, const char * argv[]) {
    // insert code here...
    
    while (1) {
        char yama[201];
        scanf("%s",yama);
        if(yama[0] == '-'){
            break;
        }

        int m;
        scanf("%d",&m);
        
        int i;
        for(i=0;i<m;i++){
            int h;
            scanf("%d",&h);
            
            char head[201] = {},tail[201] = {};
            strncpy(tail, yama, h);
            strcpy(head, yama+h);
            
            char *sum = strcat(head, tail);
            strcpy(yama, sum);
            
        }
        
        printf("%s\n",yama);
        
    }

    
    return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
int main(void)
{
	int x,a,b,i;
	scanf("%d %d %d",&x,&a,&b);
	x=x-a;
	while(x>=b){
		x=x-b;
	}
	printf("%d\n",x);
	return 0;
}	
	

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		String S = sc.next();
		Matcher matcher = Pattern.compile("ABC").matcher(S);
		int count = 0;
		while (matcher.find()){
			count++;
		}

		System.out.println(count);
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 23124
from math import ceil
K = int(input())
A = list(map(int, input().split()))
L, R = 2, 2

for n in A[::-1]:
    L = ceil(L / n) * n
    R = (R // n) * n + n - 1
    if L > R:
        print(-1)
        exit()

print(L, R)


Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
int comp(const void* a, const void* b)
{ return *(int*)a > *(int*)b ; }

int findNumberOfTriangles(int arr[], int n)
{
    qsort(arr, n, sizeof( arr[0] ), comp);

    int count = 0;
    for (int i = 0; i < n - 2; ++i)
    {
        int k = i + 2;
        for (int j = i + 1; j < n; ++j)
        {
            while (k < n && arr[i] + arr[j] > arr[k])
                ++k;
            if(k > j)
                count += k - j - 1;
        }
    }
    return count;
}
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for (int i = 0; i < n; ++i) {
        cin>>arr[i];
    }
    int size = sizeof( arr ) / sizeof( arr[0] );
    cout<<findNumberOfTriangles( arr, size );
    return 0;
}

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

int main() {
	ll a,b,c; cin >> a >> b >> c;
	if(a%2==0||b%2==0||c%2==0) {
		cout << 0 << endl;
		return 0;
	}
	ll A=b*c;
	ll B=a*c;
	ll C=a*b;
	cout << min(A,min(B,C)) << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
 
using namespace std;
 
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
 
const int MAXN = 500100, MAXK = 30;
const ll MOD = 998244353;
const int INF = 1e8;
const ld PI = asin(1) * 2;
 
void setIO () {
    FAST_IO;
}
 
void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}
 
int n;
string s;
int a[MAXN];
 
ll pref[MAXN][3];
 
int main() {
	setIO();
 
    cin >> n >> s;
    ll ans = 0;
    FOR(i, 1, n) {
        if (s[i-1] == 'R') a[i] = 0;
        else if (s[i-1] == 'G') a[i] = 1;
        else a[i] = 2;
    }
 
    FOR(i, 1, n) {
        FOR(k, 0, 2) pref[i][k] = pref[i-1][k];
        pref[i][a[i]]++;
    }
 
    FOR(i, 1, n) FOR(k, i+2, n) {
        if (a[i] == a[k]) continue;
        int j = 0;
        while (a[i] == j || a[k] == j) {j++;}
        ans += pref[k-1][j]-pref[i][j];
        int mid = (k+i)/2;
        if ((k+i)%2 == 1) continue;
        if (a[mid] == j) ans--;
    }
 
    cout << ans;
 
	return 0;
}
 

Measured memory_bytes: 3664
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <limits>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
// For debug
#ifdef _DEBUG
#define DD(x) cerr << #x << ":" << x << endl;
#define DDA(ary) \
cerr << #ary << ":" << endl;\
for (auto v : ary) { cerr << v << ","; }\
cerr << endl;
#else
#define DD(x)
#define DDA(ary)
#endif

using IntType = long long;
const int MAX_N = 1005;
int n;
int main() {
	cin >> n;
	IntType tn, an;
	tn = an = 1;
	REP(i, n) {
		DD(tn);
		DD(an);
		IntType t, a;
		cin >> t >> a;
		IntType l = 0;
		IntType tr = (tn / t) + 1;
		IntType ar = (an / a) + 1;
		IntType r = max(tr, ar);
		while (r - l > 1) {
			IntType m = (r + l) / 2;
			if (t * m >= tn && a * m >= an) {
				r = m;
			}
			else {
				l = m;
			}
		}
		DD(r);
		tn = t * r;
		an = a * r;
	}
	DD(tn);
	DD(an);

	cout << tn + an << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		// Problem C
		int n = sc.nextInt();
		TreeSet<Integer> s = new TreeSet<Integer>();
		int first = 0;
		int second = 0;
		for(int i=0;i<n;i++) {
			int tmp = sc.nextInt();
			if (s.contains(tmp)) {
				if(tmp >= first) {
					second = first;
					first = tmp;
					s.remove(tmp);
				} else if (tmp >= second) {
					second = tmp;
					s.remove(tmp);
				}
			} else {
				s.add(tmp);
			}
		}
		System.out.println((long)first * (long)second);
	}

}


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

int main(void){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(), h.end());
  ll ans = 0; 
  rep(i,n-k) ans += h[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4016
from itertools import product


def main():
    nn = n = input()
    if n == 1:
        print(0)
        return
    factors = {}
    p = 2
    while n % p == 0:
        factors[p] = factors.get(p, 0) + 1
        n //= p
    p = 3
    while nn >= p * p:
        while n % p == 0:
            factors[p] = factors.get(p, 0) + 1
            n //= p
        p += 2
    if n > 1:
        factors[n] = factors.get(n, 0) + 1
    
    s = []
    for f in factors:
        n = factors[f]
        s.append([(f ** i, f ** (n - i)) for i in xrange(n + 1)])

    best = float('inf')
    for case in product(*s):
        a = b = 1
        for aa, bb in case:
            a *= aa
            b *= bb
        best = min(best, a + b - 2)
    print(best)


main()


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    map<int, int> u;
    for (int i = 0; i < n; i++) u[a[i]]++;
    if (u.size() > 3) {
        cout << "No" << endl;
        return 0;
    }
    if (n == 3) {
        int d = 0;
        for (auto x: a) {
            d ^= x;
        }
        if (d == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }
    if (u.size() == 1 && a[0] != 0) {
        cout << "No" << endl;
        return 0;
    }
    if (u.size() == 2) {
        if (u[0] * 3 != n) {
            cout << "No" << endl;
            return 0;
        }
    }
    if (u.size() == 3) {
        int d = 0;
        for (auto it: u) {
            d ^= it.first;
            if (it.second * 3 != n) {
                cout << "No" << endl;
                return 0;
            }
        }
        if (d != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

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

int main() {
	string s; cin >> s;
	vector<int>a(26);
	rep(i, s.size()) {
		a[s[i] - 'a']++;
	}
	int ans = INF;
	rep(i, a.size()) {
		if (a[i] == 0) {
			ans = i;
			break;
		}
	}
	if (ans != INF) {
		cout << char('a' + ans) << "\n";
	}
	else cout << "None" << "\n";
	return 0;
}

Measured memory_bytes: 512
x,y = map(int,input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if x in a and y in a:
    print("Yes")
    exit()
if x in b and y in b:
    print("Yes")
    exit()
if x in c and y in c:
    print("Yes")
    exit()
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>

using namespace std;

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

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

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

const int PI = acos(-1);
const int INF = numeric_limits<int>::infinity() / 2;
const ll INFLL = numeric_limits<ll>::infinity() / 2;

bool ok(char a, char b) {
  return (a == 'o' || a == '#') && (b == 'o' || b == '#');
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  char fd[50][50];
  cin >> h >> w;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++)
      cin >> fd[i][j];
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w - 1; j++) {
      if (!ok(fd[i][j], fd[i][j+1])) continue;
      fd[i][j] = fd[i][j+1] = 'o';
    }
  }

  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h - 1; j++) {
      if (!ok(fd[j][i], fd[j+1][i])) continue;
      fd[j][i] = fd[j+1][i] = 'o';
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (fd[i][j] == '#') {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int n,k,a[202020]; 
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n>>k;
	fo(i,0,n)cin>>a[i];
	int l=0,r=1e9+5;
	while(l<=r){
		int mid=(l+r)/2;
		if(mid==0)break;
		ll x=0;
		fo(i,0,n)x+=(a[i]-1)/mid;
		if(x>k)l=mid+1;
		else r=mid-1;
	}
	ll x=0;
	if(l<=1){
		cout<<"1\n";
		return 0;
	}
	fo(i,0,n)x+=(a[i]-1)/(l-1);
	if(x<=k)cout<<l-1<<endl;
	else cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 4320
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string[] sar = s.Split(' ');
			int a, b, c;
			a = int.Parse(sar[0]);
			b = int.Parse(sar[1]);
			c = int.Parse(sar[2]);
			int number = 0;
			for (int i = a; i <= b; i++)
			{
				if (c % i == 0) { number++; }
			}
			Console.WriteLine(number);
		}
	}
}

Measured memory_bytes: 9144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", 32 * 1024 * 1024).start(); //
	}
	public void run() {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		int max_ans = 0;
		int cans=0;
		int prev = 0;
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
			if(prev >= a[i])
			{
				cans++;
			}
			else {
				max_ans = Math.max(max_ans, cans);
				cans = 0;
			}
			prev = a[i];
		}
		max_ans = Math.max(max_ans, cans);
		out.println(max_ans);
		out.flush();
	}

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}

Measured memory_bytes: 38868
diffCount::String->String->Int
diffCount a b = length $ filter id $ zipWith (/=) a b

main = do
  s <- getLine
  let len = length s
  let ptn1 = take len (cycle "10")
  let ptn2 = take len (cycle "01")
  print $ min (diffCount s ptn1) (diffCount s ptn2)
        

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

Measured memory_bytes: 3092
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N;
ll a[210000];

int main () {
  cin >> N;

  rep(i, N) cin >> a[i];

  ll tmp = a[N];
  ll ans = 0;

  for (int i=N;i>=1;--i) {
    if (i - a[i] <= 0) {
      cout << -1 << "\n";
      return 0;
    }

    if (a[i] == tmp) {
      ans += a[i];
    } else if (a[i] == tmp-1) {
      tmp = a[i];
    } else {
      if (a[i] < tmp-1) {
        cout << -1 << "\n";
        return 0;
      }

      tmp = a[i];
      ans += a[i];
    }
  }
  if (tmp != 0) {
    cout << -1 << "\n";
  } else {
    cout << ans << "\n";
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve(long long N, std::vector<std::string> s, std::vector<long long> t, std::string X){
    ll cnt=0;
    bool start=false;
    for (ll i = 0; i < N; i++) {
        if(start){
            cnt += t[i];
        }
        if(s[i]==X){
            start = true;
        }
    }
    cout << cnt << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> s(N);
    std::vector<long long> t(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> s[i];
        scanf("%lld",&t[i]);
    }
    std::string X;
    std::cin >> X;
    solve(N, std::move(s), std::move(t), X);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A,B;
  char c[11];
  cin>>A>>B;
  cin >> c;
  
  for(int i=0;i<A;i++){
    if(c[i]<'0' || c[i]>'9'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  
    if(c[A] != '-'){
      cout<<"No"<<endl;
      return 0;
    }
    
    for(int i=A+1;i<A+B+1;i++){
    if(c[i]<'0' || c[i]>'9'){
      cout<<"No"<<endl;
      return 0;
    }  
    }
  
      cout<<"Yes"<<endl;
      
    }


Measured memory_bytes: 256
//ehhhhh...... i hate you......

/* optimizations and other useless stuff*/
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define INF 1e14
#define ull unsigned long long int
using namespace std;
/* TYPE DEFINITIONS */
typedef     long long int   ll;
typedef     vector<ll>      vi;
typedef     pair<ll,ll>     pi;


/* Basic  Math!!! */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
ll ncr(int n, int k)  
{  
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 

/* MACROS */
#define  all(A)         (A).begin() , (A).end()
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).sbegin()) it = (a).begin(); it != (a).end(); it++)  
void solve()
{
    int n;
    cin>>n;
    ll ans=0;
    int a[n],b[n],c[n-1];
    forn(i,n)cin>>a[i];
    forn(i,n)cin>>b[i];
    forn(i,n-1)cin>>c[i];
    ans+=b[a[0]-1];
    for(int i=1;i<n;i++)
    {
        //cout<<ans<<endl;
        if(a[i-1]+1==a[i])
        {
            ans+=b[a[i]-1];
            if(a[i]-2>=0)ans+=c[a[i]-2];
        }
        else
        {
            ans+=b[a[i]-1];
        }
    }
    cout<<ans<<endl;
}

int main()
{
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>){
    val str1 = readLine()?:""
    val str2 = readLine()?:""
    var str = str2
    for(i in 0 .. str.length-1){
        str = str + str2[i]
        str = str.substring(1,str2.length+1)
        if(str1.equals(str,true)) {
            println("Yes")
            return
        }
    }
    println("No")
}

Measured memory_bytes: 33580
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
using namespace std;
int n;
int a[100005],dp[100005];
ll sol(int i)
{
    ll res=1e10;
    //cout<<i<<endl;
    if(dp[i]!=-1)return dp[i];
    if(i>=n-1)return 0;
    if(i+1<=n-1)
            res=min(res,sol(i+1)+abs(a[i]-a[i+1]));
    if(i+2<=n-1)
            res=min(res,sol(i+2)+abs(a[i]-a[i+2]));
        return dp[i]=res;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    memset(dp,-1,sizeof dp);
    cout<<sol(0);
}

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

bool is_palindrome(string s) {
    int n = s.size();
    for (int i = 0; i < n; i++) {
        if (s[i] != s[n - i - 1])
            return false;
    }

    return true;
}

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

    int N = S.size();
    int cond2 = (N - 1) / 2;
    int cond3 = (N + 3) / 2;
    string str2 = S.substr(0, cond2);
    string str3 = S.substr(cond3 - 1, N - cond3 + 1);

    if (is_palindrome(S)
        && is_palindrome(str2)
        && is_palindrome(str3)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
num_n = int(input())
n = map(int, raw_input().split())
num_m = int(input())
m = map(int, raw_input().split())
    
def solve(i, m):
   if m == 0:
      return True
   if i >= num_n or m > sum(n):
      return False
   res = solve(i + 1, m) or solve(i + 1,m - n[i])
   return res
     
for k in range(num_m):
   if solve(0, m[k]):
      print "yes"
   else:
      print "no"

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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int gcd(int a, int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
int a[100005],l[100005],r[100005];
int solve(){
    cin>>n;
    rep(i,1,n) cin>>a[i];
    l[1]=a[1]; r[n]=a[n];
    rep(i,1,n) l[i]=gcd(l[i-1],a[i]);
    rep1(i,n-1,1) r[i]=gcd(r[i+1],a[i]);
    rep(i,1,n) ans=max(ans,gcd(l[i-1],r[i+1]));
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

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

using namespace std;

int main(){
	int n, w;
	cin >> n >> w;

	int wt[n], val[n];
	for(int i=0;i<n;i++){
		cin >> wt[i] >> val[i];
	}

	ll dp[w+1];
	memset(dp, 0, sizeof(dp));
	for(int i=0;i<n;i++){
		for(int j=w;j>=wt[i];j--){
			dp[j] = max(dp[j], dp[j-wt[i]] + val[i]);
		}
	}

	cout << dp[w] << endl;
	return 0;
}

Measured memory_bytes: 4388
#include<stdio.h>

int main() {
	int n, sum;
	int i, j, k;
	int count;
	
	while (1) {
		scanf("%d %d", &n, &sum);
		if (n == 0 && sum == 0) break;
		count = 0;
		for (i = 1; 3 * i + 3 <= sum; i++) {
			for (j = i + 1; i + 2 * j + 1 <= sum; j++) {
				for (k = n; k > j; k--) {
					if (sum == i + j + k) {
							count++;
							break;
					} else if (sum >= i + j + k) {
							break;
					}
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 600
fn main(){
	let v = read_vec::<i32>();
	let (a, b) = (v[0], v[1]);
	println!("{} {} {:.6}", a / b, a % b, a as f64 / b as f64)

}
 
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


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

int main(void)
{
    int n, t;
    cin >> n >> t;
    priority_queue<int, vector<int>, greater<int>> q;
    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        if (b <= t)
            q.push(a);
    }
    if (q.size() == 0)
        cout << "TLE" << endl;
    else
        cout << q.top() << endl;
}


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

using namespace std;

int main() {
	int k, a, b;
	scanf("%d%d%d", &k, &a, &b);
	
	int least = k * ((a + k - 1) / k);
	
	if (least <= b) printf("OK\n");
	else printf("NG\n");
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  reverse(ALL(s));
  int now = 0;
  while(now < int(s.size())) {
    if(s.substr(now, 5) == "maerd"){
      now += 5;
    }else if(s.substr(now, 7) == "remaerd"){
      now += 7;
    }else if(s.substr(now, 5) == "esare"){
      now += 5;
    }else if(s.substr(now, 6) == "resare"){
      now += 6;
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

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

		int n = scan.nextInt();
		int v = 0;
		int m = 0;
		for(int i = 0; i < n; i++){
			int p = scan.nextInt();
			v += p;
			if ( m < p) m =p;
		}
		System.out.println(v - m /2);
	}
}


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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int c = a - b;
  vector<long long> v;
  for (int i = 0; i < n; i++) {
    long long k;
    scanf("%lld", &k);
    v.push_back(k);
  }
  sort(v.begin(), v.end());

  long long left = v[n-1] / a;
  long long right = v[n-1] / b + 1;
  while(left != right) {
    long long mid = (left + right) / 2;
    long long count = 0;
    for (int i = 0; i < n; i++) {
      if (v[i] > mid * b) {
        count += ((v[i] - mid * b) + c - 1) / c;
      }
    }
    if (count <= mid) right = mid;
    else left = mid + 1;
  }
  cout << left << endl;
  return 0;
}

Measured memory_bytes: 1528
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    a = [(int(x),i+1) for i,x in enumerate(sys.stdin.readline().split())]

    N0 = 2**(N.bit_length())
    st1 = [0] * (2*N0)
    st2 = [N+1] * (2*N0)

    def update_max(i,x):
        i += N0 - 1
        st1[i] = x
        while i > 0:
            i = (i-1) // 2
            st1[i] = max(st1[i*2+1],st1[i*2+2])

    def update_min(i,x):
        i += N0 - 1
        st2[i] = x
        while i > 0:
            i = (i-1) // 2
            st2[i] = min(st2[i*2+1],st2[i*2+2])

    def query_max(l,r):
        L = l + N0; R = r + N0
        ret = 0
        while L < R:
            if L % 2:
                ret = max(ret,st1[L-1])
                L += 1
            if R % 2:
                R -= 1
                ret = max(ret,st1[R-1])
            L //= 2; R //=2
        return ret

    def query_min(l,r):
        L = l + N0; R = r + N0
        ret = N+1
        while L < R:
            if L % 2:
                ret = min(ret,st2[L-1])
                L += 1
            if R % 2:
                R -= 1
                ret = min(ret,st2[R-1])
            L //= 2; R //= 2
        return ret

    a.sort()
    ans = 0
    for x,y in a:
        i = query_max(1,y)
        j = query_min(y,N+1)
        ans += (y-i) * (j-y) * x
        update_max(y,y)
        update_min(y,y)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 105928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/*
int main(void){
    int a[101],b,res=0;
    for(int i=0;i<101;i++)a[i]=0;
    for(int i=0;i<101;i++){
        b=0;
        cin>>b;
        a[b]++;
    }
    int ans[101],j=0;
    for(int i=0;i<101;i++)ans[i]=0;
    for(int i=1;i<101;i++){
        if(a[i]>=res){
            ans[j]=a[i];
            j++;
        }
    }
    for(int i=0;i<101;i++){
        cout<<ans[i]<<endl;
        if(ans[i]==0)break;
    }
}
*/
int main(void){
    int n,i=0;
    int a[101] ;
    memset(a,0,sizeof(a));
    while(cin>>n){
        a[n]++;
        i++;
    }
    int max = 0;

    for(int j = 0;j<i;j++){
        if(a[j] > max)max = a[j];
    }
    
    for(int j=0;j<i;j++){
        if(a[j] == max){
            cout << j<<endl;
        }
    }
    
}




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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<int,P>;
using PP = pair<P, P>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = ll(1e9)+7;
constexpr int di[] = {0,1,0,-1};
constexpr int dj[] = {1,0,-1,0};


bool solve(){
    int m, n, k;
    cin >> m >> n >> k;
    vector<vector<P> > row(n), col(m), g((k+2)*2);
    for(int i=0;i<k;i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        row[y].emplace_back(P(x,i*2));
        col[x].emplace_back(P(y,i*2+1));
        g[i*2].emplace_back(P(i*2+1,1));
        g[i*2+1].emplace_back(P(i*2,1));
    }
    int S = k, G = k+1;
    col[0].emplace_back(P(0,S*2));
    row[n-1].emplace_back(P(m-1,G*2));
    col[m-1].emplace_back(P(n-1,G*2+1));
    for(int i=0;i<n;i++){
        sort(row[i].begin(), row[i].end());
        int t = row[i].size();
        for(int j=0;j<t-1;j++){
            int l = row[i][j].first, u = row[i][j].second;
            int r = row[i][j+1].first, v = row[i][j+1].second;
            g[u].emplace_back(P(v,r-l));
            g[v].emplace_back(P(u,r-l));
        }
    }
    for(int i=0;i<m;i++){
        sort(col[i].begin(),col[i].end());
        int t = col[i].size();
        for(int j=0;j<t-1;j++){
            int l = col[i][j].first, u = col[i][j].second;
            int r = col[i][j+1].first, v = col[i][j+1].second;
            g[u].emplace_back(P(v,r-l));
            g[v].emplace_back(P(u,r-l));
        }
    }
    vector<ll> d((k+2)*2, INF);
    priority_queue<P, vector<P>, greater<P> > que;
    d[S*2] = 0;
    que.push(P(0,S*2));
    while(!que.empty()){
        auto p = que.top();
        que.pop();
        int v = p.second;
        if(p.first > d[v]) continue;
        for(auto e : g[v]){
            ll u = e.first, cost = e.second;
            if(d[u] > d[v]+cost){
                d[u] = d[v]+cost;
                que.push(P(d[u],u));
            }
        }
    }
    ll ans = min(d[G*2], d[G*2+1]);
    cout << (ans < INF ? ans : -1) << endl;
    return true;
}

int main(){
    solve();
    return 0;
}



Measured memory_bytes: 62328
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <map>
#include <tuple>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;

int MAX_N = 200000;
struct Edge {
	int src, dst;
	Edge(int x, int y) {
		src = x;
		dst = y;
	}
};
typedef vector<Edge> edges;
typedef vector<edges> graph;

bool pp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
	return a.first < b.first;
}
void add_edge(graph& g, int x, int y) {
	g[x].emplace_back(Edge(x, y));
	g[y].emplace_back(Edge(y, x));
}

void dfs(graph& g, int v, vector<bool> &visited, vector<int> &u, int i) {
	visited[v] = true;
	u[v] = i;
	REP(j, g[v].size()) {
		if (!visited[g[v][j].dst]) dfs(g, g[v][j].dst, visited, u, i);
	}
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k, l;
	cin >> n >> k >> l;
	vector<Edge> e;
	graph r(n, e), t(n, e);
	REP(i, k) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		add_edge(r, x, y);
	}
	REP(i, l) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		add_edge(t, x, y);
	}
	vector<int> gt(n, -1), gr(n, -1);
	int c = 0;
	REP(i, n) {
		if (gr[i] == -1) {
			++c;
			vector<bool> visited(n, false);
			dfs(r, i, visited, gr, c);
		}
	}
	c = 0;
	REP(i, n) {
		if (gt[i] == -1) {
			++c;
			vector<bool> visited(n, false);
			dfs(t, i, visited, gt, c);
		}
	}
	vector<pair<pair<int, int>, int> > val(n);
	REP(i, n) {
		val[i] = make_pair(make_pair(gr[i], gt[i]), i);
	}

	sort(ALL(val));
	vector<int > v(n);
	REP(i, n) {
		v[val[i].second] = upper_bound(ALL(val), val[i], pp)-lower_bound(ALL(val), val[i], pp);
	}

	REP(i, n) {
		cout << v[i];
		if (i == n - 1) cout << endl;
		else cout << " ";
	}

	return 0;
}



Measured memory_bytes: 21504
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  char a[H][W];
  bool row[H] = {0};
  bool col[W] = {0};
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> a[i][j];
      if(a[i][j] == '#'){
        row[i] = true;
        col[j] = true;
      }
    }
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(row[i] && col[j]){
        cout << a[i][j];
      }
      if(j == W-1 && row[i] != 0){
        cout << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

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

    Int ans = 0;

    for(int i = 0;i < N;i++) {
        int temp;
        cin>>temp;
        ans += temp-1;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
using System;  
  
namespace ConsoleApplication1  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {
          string hoge = Console.ReadLine();
          if(hoge == "a"){
            Console.WriteLine("b");
          }
            if(hoge == "b"){
            Console.WriteLine("c");
          }
            if(hoge == "c"){
            Console.WriteLine("d");
          }
            if(hoge == "d"){
            Console.WriteLine("e");
          }
            if(hoge == "e"){
            Console.WriteLine("f");
          }
            if(hoge == "f"){
            Console.WriteLine("g");
          }
            if(hoge == "g"){
            Console.WriteLine("h");
          }
            if(hoge == "h"){
            Console.WriteLine("i");
          }
            if(hoge == "i"){
            Console.WriteLine("j");
          }
            if(hoge == "j"){
            Console.WriteLine("k");
          }
            if(hoge == "k"){
            Console.WriteLine("l");
          }
            if(hoge == "l"){
            Console.WriteLine("m");
          }
            if(hoge == "m"){
            Console.WriteLine("n");
          }
            if(hoge == "n"){
            Console.WriteLine("o");
          }
            if(hoge == "o"){
            Console.WriteLine("p");
          }
            if(hoge == "p"){
            Console.WriteLine("q");
          }
          if(hoge == "q"){
            Console.WriteLine("r");
          }
          if(hoge == "r"){
            Console.WriteLine("s");
          }
          if(hoge == "s"){
            Console.WriteLine("t");
          }
          if(hoge == "t"){
            Console.WriteLine("u");
          }
          if(hoge == "u"){
            Console.WriteLine("v");
          }
            if(hoge == "v"){
            Console.WriteLine("w");
          }
          if(hoge == "w"){
            Console.WriteLine("x");
          }
          if(hoge == "x"){
            Console.WriteLine("y");
          }
          if(hoge == "y"){
            Console.WriteLine("z");
          }
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<pair<int, int> > v(n);
    rep(i, n){
        int t, a;
        cin>>t>>a;
        v[i] = make_pair(t, a);
    }
    ll t = (ll)v[0].first;
    ll a = (ll)v[0].second;
    for(int i = 1;i<=n-1;i++){
        ll t_ratio = (ll)v[i].first;
        ll a_ratio = (ll)v[i].second;
        ll tnum = max(0LL, (t-t_ratio+(ll)v[i].first-1)/((ll)v[i].first));
        ll anum = max(0LL, (a-a_ratio+(ll)v[i].second-1)/((ll)v[i].second));
        t = t_ratio*(max(tnum, anum)+1);
        a = a_ratio*(max(tnum, anum)+1);
    }
    cout<<t+a<<endl;
    return 0;
}

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

const long long maxn = 2e5 + 10;

long long n, k, a[maxn];
long long ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n >> k;
    for(long long i = 0; i < n; i++){
        cin >> a[i];
        ans += a[i];
    }
}

void solve(){
    sort(a, a + n, greater<long long>());
    for(long long i = 0; i < min(n, k); i++)
        ans -= a[i];
}

void out(){
    cout << ans;
}


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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  
  long long e = a * c;
  long long f = b * d;
  long long g = a * d;
  long long h = b * c;
  
  if (a > 0 && b > 0 && c < 0 && d < 0) {
    cout << g << endl;
  }
  else if (a < 0 && b < 0 && c > 0 && d > 0) {
    cout << h << endl;
  }
  else{
    long long me = max(e, f);
    cout << me << endl;
  }
}


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

namespace ABC144A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b,c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            if(a<=9&&a>=1&&b<=9&&b>=1)
            {
                c = a * b;
            }
            else
            {
                c = -1;
            }
            Console.WriteLine(c);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
import scala.collection.immutable
object Main extends App {
  import scala.io.StdIn._
  import scala.math._
  val expression = readLine.trim.map(c ⇒ if (c == '(') 1 else -1).toArray
  for (i ← expression.indices.tail) expression(i) += expression(i - 1)
  val indices: Map[Int, immutable.IndexedSeq[Int]] = expression.indices.groupBy(i ⇒ expression(i))
  println(
    indices.map(a ⇒ a._2.length * (a._2.length - 1L) / 2).sum
  )
}


Measured memory_bytes: 105328
from collections import Counter

# 再帰回数のエラー？と思われるので再帰上限を変更 10**3 → 10**9
# 変更したら RE がなくなったのでおそらくこれのせいで通らなかった
import sys
sys.setrecursionlimit(10 ** 9)

def main(N, M, C):
    lst = [n for n in range(N)] # 初期値はすべてがそれぞれ根である状態

    def get_root(x):    # 根を得る関数
        if lst[x] == x: # それ自身が根である場合
            return x
        else:   # 根が別のものである場合
            lst[x] = get_root(lst[x])   # 経路圧縮あり (ある種「メモ再帰化」)
            return lst[x]
            # return get_root(lst[x]) # 経路圧縮なし (わかりやすい，ただの再帰関数) → ちなみにこれだとTLEになってしまった．

    def unite(x, y):    # 集合の連結を行う関数
        root_x = get_root(x)
        root_y = get_root(y)
        if root_x != root_y:    # 根が違う (=異なる集合) ならば
            lst[root_x] = root_y
            
    {unite(*c) for c in C}  # 集合の連結を行う．
    print(max(Counter(map(get_root, lst)).values()))    # 一番大きい集合の大きさを得る．


if __name__ == '__main__':
    N, M = list(map(int, input().split()))
    C = set()
    for _ in range(M):
        C.add(tuple(map(lambda x:int(x)-1, input().split())))   # pythonのindexに合わせるために "-1"
    main(N, M, C)

Measured memory_bytes: 52524
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y,ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        ll w=(p*p)%z;
        if(y%2==0)
         return w;
        else
        return (x*w)%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
  ll n;
  cin>>n;
  ll x[n],y[n];
  for(int i=0;i<n;i++)
  cin>>x[i]>>y[i];
  ll a[n],b[n];
  for(int i=0;i<n;i++){
  a[i]=x[i]+y[i];
  b[i]=x[i]-y[i];}
sort(a,a+n);
sort(b,b+n);
cout<<max(b[n-1]-b[0],a[n-1]-a[0]);}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int pre = -999;
  rep(i, n) {
    if(pre <= a[i] - 1) {
      pre = a[i] - 1;
    }else if (pre <= a[i]) {
      pre = a[i];
    }else {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}



Measured memory_bytes: 640
//a.c A-Double Helix
#include<stdio.h>

int main(void){
    char buf[1];
    scanf("%s",buf);
    if(buf[0]=='A'){
        printf("T\n");
    }else if(buf[0]=='T'){
        printf("A\n");
    }else if(buf[0]=='C'){
        printf("G\n");
    }else{
        printf("C\n");
    }
    return 0;
}

Measured memory_bytes: 128
from itertools import permutations

n, m = map(int, input().split())
edge = [[False] * n for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edge[a-1][b-1] = True
    edge[b-1][a-1] = True

res = 0
for t in permutations(list(range(1, n))):
    l = list(t)
    l.insert(0, 0)
    flag = True

    for i in range(n-1):
        if not edge[l[i]][l[i+1]]:
            flag = False

    if flag:
        res += 1

print(res)

Measured memory_bytes: 73632
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 1000000000
int gcd(int a, int b)
{
    if (a < b)
        return gcd(b, a);
    else if (a % b)
        return gcd(b, a % b);
    else
        return b;
}
int main()
{
    int p, q;
    cin >> p >> q;
    q /= gcd(p, q);
    map<int, int> res;
    for (int i = 2; i * i <= MAX_N; i++)
    {
        while (q % i == 0)
        {
            q /= i;
            res[i]++;
        }
    }
    if (q != 1)
        res[q]++;
    int ans = 1;
    for (auto p : res)
    {
        ans *= p.first;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3108
'use strict'
 
function main(n) {
  let N = n.split("\n")[0].split(" ")[0];
  let K = n.split("\n")[0].split(" ")[1];
  let l = n.split("\n")[1].split(" ");
  let ans = 0;
  let lSort = l.sort((a,b)=>{
  	return a-b;
  }).reverse();
  
  for(let i = 0; i < K; i++){
  	ans += lSort[i] * 1;
  }
  console.log(ans);
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372