akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>

using namespace std;

const bool debug = true;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
//const int mod = int(1e9) + 7;
//const int inf = 1e9;
//const long long infLL = 1e16;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 300500; //       e5
//const int SZ = 2100;
//const int delta = 1 << 19;

int a[100];

int main()
{
    ios_base::sync_with_stdio(false);
    //if(debug)
//freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    int n, m;
    cin >> n >> m;
    for(int i =0 ; i < m; i++){
        int u, v;
        cin >> u >> v;
        a[u]++;
        if(u != v) a[v]++;
    }

    for(int i = 1; i <= n; i++){
        cout << a[i] << "\n";
    }


    return 0;
}


Measured memory_bytes: 256
import numpy as np
x1, y1, x2, y2 = map(int, input().split())

a = np.array([x2-x1, y2-y1])
rot = np.array([[0, 1], [-1, 0]])
b = np.dot(a, rot)
print (x2 + b[0], y2 + b[1], x1 + b[0], y1 + b[1])


Measured memory_bytes: 12600
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		String str = sc.next();
		int wPos = str.indexOf('w');
		String pre = str.substring(0, wPos - 1);
		String suf = str.substring(wPos + 2);
		int[][] dp = new int[pre.length() + 1][suf.length() + 1];
		for (int i = 1; i <= pre.length(); ++i) {
			for (int j = 1; j <= suf.length(); ++j) {
				dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
				if (syn(pre.charAt(i - 1), suf.charAt(suf.length() - j))) {
					dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - 1] + 2);
				}
			}
		}
		System.out.println(dp[pre.length()][suf.length()] + 3);
	}

	static boolean syn(char c1, char c2) {
		if (c1 == '(' && c2 == ')') {
			return true;
		}
		if (c1 == ')' && c2 == '(') {
			return true;
		}
		if (c1 == '{' && c2 == '}') {
			return true;
		}
		if (c1 == '}' && c2 == '{') {
			return true;
		}
		if (c1 == '[' && c2 == ']') {
			return true;
		}
		if (c1 == ']' && c2 == '[') {
			return true;
		}
		return false;
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
  string s;
  
  cin>>s;
  string front="";
  string back=s;


  int q;
  cin>>q;

  int t;
  int f;
  bool revflag=false;
  string c;
  for(int i=0;i<q;i++){
    cin>>t;
    switch(t){
      case 1:
        revflag=!revflag;
        break;
      case 2:
        cin>>f>>c;
        switch (f) {
          case 1:
            if(revflag){
              back+=c;
            }
            else{
              front+=c;
            }
            break;
          case 2:
            if(revflag){
              front+=c;
            }
            else{
              back+=c;
            }
            break;
        }
        break;
    }
  }
  if(revflag){
    reverse(back.begin(), back.end());
    cout<<back+front;
  }
  else{
    reverse(front.begin(), front.end());
    cout<<front+back;
  }  
}


Measured memory_bytes: 1500
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(H: int, W: int, N: int):
    if H > W:
        W, H = H, W
    print(-(-N//W))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(H, W, N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
 
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; }

#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 

void func() {
  string S;
  cin >> S;

  
  LL N = 3;
  for (LL bit = 0; bit < (1 << N); ++bit) {
    LL total = stoll(S.substr(0, 1));
    for (LL i = 0; i < N; ++i) {
      //cout << std::bitset<10>(bit)<<endl;
      if (bit & (1 << i)) {
        total += stoll(S.substr(i+1, 1));
      }
      else{
        total -= stoll(S.substr(i+1, 1));
      }
    }
    if(total ==7){
      //cout << std::bitset<10>(bit)<<endl;LL total = stoll(S.substr(0, 1));
      cout << stoll(S.substr(0, 1));
      for (LL i = 0; i < N; ++i) {
        //cout << std::bitset<10>(bit)<<endl;
        if (bit & (1 << i)) {
          cout <<"+";
          
        }
        else{
          cout <<"-";
        }
        cout << stoll(S.substr(i+1, 1));
      }
      cout << "=7";
      return ;
    }
  }
  return;
}

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

Measured memory_bytes: 256
def solve(x, y):
    # |x| = |p + q  | = | 1 1 | |p|
    # |y|   |2p + 4q|   | 2 4 | |q|
    # <=>
    # |p| = 1/2 | 4 -1| |x|  =  (4x - y)/2
    # |q|       |-2  1| |y|     (-2x +y)/2
    p2 = 4 * x - y
    q2 = -2 * x + y
    if p2 % 2 == 0 and q2 % 2 == 0 and p2 >= 0 and q2 >= 0:
        return "Yes"
    return "No"


def main(istr, ostr):
    x, y = list(map(int, istr.readline().strip().split()))
    result = solve(x, y)
    print(result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)


Measured memory_bytes: 9136
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit


if True:
    N, = getIntList()
    #print(N)
    za = getIntList()
else:
    N = 1000
    import random
    za = [random.randint(1, 1000000000) for i in range(N) ]

dprint('begin')

zleft = [0 for i in range(N+1)]
zright = [0 for i in range(N+1)]


def getwork(zr, za):
    zr[0] = 0
    st = []
    for i in range(N):
        if i%10000  ==0:
            dprint('---', i)
        nt = [[za[i],0], [za[i],0], 1]
        st.append(nt)
        nr = zr[i]
        #dprint(st)
        while len(st)>1:
            b_2 = st[-2][1][1]
            b_1 = st[-1][0][1]
            bb = min(b_1,b_2)
            b_1 -=bb
            b_2 -=bb
            b_1p = 4 ** b_1
            b_2p = 4 ** b_2
            t2 = st[-2][1][0] * b_2p
            t1 = st[-1][0][0] * b_1p
            if  t2 < t1:
                nr+= 2* st[-2][2]
                st[-2][0][1] +=1
                st[-2][1][1] +=1
            elif t2 < t1 * 4:
                ttt = [ st[-2][0], st[-1][1], st[-2][2] + st[-1][2] ]  
                st[-2] = ttt
                st.pop()
            else:
                break
        #dprint(st)
        zr[i+1] = nr
        #dprint(nr)
        #dprint(st)
        assert nr < 1000000000000000

getwork(zleft, za)
dprint('!!!!')
getwork(zright, za[::-1])
 
#dprint(zleft)
#dprint(zright)

r =  zright[N]
for i in range(N+1):
    tr =  i + zleft[i] + zright[N-i]
    r = min(r,tr)

print(r)

dprint('end')




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

int main(){
	int N,W;
	int v[100],w[100];
	
	//input
	scanf(" %d %d", &N, &W);
	for(int i=0; i<N; ++i) scanf(" %d %d", &v[i], &w[i]);
	
	//solve
	
	//dp[i][j]:=??????1~i????????????????????????????????????????????§?????????j???????????\???????????????????????????????¨?????????§???
	int dp[101][10001]={0};
	
	for(int i=0; i<N; ++i){
		for(int j=0; j<=W; ++j){
			if(j-w[i]>=0)
				dp[i+1][j] = max( dp[i+1][j-w[i]]+v[i], dp[i][j] );
			else dp[i+1][j] = dp[i][j];
		}
	}

	printf("%d\n", dp[N][W]);
}

Measured memory_bytes: 5144
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    cout << (N-2)*180 << nn;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace C_TrainTicket
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var A = int.Parse(input[0].ToString());
            var B = int.Parse(input[1].ToString());
            var C = int.Parse(input[2].ToString());
            var D = int.Parse(input[3].ToString());

            var op = new string[]{ "+", "-"};
            var gotResult = false;
            var resultLine = "";

            for(var i = 0; i < op.Length; i++)
            {
                for(var j = 0; j < op.Length; j++)
                {
                    for(var k = 0; k < op.Length; k++)
                    {
                        var result = Operand(A, B, op[i]);
                        result = Operand(result, C, op[j]);
                        result = Operand(result, D, op[k]);

                        if (result == 7)
                        {
                            resultLine = A + op[i] + B + op[j] + C + op[k] + D + "=7";
                            gotResult = true;
                            break;
                        }
                    }
                    if(gotResult)
                        break;
                }
                if(gotResult)
                    break;
            }

            Console.WriteLine(resultLine);
        }

        static int Operand(int a, int b, string op)
        {
            if(op == "+")
                return a + b;

            return a - b;
        }
    }

    static class StringExtention
    {
        static public int[] ToIntArrays(this string input)
        {
            return input.Split(' ').Select(int.Parse).ToArray();
        }
    }
}


Measured memory_bytes: 13140
s=input()
while 1:
    if s[-5:]=="dream":
        s=s[:-5]
        continue
    elif s[-7:]=="dreamer":
        s=s[:-7]
        continue
    elif s[-5:]=="erase":
        s=s[:-5]
        continue
    elif s[-6:]=="eraser":
        s=s[:-6]
        continue
    else:
        if s=="":
            print("YES")
        else:
            print("NO")
        break

Measured memory_bytes: 134772
#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;
    queue<int> q;
    rep(i,n){
        int a;
        cin>>a;
        q.push(a);
    }
    int ans=0;
    int i=1;
    while(!q.empty()){
        int b = q.front();
        if(b==i){
            ans++;
            i++;
        }
        q.pop();
    }
    if(ans==0) cout << -1 << endl;
    else if(ans==n)  cout << 0 << endl;
    else    cout << n-ans  << endl;
    
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 25, M = 1e6 + 25, oo = 1e9, mod = 1e9 + 7, v = 1 << 21;
const long long OO = 1e18+25;
int n, a[25][25], mem[25][v];

int dp(int idx=0, int msk=0)
{
    if(msk == (1 << n)-1) return 1;
    if(idx == n+1) return 0;
    int &ret = mem[idx][msk];
    if(ret != -1) return ret;
    ret = 0;
    for(int i=0; i<n; i++)
    {
        if(a[idx][i] && !(msk&(1<<i)))
        {
            ret = (ret+dp(idx+1, msk|(1<<i)))%mod;
        }
    }
    return ret;
}


int main()
{
    memset(mem, -1, sizeof mem);
    scanf("%d",&n);
    for(int i=0; i<n; i++)for(int j=0; j<n; j++) scanf("%d",&a[i][j]);
    printf("%d",dp());
    return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> L){
    sort(ALL(L));
    int ans = 0;
    REP(i, N){
        ans += L[i*2];
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(2*N);
    for(int i = 0 ; i < 2*N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 256
l,r=map(int,input().split())
mod=2019
lm=l%673
if r-l+1>=673:
    print(0)
else:
    ans=float('inf')
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans=min(ans,i*j%mod)
    print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

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

int col[100005];
vector<pi> g[100005];

void dfs(int u, int p, int c){
	col[u] = c;
	for(pi v : g[u]) if(v.fi != p){
		dfs(v.fi, u, c ^ v.se);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	rep(i, n - 1){
		int a, b, c;
		cin >> a >> b >> c;
		g[a].pb(mp(b, c % 2));
		g[b].pb(mp(a, c % 2));
	}
	dfs(1, 0, 0);
	repn(i, 1, n + 1) cout << col[i] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define stdi(in) freopen(in, "r", stdin)
#define stdo(out) freopen(out, "w", stdout)
#define stdio(in, out) stdi(in); stdo(out)
#define pb push_back

using namespace std;

typedef long long ll;

const int MAX = 1e5+7;
const ll MOD = 1e9+7;

ll dp[MAX][2];
vector<int> G[MAX];

ll solve(int s, int c, int p){

	if(dp[s][c]!=-1) return dp[s][c];

	ll ans = 1;
	for(auto v: G[s]){
		if(v==p) continue;

		if(c==1){
			ans = (ans*solve(v,0,s))%MOD;
			continue;
		}

		ll tmp = (solve(v,0,s)+solve(v,1,s))%MOD;
		ans = (ans*tmp)%MOD;
	}

	return dp[s][c] = ans;
}

int main(){

	/*#ifndef ONLINE_JUDGE
        stdio("in", "out");
    #endif*/

	int n;
	cin>>n;
	memset(dp, -1, sizeof(dp));
	for(int i=0;i<n-1;i++){
		int u,v;
		cin>>u>>v;
		G[u].pb(v);
		G[v].pb(u);
	}

	ll ans = solve(1,0,0);
	ans = (ans+solve(1,1,0))%MOD;

	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 15616
#include<iostream>
#include<math.h>
#include<algorithm>

typedef long long ll;

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

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

    int A,B;
    cin >> A >> B;
    if(A > 8 or B > 8){
         cout << ":(" << endl;
    }else {
         cout << "Yay!" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from bisect import bisect
n, k = map(int, input().split())
v = list(map(int, input().split()))
ans = 0
for left in range(n + 1):
    for right in range(n + 1 - left):
        if left > n - right or left + right > k:
            continue
        li = sorted(v[:left] + v[n - right:])
        rem = min(bisect(li, 0), k - left - right)
        ans = max(ans, sum(li[rem:]))
print(ans)


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

#define ll long long
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fir(a,b) for(int i=a;i>b;i--)
#define fjr(a,b) for(int j=a;j>b;j--)
#define test int t;cin>>t;while(t--)
#define fast ios::sync_with_stdio(NULL); cin.tie(NULL)

int main(){
    fast;
    int r,d,x,a;
    cin >> r >> d >> x;
    fi(1,11)
    {
        a = (r*x)-d;
        x = a;
        cout << x << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    val count =
      Iterator.continually(io.StdIn.readInt())
        .take(n)
        .count(isPrime)
    println(count)
  }

  def isPrime(n: Int): Boolean = {
    val rt = Math.sqrt(n).toInt

    @annotation.tailrec
    def isPrime(i: Int): Boolean = {
      if (i <= rt)
        if (n % i ==0) false
        else isPrime(i + 2)
      else
        true
    }

    if (n == 2)
      true
    else if (n < 2 || n % 2 == 0)
      false
    else
      isPrime(3)
  }
}

Measured memory_bytes: 47572
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

P = 1/N
ans = max(0, (N-K+1)/N)

for i in range(1, min(N+1, K)):
	ans += P*0.5**(ceil(log2(K/i)))

print(ans)




Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> P_i;
typedef pair<double,double> P_d;
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;int ans=0;
#define answer cout << ans << endl;
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; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed main(){
  int N;
  cin >> N;
  cout << ceil((double)N/2.0) << endl;
  return 0;
}


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

typedef complex<int> P;

int main(){
     int N;
     while(cin>>N,N){
	  vector< P > source[8];
	  vector< P > temp;
	  vector< P > ore[N+1];

	  int M;
	  cin>>M;
	  for(int i=0;i<M;i++){
	       int x,y;
	       cin>>x>>y;
	       temp.push_back(P(x,y));
	  }
	  int x1=temp[0].real();
	  int y1=temp[0].imag();
	  for(int i=0;i<M;i++){
	       P a=P(temp[i].real()-x1,temp[i].imag()-y1);
	       for(int j=0;j<4;j++){
		    source[j].push_back(a);
		    a*=P(0,1);
	       }
	  }
	  x1=temp[M-1].real();
	  y1=temp[M-1].imag();
	  for(int i=M-1;i>-1;i--){
	       P a=P(temp[i].real()-x1,temp[i].imag()-y1);
	       for(int j=0;j<4;j++){
		    source[j+4].push_back(a);
		    a*=P(0,1);
	       }
	  }
//±Á©çÜêü1~n
	  for(int i=1;i<N+1;i++){
	       int M;
	       cin>>M;
	       int x1,y1;
	       cin>>x1>>y1;
	       ore[i].push_back(P(0,0));
	       for(int j=1;j<M;j++){
		    int xi,yi;
		    cin>>xi>>yi;
		    ore[i].push_back(P(xi-x1,yi-y1));
	       }
	  }
	  vector<int> ans;
	  ans.clear();
	  for(int i=1;i<N+1;i++){
	       for(int j=0;j<8;j++){
		    if(source[j]==ore[i]){
			 ans.push_back(i);//±ÌÜÜ¾Æ¦d¡·é©çÓ
			 break;//½Ôñ±êÅãÍð
		    }
	       }
	  }
	  sort(ans.begin(),ans.end());
	  for(int i=0;i<ans.size();i++){
	       cout<<ans[i]<<endl;
	  }
     
	  cout<<"+++++"<<endl;
     }
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{   
    int n;
    scanf("%d",&n);
    int h[n];
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    for(int i=n-1;i>=0;i--){
        if(h[i-1]<=h[i]){
        }else if(h[i-1]==h[i]+1){
            h[i-1]--;
        }else{
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 512
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(m)]
b=[]
for i in range(m):
  if a[i][0]==1:
    b+=[a[i][1]]
  elif a[i][1]==n:
    b+=[a[i][0]]

if len(b)==len(set(b)):
  ans='IMPOSSIBLE'
else:
  ans='POSSIBLE'
print(ans)

Measured memory_bytes: 62596
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	N := ReadInt()

	ans := math.MaxInt64
	for i := 1; i*i <= N; i++ {
		if N%i != 0 {
			continue
		}
		j := N / i
		ans = Min(ans, F(i, j))
	}
	fmt.Println(ans)
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

func F(a, b int) int {
	if b > a {
		a = b
	}
	n := 0
	for a > 0 {
		n++
		a /= 10
	}
	return n
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 1844
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000000000

int main() {
    int N, M;
    cin >> N >> M;
    int A[N];
    long long int sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < N; i++) {
        sum += A[i];
    }
    int count = 0;
    for(int i = 0; i < N; i++) {
        if(A[i] >= (double)sum/(4.0*M)) {
            count++;
        }
    }
    string messages = "Yes";
    if(count < M) {
        messages = "No";
    }
    cout << messages << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
#define ll long long

int main () {
  ll n;
  cin >> n;
  ll a[3 * n];
  ll l_sum[3 * n];
  ll r_sum[3 * n];
  for (ll i = 0; i < 3 * n; i++) {
    l_sum[i] = 0;
    r_sum[i] = 0;    
  }
  for (int i = 0; i < n * 3; i++) {
    cin >> a[i];     
  }  
  priority_queue<ll, vector<ll>, greater<ll> > box;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      l_sum[i] = a[i];  
    }  
    else {
      l_sum[i] = l_sum[i - 1] + a[i];  
    }
    box.push(a[i]);
  }
  for (int i = n; i < 2 * n; i++) {
    ll sub = box.top();
    if (a[i] > sub) {
      l_sum[i] = l_sum[i - 1] + a[i] - sub;  
      box.pop();
      box.push(a[i]);
    }  
    else {
      l_sum[i] = l_sum[i - 1];  
    }
  }
  priority_queue<ll> box2;
  for (int i = 0; i < n; i++) {
    int j = 3 * n - 1 - i;
    if (j == 3 * n - 1) {
      r_sum[i] = a[j];    
    }
    else {
      r_sum[i] = r_sum[i - 1] + a[j]; 
    }  
    box2.push(a[j]);
  }
  for (int i = n; i < 2 * n; i++) {
    int j = 3 * n - 1 - i;
    ll sub = box2.top();
    if (a[j] < sub) {
      r_sum[i] = r_sum[i - 1] + a[j] - sub;
      box2.pop();
      box2.push(a[j]); 
    }  
    else {
      r_sum[i] = r_sum[i - 1];  
    }
  }
  ll max;
  for (int i = 0; i <= n; i++) {
    int left = n - 1 + i;
    int right = 2 * n - i - 1;
    // cout << l_sum[left] << " " << r_sum[right] << endl;
    if (i == 0) {
      max = l_sum[left] - r_sum[right];  
    }    
    else {
      if (max <= l_sum[left] - r_sum[right]) {
        max = l_sum[left] - r_sum[right];  
      }  
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,a,b;
	cin >> n >> a >> b;
	cout << n / (a + b) * a + min(a,n % (a + b)) << endl;
}

Measured memory_bytes: 256
while True:
    n, r = map(int, raw_input().split())

    if n == 0 and r == 0:
        break

    Cards = [i for i in range(n, 0, -1)]

    for i in range(r):
        p, c = map(int, raw_input().split())
        Cards = Cards[p-1:p-1+c] + Cards[:p-1] + Cards[p-1+c:]

    print Cards[0]


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    set<int> A;
    rep(i, N){
        int a;
        cin >> a;
        if(A.count(a)) A.erase(a);
        else A.insert(a);
    }

    cout << A.size() << endl;
}

Measured memory_bytes: 4864
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

type Res struct {
	by, bx, y, x int
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	H, W := sc.nextInt(), sc.nextInt()
	G := make([][]int, H)
	for i := 0; i < H; i++ {
		G[i] = make([]int, W)
	}
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			a := sc.nextInt()
			if a%2 == 0 {
				G[i][j] = 0
			} else {
				G[i][j] = 1
			}
		}
	}
	changed := 0
	res := []Res{}
	for i := 0; i < H; i++ {
		if i%2 == 0 {
			for j := 0; j < W; j++ {
				if G[i][j] == 0 || (i == H-1 && j == W-1) {
					continue
				}
				ny, nx := i, j
				if j != W-1 {
					nx++
				} else {
					ny++
				}
				changed++
				res = append(res, Res{i, j, ny, nx})
				if G[ny][nx] == 1 {
					G[ny][nx] = 0
				} else {
					G[ny][nx] = 1
				}
			}
		} else {
			for j := W - 1; j >= 0; j-- {
				if G[i][j] == 0 || (i == H-1 && j == 0) {
					continue
				}
				ny, nx := i, j
				if j != 0 {
					nx--
				} else {
					ny++
				}
				changed++
				res = append(res, Res{i, j, ny, nx})
				if G[ny][nx] == 1 {
					G[ny][nx] = 0
				} else {
					G[ny][nx] = 1
				}
			}
		}
	}
	fmt.Fprintln(wtr, changed)
	for i := 0; i < changed; i++ {
		r := res[i]
		fmt.Fprintln(wtr, r.by+1, r.bx+1, r.y+1, r.x+1)
	}
}


Measured memory_bytes: 21888
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

int main()
{	
	ll n, k;
	cin >> n >> k;

	double p = 0;
	reple(i, 1, n)
	{
		ll x = 1;
		while ((ll)i * x <= k - 1)
		{
			x *= 2;
		}

		p += 1/(double)(x * n);
	}

	cout << setprecision(9)<< p << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
  int n;
  int s=0;
  cin >> n;
  vector<int> a(n), b(n), c(n-1);
  rep(i,n) cin >> a.at(i);
  rep(i,n) cin >> b.at(i);
  rep(i,n-1) cin >> c.at(i);
  s += accumulate(b.begin(), b.end(), 0);
  rep(i,n-1) if(a.at(i) == a.at(i+1)-1) s += c.at(a.at(i)-1);
  cout << s << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
h = list(map(int,input().split()))

dp=[10**10]*(n+2)

for i in range(1,n+1):
  for j in range(1,k+1):
    if i-j>0:
      x=dp[i-j]+abs(h[i-1]-h[i-j-1])
    else:
      x=abs(h[i-1]-h[0])
    dp[i]=min(dp[i],x)

print(dp[n])

Measured memory_bytes: 52592
import heapq
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]
AB.sort(key=lambda x:x[0])
AB.append([10**5+1,0])
h=[]
ans=0
for i in range(1,M+1):
  while AB[0][0]<=i:
    heapq.heappush(h,-AB.pop(0)[1])
  if len(h)>0:
    ans+=-heapq.heappop(h)
print(ans)

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

using namespace std;

int main()
{
    int a,b;

    cin>>a>>b;

    if(a==1 && b==2)
        cout<<"3"<<endl;

    else if(a==2 && b==1)
        cout<<"3"<<endl;

    else if((a==1 && b==3) || (a==3 && b==1))

        cout<<"2"<<endl;


    else //if((a==2 && b==3) || (a==3 && b==2))

        cout<<"1"<<endl;

    return 0;
}


Measured memory_bytes: 256
let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ =
    Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  List.sort compare as_
  |> (fun (a :: as_) -> List.fold_left (fun (a, s) a' -> (a', a' - a + s)) (a, 0) as_)
  |> snd
  |> Printf.printf "%d\n"

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#pragma comment(linker, "/STACK:250000000")

#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <functional>
#include <numeric>
#include <random>
#include <cstring>
#include <ctime>
#include <cassert>

#define y1 klfjvkldfngldf

using namespace std;

typedef long long LL;

int h, w;

int main()
{
	cin >> h >> w;

	LL res = 1LL << 60;
	for (int it = 0; it < 2; ++it)
	{
		for (int i = 1; i < h; ++i)
		{
			vector<LL> s;
			s.push_back((LL)i * (w / 2));
			s.push_back((LL)(h - i) * w);
			s.push_back((LL)i * w - s[0]);
			sort(s.begin(), s.end());
			res = min(res, s[2] - s[0]);
		}
		if (h > 2)
			res = min(res, (LL)(h + 2) / 3 * w - (LL)h / 3 * w);
		swap(h, w);
	}
	cout << res << '\n';
	return 0;
}

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

int main()
{
   string s;
   cin>>s;
   int count=0;
   string rs;
   rs = s;
   reverse(rs.begin(),rs.end()); 

   for(int i=0;i<s.size();i++)
   {   
       if(s[i]!=rs[i])
       {
           rs[i]=s[i];
           count++;
           s = rs;
           reverse(rs.begin(),rs.end());
           if(s==rs)
           {
               break;
           }
           else
           {
               i=0;
           }
       }
   }  
   cout<<count<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int w,h,x,y,r;
	scanf("%d %d %d %d %d", &w,&h,&x,&y,&r);

	int x_max=w-r;
	int x_min=r;
	int y_max=h-r;
	int y_min=r;
	
	if(x<x_min||x>x_max)
	{
	    printf("No\n");
	    return 0;
	}
	if(y<y_min||y>y_max)
	{
	    printf("No\n");
	    return 0;
	}
	printf("Yes\n");
}


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
const int N=4100000;
typedef long long ll;
ll sta[N];int top;
ll a[N];int n,m;
inline int erfen(ll v,int r){
	int l,mid;
	//cout<<"erfen:v="<<v<<" r="<<r<<endl;
	for(l=0,mid=(r+l)>>1;r-l>1;mid=(r+l)>>1)if(sta[mid]<=v)l=mid;else r=mid;
	if(sta[r]<=v)return r;
	return l;
}
ll t[N];
int main(){
	//freopen("in.txt","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
	sta[++top]=n;
	for(int i=1;i<=m;i++){
		while(top&&sta[top]>=a[i])top--;
		sta[++top]=a[i];
	}
	for(int i=0;i<=n;i++)a[i]=0;
	m=top;
	//for(int i=1;i<=m;i++)cout<<sta[i]<<endl;
	t[m]=1;
	for(int i=m;i>=1;i--){
		//cout<<"i="<<i<<endl;
		ll k=sta[i],p=erfen(k,i-1);
		//cout<<"k="<<k<<" p="<<p<<" "<<sta[p]<<endl;
		while(p)t[p]+=(k/sta[p])*t[i],k%=sta[p],p=erfen(k,p-1);//,cout<<"k="<<k<<" p="<<p<<endl;
		a[1]+=t[i];a[k+1]-=t[i];
	}
	ll now=0;
	for(int i=1;i<=n;i++){
		now+=a[i];
		printf("%lld\n",now);
	}
	return 0;
}

Measured memory_bytes: 8576
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		long x =lcm(n,m);
		boolean ok = true;
		for (int i=0;i<n;i++) {
			if ((x/n*i)%(x/m)==0 && s.charAt(i)!=t.charAt((int)(x/n*i/(x/m)))) {
				ok=false;
			}
		}
		for (int i=0;i<m;i++) {
			if ((x/m*i)%(x/n)==0 && t.charAt(i)!=s.charAt((int)(x/m*i/(x/n)))) {
				ok=false;
			}
		}

		System.out.println(ok?x:-1);
	}

	static long lcm(int n, int m) {
		return ((long)n*m)/gcd(n,m);
	}
	static int gcd(int n, int m) {
		if (n<m) {
			return gcd(m,n);
		}
		if (n%m==0) {
			return m;
		}
		return gcd(m,n%m);
	}
}


Measured memory_bytes: 26272
package main

import (
	"bufio"
	"fmt"
	"math/bits"
	"os"
	"sort"
)

type P struct {
	index int
	time  int
}

func main() {
	r := bufio.NewReader(os.Stdin)

	var n, q int
	fmt.Fscan(r, &n, &q)

	ps := make([]P, n)
	names := make([]string, n)
	for i := range ps {
		fmt.Fscan(r, &names[i])
		fmt.Fscan(r, &ps[i].time)
		ps[i].index = i
	}

	sort.Slice(ps, func(i, j int) bool {
		a, b := (ps[i].time-1)/q, (ps[j].time-1)/q
		if a == b {
			return ps[i].index < ps[j].index
		}
		return a < b
	})

	end := make([]uint8, n/8+1)
	et := 0
	for i, p := range ps {
		et += p.time
		endn := 0
		for j := 0; j <= p.index/8; j++ {
			endn += bits.OnesCount8(end[j] << uint(max(0, 8-p.index+8*j)))
		}
		aliven := p.index - endn
		fmt.Println(names[p.index], et+(n-i-1)*q*((p.time-1)/q)+aliven*q)
		end[p.index/8] |= 1 << (uint(p.index) % 8)
	}
}

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



Measured memory_bytes: 4428
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn = 10000 + 10;
const double eps=1e-6;

double f[maxn];
bool able[maxn];
int res1,res2;
double maxa,ans,t;
int a,b,c,d,e,n;

int main() {
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&n);
	maxa=(double) e/(100+e);
	able[0]=1;
	//printf("%f\n",maxa);
	for(int i=0;i<=n;i++) {
		t=f[i]*i/(i+a*100); if(able[i]&&t-maxa<=eps) {
			f[i+a*100]=max(f[i+a*100],t);
			able[i+a*100]=1;
		}
		t=f[i]*i/(i+b*100); if(able[i]&&t-maxa<=eps) {
			f[i+b*100]=max(f[i+b*100],t);
			able[i+b*100]=1;
		}
		t=(f[i]*i+c)/(i+c); if(able[i]&&t-maxa<=eps) {
			f[i+c]=max(f[i+c],t);
			able[i+c]=1;
		}
		t=(f[i]*i+d)/(i+d);	if(able[i]&&t-maxa<=eps) {
			f[i+d]=max(f[i+d],t);
			able[i+d]=1;
		} 
		//printf("f[%d]=%f\n",i,f[i]);
	}
	res1=a*100;
	for(int i=1;i<=n;i++) if(f[i]>ans) {
		ans=f[i];
		res1=i; 
		res2=round(i*f[i]);	
	}
	printf("%d %d\n",res1,res2);
	return 0;	
}

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

int main() {
  int N, T;
  bool ans = false;
  int MIN = 1000;
  cin >> N >> T;
  vector<int> c(N);
  vector<int> t(N);
  for (int i = 0; i < N; i++)
    cin >> c.at(i) >> t.at(i);
  for (int i = 0; i < N; i++) {
    if (t.at(i) <= T) {
      MIN = min(MIN, c.at(i));
      ans = true;
    }
  }
  if (ans == false)
    cout << "TLE" << endl;
  else
    cout << MIN << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val s = sc.next()

  val mod = 1_000_000_000 + 7L

  val map = mutableMapOf<Char, Int>()
  for (si in s) {
    val tmp = map.getOrElse(si) { 0 }
    map.put(si, tmp+1)
  }

  // val max = map.keys.size
  // println(max)

  var ans = 1L
  for (mi in map.values) {
    ans = ans * (mi + 1) % mod
  }

  println(ans - 1)

}


Measured memory_bytes: 41908
#include <bits/stdc++.h>
 
using namespace std;
 
int pal(long int n)
{
   long int o=n,rev=0;
   while(n!=0)
   {
     rev*=10;
     rev+=n%10;
     n/=10;
   }
  
  if(o==rev)
      return 1;
  
  else
     return 0;
}

int main()
{
   
    long int a,b;
  long int i,cnt=0;
  cin>>a>>b;
  for(i=a;i<=b;++i)
  {  if(pal(i))
        cnt++;
  }
  
  printf("%ld",cnt);
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <numeric>
#include <algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef pair<int, int> P;
string S, T;

int main(){
  cin >> S >> T;
  int sl = S.length(), tl = T.length();
  
  if(sl < tl){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  
  int cnt=0;
  for(int i=0; i<sl; i++){
    if(S[i] == '?') cnt++;
  }
  if(cnt == sl){
    for(int i=0; i<sl-tl+1; i++){
      S.replace(i, 1, "a");
    }
    S.replace(sl-tl, tl, T);
    cout << S << endl;
    return 0;
  }
  
  int index = -1;
  for(int i=0; i<sl-tl+1; i++){
    bool flag=true;
    for(int j=0; j<tl; j++){
      if(S[i+j]!='?' && S[i+j]!=T[j]){
//        cout << j  << endl;
        flag = false;
        break;
      }
    }
    if(flag){
      index = i;
//      cout << i << endl;
    }
  }
  if(index == -1){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }else{
  for(int j=0; j<sl; j++){
    if(index<=j && j<=index+tl-1){
      S.replace(j, tl, T);
        j+=tl-1;
      }
    else if(S[j]=='?'){
      S.replace(j, 1, "a");
    }
  }
  cout << S << endl;
  return 0;
  }
}

Measured memory_bytes: 3612
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll M =1e9+7;
const int N = 1e5+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

// vector<int> adj[N];
// bool vis[N]={0};

// void dfs(int x)
// {
//     vis[x]=1;
        
//     for(auto it:adj[x])   
//     if(!vis[it])
//     dfs(it);
        
// }

ll me(ll x,ll n)
{
    ll res=1;

    while(n)
    {
        if(n&1)
        res=(res*x)%M;

        x=(x*x)%M;

        n/=2;
    }

    return res;


}




int main()
{
    ll x,ans=0;
    lscf(x);

    
    ll mn=M;

    for(ll i=1;i<1001;i++)
    {
        

        rep(j,2,10)
        {
            ll p=me(i,j);

            if(p<=x)
            { 
                ll v=abs(x-p);
                if(v<mn)
                mn=v,ans=p; 
            }


        }

    


       
    }

   

    lprin(ans);

    
 

    
}


Measured memory_bytes: 3772
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
count=0
for i in range(len(a)-1):
    if a[i]+1==a[i+1]:
        count+=c[a[i]-1]
for i in b:
    count+=i
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);

const int MAX = 2000010;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	COMinit();
	int N, M;
	cin >> N >> M;
	int X[N], Y[M];
	rep(i,N) cin >> X[i];
	rep(i,M) cin >> Y[i];

	sort(X, X+N);
	sort(Y, Y+M);
	int ans1= 0, ans2 = 0;
	rep(i,N-1){
		ans1 += (X[i+1]-X[i])*(i+1)*(N-i-1);
		ans1 %= MOD;
	}
	rep(i,M-1){
		ans2 += (Y[i+1]-Y[i])*(i+1)*(M-i-1);
		ans2 %= MOD;
	}
	// cout << ans1 << " " << ans2 << endl;
	int ans = ans1 * ans2;
	ans %= MOD;
	cout << ans << endl;
}

Measured memory_bytes: 48768
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define F first
#define S second
#define ld long double
#define rep(i,n) for (int i =0;i < (n); ++i)
#define vi vector<ll>
#define all(v) (v).begin(),(v).end()
const int inf = 1e9 + 10;

void solve() {
	ll n;
	cin >> n;
	ll a[n + 1];
	for (int i = 1; i <= n; i++) cin >> a[i];
	map<ll, ll> f;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += f[i - a[i]];
		f[i + a[i]]++;
	}
	cout << ans;
}
int main() {

	FASTIO;

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(25);
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 27904
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;  
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,m,n,k;
ll t=1;
map<ll,vector<ll>>f;
map<ll,ll>visited;
void dfs(ll num)
{
    if(visited[num]!=0)return;
    visited[num]++;c++;
    for(ll i=0;i<f[num].size();i++)
    dfs(f[num][i]);
}
void solve()
{
    cin>>n>>m;
    vector<ll>ans;
    for(ll i=0;i<m;i++)
    {
        cin>>a>>b;
        f[a].emplace_back(b);
        f[b].emplace_back(a);
    }
    for(ll i=1;i<=n;i++)
    {
        c=0;
        dfs(i);
        if(c>0)
        ans.emplace_back(c);
    }
    cout<<(ans.size()-1LL);
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   
   //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 24088
#include<iostream>
using namespace std;
int main()
{
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++)
  {
    if((i%2==0)&&(s[i]=='L')) {cout<<"No";return 0;}
    if((i%2==1)&&(s[i]=='R')) {cout<<"No"; return 0;}
                    }
        cout<<"Yes";
                    }



Measured memory_bytes: 256