akhauriyash/Code-Regression huggingface dataset:
l, r = map(int, input().split())
if r-l>=2019:
    print(0)
else :
    a = 10*1000
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = (i*j)%2019
            a = min(a, ans)
    print(a)

Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left 

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n = INT()
    h = LIST()

    lis = [0]*(n-1)

    for i in range(n-1):
        if h[i] >= h[i+1] :
            lis[i] = 1

    ans_lis = []
    ct = 0
    for i in range(n-1):
        if  lis[i] == 0:
            ans_lis.append(ct)
            ct = 0
        else:
            ct += 1
    ans_lis.append(ct)
    
    print(max(ans_lis))

if  __name__=='__main__':
    main()


Measured memory_bytes: 16324
N=int(input())
s=0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
for i in range(N):
  if (i+1)%2!=0:
    if len(make_divisors(i+1))==8:
      s+=1
print(s)

Measured memory_bytes: 3060
n = int(input())
s = list(input())

r = 0
g = 0
b = 0
for i in range(n):
    if s[i] == "R":
        r += 1
    elif s[i] == "G":
        g += 1
    else:
        b += 1

ans = r * g * b
if ans == 0:
    print("0")
else:
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            sub = j - i
            sub2 = (n - 1) - j
            if sub <= sub2:
                if s[i] != s[j] and s[j] != s[j + sub] and s[i] != s[j + sub]:
                    ans -= 1
    print(ans)


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

int main() {

  string S;
  cin >> S;

  int num1 = (S.at(0) - '0') * 10 + S.at(1) - '0';
  int num2 = (S.at(2) - '0') * 10 + S.at(3) - '0';

  string result = "NA";

  if (0 < num1 && 0 < num2 && num1 <= 12 && num2 <= 12) {
    result = "AMBIGUOUS";
  } else if (num1 <= 12 && 0 < num1) {
    result = "MMYY";
  } else if (num2 <= 12 && 0 < num2) {
    result = "YYMM";
  } else {
    result = "NA";
  }

  cout << result << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	char a[5];


	scanf("%s", a);
	

	if(a[0] == a[1] && a[2] == a[3] && a[0] != a[2]){
		printf("Yes");
	} else if(a[0] == a[2] && a[1] == a[3] && a[1] != a[2]){
		printf("Yes");
	} else if(a[0] == a[3] && a[1] == a[2] && a[0] != a[2]){
		printf("Yes");
	} else {
		printf("No");
	}

	return 0;
}	

Measured memory_bytes: 128
/**
 * There is a start and there is no end in the space. ---Infinity.
 * It ruins and goes though there is also a start in stars. ---Finite.
 * Only the man who has wisdom can read the most foolish one from the history.
 * Fishes living in the sea doesn't know the life in the land.
 * It also ruins and goes if they have wisdom.
 * It funnier that man exceeds the speed of light than fish start living in the land.
 * It can be said that this is an final ultimatum from the god to the people who can fight.
 *
 * Steins;Gate
 */

#include <bits/stdc++.h>

const int N = 110;

int vis[N];

int main() {

    int n, cnt1 = 0;
    scanf("%d", &n);
    int t = (n + 1) * n / 2;
    if(t & 1) {
        if((n & 1) == 0) {
            printf("%d\n", n * (n - 2) / 2);
            for(int i = 1; i <= n; i++) {
                for(int j = i + 1; j <= n; j++) {
                    if(i + j != n + 1) {
                        printf("%d %d \n", i, j);
                    }
                }
            }
            return 0;
        }
        else {
            printf("%d \n", (n - 1) * (n - 3) / 2 + n - 1);
            for(int i = 1; i < n; i++) {
                printf("%d %d \n", i, n);
            }
            for(int i = 1; i < n; i++) {
                for(int j = i + 1; j < n; j++) {
                    if(i + j != n) {
                        printf("%d %d \n", i, j);
                    }
                }
            }
        }
        return 0;
    }
    t /= 2;
    for(int i = n; i >= 1 && t; i--) {
        if(t >= i) {
            t -= i;
            vis[i] = 1;
            cnt1++;
        }
    }
    printf("%d\n", cnt1 * (n - cnt1));
    for(int i = 1; i <= n; i++) {
        if(vis[i]) {
            for(int j = 1; j <= n; j++) {
                if(!vis[j]) {
                    printf("%d %d \n", i, j);
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF (2e9)
#define EPS (1e-7)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  string l, r, ans;
  cin >> n >> l >> r;

  for (int i; i < n; i++) {
    cout << l.at(i) << r.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int m, n;
map<string, pii> mp;
string e[110];
int dp[110][110][256];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> m;
  for (int i = 0; i < m; i++) {
    string name;
    int lb, ub;
    cin >> name >> lb >> ub;
    mp[name] = pii(lb, ub);
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> e[i];
  }

  stack<pii> st;
  for (int i = 0; i < n; i++) {
    if (isdigit(e[i][0])) {
      dp[i][i][stoi(e[i])] = 1;
      st.emplace(i, i);
    } else if (isalpha(e[i][0])) {
      pii r = mp[e[i]];
      for (int j = 0; j < 256; j++) {
        dp[i][i][j] = (r.first <= j && j <= r.second);
      }
      st.emplace(i, i);
    } else {
      if (st.size() < 2) {
        cout << "error" << endl;
        return 0;
      }
      pii a, b;
      b = st.top(); st.pop();
      a = st.top(); st.pop();
      if (e[i] == "+") {
        for (int j = 0; j < 256; j++) {
          for (int k = 0; k < 256; k++) {
            dp[a.first][i][(j+k)%256] |= (dp[a.first][a.second][j] && dp[b.first][b.second][k]);
          }
        }
      } else if (e[i] == "-") {
        for (int j = 0; j < 256; j++) {
          for (int k = 0; k < 256; k++) {
            dp[a.first][i][(j-k+256)%256] |= (dp[a.first][a.second][j] && dp[b.first][b.second][k]);
          }
        }
      } else if (e[i] == "*") {
        for (int j = 0; j < 256; j++) {
          for (int k = 0; k < 256; k++) {
            dp[a.first][i][(j*k)%256] |= (dp[a.first][a.second][j] && dp[b.first][b.second][k]);
          }
        }
      } else if (e[i] == "/") {
        if (dp[b.first][b.second][0]) {
          cout << "error" << endl;
          return 0;
        }
        for (int j = 0; j < 256; j++) {
          for (int k = 1; k < 256; k++) {
            dp[a.first][i][(j/k)%256] |= (dp[a.first][a.second][j] && dp[b.first][b.second][k]);
          }
        }
      }
      st.emplace(a.first, i);
    }
  }
  cout << "correct" << endl;

  return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 1000000

int main()
{
    int v, e, s, t, d;
    int G[15][15];
    cin >> v >> e;
    for (int i = 0; i < v; i++) {
        fill(G[i], G[i] + v, INF);
    }
    for (int i = 0; i < v; i++) {
        G[i][i] = 0;
    }
    for (int i = 0; i < e; i++) {
        cin >> s >> t >> d;
        G[s][t] = d;
    }
    int dp[1 << 15][15];
    for (int i = 0; i < 1 << 15; i++) {
        fill(dp[i], dp[i] + 15, INF);
    }
    dp[0][0] = 0;
    
    for (int S = 0; S < 1 << v; S++) {
        for (int i = 0; i < v; i++) {
            for (int u = 0; u < v; u++) {
                if (!((S >> u) & 1)) {
                    dp[S | (1 << u)][u] = min(dp[S | (1 << u)][u], dp[S][i] + G[i][u]);
                }
            }
        }
    }
    if (dp[(1 << v) - 1][0] == INF) {
        cout << -1 << endl;
    }
    else {
        cout << dp[(1 << v) - 1][0] << endl;
    }
    return 0;
}

Measured memory_bytes: 3080
n,m,x,y = list(map(int, input().split()))
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

xs2 = sorted(xs)
ys2 = sorted(ys)
for i in range(x+1, y+1):
	if xs2[-1] < i <= ys2[0]:
		print("No War")
		quit()
print("War")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, a;
    cin >> h >> a;
    cout << (h+a-1)/a << endl;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int x ;
  x=1;
  for (int i=0; i<N;i++){
    if (2*x > (x+K))
      x+= K;
    else if (2*x <=(x+K))
      x*= 2;
      }
  cout << x << endl;



    
    
    
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,m;
	cin >> n >> m;
	if(n % 2 == 0){
		int l = n/2;
		int r = l + 1;
		rep(i,0,n/4){
			if(m == 0)break;
			cout << l << ' ' << r << '\n';
			--l,++r;
			--m;
		}
		++r;
		rep(i,0,n/2){
			if(m == 0)break;
			cout << l << ' ' << r << '\n';
			--l,++r;
			--m;
		}
	}
	else{
		int off = 0;
		rep(i,0,m){
			cout << i+1 << ' ' << (n-i-1+off) << '\n';
		}
	}
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

struct point {
	long long x, y;
};
vector<point> A;
int N, K;

long long judge(int a, int b) {
	vector<point> AA;
	for (int n = a; n <= b; n++) {
		AA.push_back(A[n]);
	}
	sort(AA.begin(), AA.end(), [](point a, point b) {return a.y < b.y; });
	long long ans = LLONG_MAX;
	for (int n = 0; n <= AA.size() - K; n++) {
		ans = min(ans, AA[n + K - 1].y - AA[n].y);
	}
	return ans * (A[b].x - A[a].x);
}

int main() {
	cin >> N >> K;
	A.resize(N);
	for (point& p : A) {
		cin >> p.x >> p.y;
	}
	sort(A.begin(), A.end(), [](point a, point b) {return a.x < b.x; });
	long long ans = LLONG_MAX;
	for (int a = 0; a <= N - K; a++) {
		for (int b = a + K - 1; b < N; b++) {
			ans = min(ans, judge(a, b));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   B : Integer;
   C : Integer;
   flag : Integer;
begin
   Get (A);
   Get (B);
   Get (C);
   if A = B then
      if A = C then
         Put_Line ("No");
      else
         Put_Line ("Yes");
      end if;
   else
      if A = C then
         Put_Line ("Yes");
      elsif B = C then
         Put_Line ("Yes");
      else
         Put_Line ("No");
      end if;
   end if;
end Solve;

Measured memory_bytes: 3672
#include<stdio.h>
#include<string.h>
#define N 8
#define FREE -1
#define NOT_FREE 1
#define TRUE 2
#define FALSE 0


int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int X[N][N];



void board()
{
  int i;
  int j;
  
  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N; j++ ){
      if( X[i][j]== 2){
	if( row[i] != j )return;
      }
    }
  }
  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N; j++ ){
      if(row[i] == j )printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}



void putqueen(int i)
{
  int j;

  if( i == N ){
    board();
    return;
  }

  for( j = 0 ; j < N ; j++ ){
    if( NOT_FREE == col[j] ||
	NOT_FREE == dpos[i+j]||
	NOT_FREE == dneg[i-j+N-1]
	)
      continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;

    putqueen(i+1);
    
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

int main()
{
  int i;
  int j;
  int k;
  int r,c;

  // 全部襲撃される前に設定する
   for( i= 0 ; i < N; i++ ){
    row[i] = FREE;
    col[i] = FREE;
  }
  for( i = 0; i < 2*N-1; i++ ){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
  //ここまで
  
  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N; j++ ){
      X[i][j] = FALSE;
    }
  }

  scanf("%d",&k);
  for( i = 0 ; i < k ; i++ ){
    scanf("%d%d",&r,&c);// 0から始まるr行 c列目にクイーンが存在する
    X[r][c] = TRUE;
  }
  putqueen(0);

  return 0;
}
  
  



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for(ll i = 0 ; i<n ; i++) 
#define rep2(n) for(ll j=0 ; j<n ; ++j )
#define repd(n) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007
#define pii pair<ll,ll>
#define vll vector<ll>
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 0x3f3f3f3f
#define sz(a) a.size() 
#define all(a) a.begin(),a.end()
#define M 998244353
#define limit 100000000

int main() {

  ll a,b; cin >> a>>b;
  ll c = a%b; 
  if(abs(c-b)<c) cout << abs(c-b);
  else cout << c;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(Q)]
ac_sum = [0] * (N + 1)
s = list(s)
i = 0
while i < N:
    if s[i : i + 2] == ['A', 'C']:
        #print(i)
        ac_sum[i + 2] += ac_sum[i] + 1
        ac_sum[i + 1] += ac_sum[i] + 1
        i += 2
    else:
        ac_sum[i + 1] = ac_sum[i]
        i += 1
for l, r in lr:
    l -= 1
    r -= 1
    print(ac_sum[r] - ac_sum[l])

Measured memory_bytes: 33036
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String middle = s.substring(1, s.length() - 1);
        System.out.println(s.substring(0, 1) + middle.length() + s.substring(s.length() - 1));
    }

}


Measured memory_bytes: 22996
import sys

N = int(input())
b = [int(s) for s in input().split()]

revans = []
for _ in range(N):
    for i in reversed(range(len(b))):
        if b[i] == i + 1:
            revans.append(i + 1)
            b.pop(i)
            break
    else:
        print(-1)
        sys.exit()

for v in reversed(revans):
    print(v)


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep3(i, k, n) for (int i = k; i < n; i++)
#define sz(s) (int)s.size()
#define F first
#define S second
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) {
    for (auto &vi: vec) os << vi << " "; return os;
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    vector<int> cnt_x(n), cnt_y(n);
    for (int i = 0; i < n; i++) {
        int xx, yy; cin >> xx >> yy; xx--, yy--;
        cnt_x[xx]++; cnt_y[yy]++;
        a[xx] = yy;
    }
    for (int i = 0; i < n; i++) {
        if (cnt_x[i] > 1 || cnt_y[i] > 1) return !(cout << -1 << endl);
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        while (a[i] != i) {
            swap(a[i], a[a[i]]);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3860
import heapq as hq

INF = 10**16
OKANE = 10**15



N, M, S, T = map(int, input().split())

graph_yen = [[] for _ in range(N+1)]
graph_snk = [[] for _ in range(N+1)]


for i in range(M):
    u, v, a, b = map(int, input().split())
    graph_yen[u].append((a, v))
    graph_yen[v].append((a, u))
    graph_snk[u].append((b, v))
    graph_snk[v].append((b, u))

def dijkstra(st, graph, N):
    dist = [INF]*(N+1)
    hasVisited = [False]*(N+1)
    hasVisited[0] = True
    
    dist[st] = 0
    hasVisited[st] = True
    
    # startをpushする
    cand_list = []
    hq.heappush(cand_list, (0,st))
    while len(cand_list) != 0:
        nex, node = hq.heappop(cand_list)
        if dist[node] < nex:
            continue

        for nb in graph[node]:
            if dist[nb[1]] > nex+nb[0]:
                dist[nb[1]] = nex+nb[0]
                hq.heappush(cand_list,(dist[nb[1]], nb[1]))
    
    return dist


dist_yen = dijkstra(S,graph_yen, N)
dist_snk = dijkstra(T,graph_snk, N)

del dist_yen[0]
del dist_snk[0]


min_list = [INF]*(N+1)
i = 0
for yen, snk in zip(dist_yen[::-1], dist_snk[::-1]):
    i+=1
    min_after_i = yen+snk
    min_list[i] = min(min_after_i,min_list[i-1])

del min_list[0]

for cost in min_list[::-1]:
    print(OKANE - cost)

Measured memory_bytes: 81452
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    public void solve() {
    	long X = nl();
    	long Y = nl();
    	long ans = 0;
    	while(X <= Y) {
    		X *= 2;
    		ans++;
    	}
    	out.println(ans);
    }
    static class PP{
    	public int key, val;
    	public PP(int key, int val) {
    		this.key = key;
    		this.val = val;
    	}
		public int getKey() {
			return key;
		}
		public void setKey(int key) {
			this.key = key;
		}
		public int getVal() {
			return val;
		}
		public void setVal(int val) {
			this.val = val;
		}
    }

    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] ndii(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

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

                                  int n = ob.nextInt();
                                  for(int i=1;i<1000;i++)
                                  {
                                  if(i*1000==n){System.out.println(0);break;}
                                  if((i*1000)>n)
                                  {
                                                   System.out.println((int)Math.abs((i*1000)-n));
                                                   break;
                                  }
                                  }
                              //    System.out.println((int)Math.abs(n-1000));
                 }

}


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

int main(){
  int i, j, k;
  int min, mina, minb;
  int A, B, M;
  scanf("%d %d %d", &A, &B, &M);

  int a[A];
  int b[B];
  int c[M];
  int x[M];
  int y[M];
  int waribiki[M];

  for(i=0; i<A; i++)scanf("%d", &a[i]);
  for(i=0; i<B; i++)scanf("%d", &b[i]);
  for(i=0; i<M; i++)scanf("%d %d %d", &x[i], &y[i], &c[i]);

  min = 1000000;
  for(i=0; i<A; i++){
    if(a[i] < min)min = a[i];
  }
  mina = min;
  min = 1000000;
  for(i=0; i<B; i++){
    if(b[i] < min)min = b[i];
  }
  minb = min;
  min = mina + minb;

  for(i=0; i<M; i++){
    waribiki[i] = a[x[i]-1] + b[y[i]-1] - c[i];
  }

  for(i=0; i<M; i++){
    if(waribiki[i] < min)min = waribiki[i];
  }

  printf("%d\n", min);
  return 0;
}


Measured memory_bytes: 2560
import java.util.*;
class Main{
public static void main(String[] $){
Scanner s=new Scanner(System.in);
String c=s.next();
long a=0,w=0;
for(int i=0;i<c.length();i++) if(c.charAt(i)=='W') a+=i-w++;
System.out.print(a);
}
}

Measured memory_bytes: 26800
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    B = tuple(map(int, input().split()))

    surplus_scores = []
    sum_lack_score = 0
    ans = 0
    for a, b in zip(A, B):
        if a > b:
            surplus_scores.append(a - b)
        elif a < b:
            sum_lack_score += b - a
            ans += 1

    if sum_lack_score > 0:
        surplus_scores.sort(reverse=True)
        pass_exam = False
        for i, score in enumerate(surplus_scores):
            sum_lack_score -= score
            if sum_lack_score <= 0:
                ans += (i + 1)
                pass_exam = True
                break
        if not pass_exam:
            ans = -1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 18760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x, y, z;
		x = sc.nextInt();
		y = sc.nextInt();
		z = sc.nextInt();
		sc.close();
		int ans = (x - z) / (y + z);
		System.out.println(ans);
	}

}


Measured memory_bytes: 22868
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    a,b,c,d = i_map()

    ans = [a*c,a*d,b*c,b*d]

    print(max(ans))






if __name__=="__main__":
    main()


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

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

int main(int argc, char const *argv[])
{
	int h,w;
	cin>>h>>w;
	int memo[h][w];
	char a;
	queue<pair<int,int>> que;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin>>a;
			if (a=='.')
			{
				memo[i][j]=-1;
			}
			else
			{
				memo[i][j]=0;
				que.push(make_pair(i,j));
			}
		}
	}
	int ans=0;
	while (que.size()>0)
	{
		auto now=que.front();que.pop();
		for (int i = 0; i < 4; ++i)
		{
			int nx=now.first+dx[i],ny=now.second+dy[i];
			if (nx<0||h<=nx||ny<0||w<=ny)
			{
				continue;
			}
			if (memo[nx][ny]==-1)
			{
				memo[nx][ny]=memo[now.first][now.second]+1;
				ans=max(ans,memo[nx][ny]);
				que.push(make_pair(nx,ny));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12304
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    int  a[5],ans=0;
    int m=10;

    for(int i=0;i<5;i++){
        cin>>a[i];
        if(a[i]%10>0){
            m=min(m,a[i]%10);
        }
        ans+=(a[i]+9)/10*10;
    }
    if(m==10){
        m=0;
    }else{
        ans-=10;
    }
    cout << ans + m<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	ll n;
	cin >> n;

	vector<ll> a(n);

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

	vector<ll> bi(n);
	for(int i = 0; i < n; i++){
		bi[i] = a[i] - (i + 1);
	}

	sort(bi.begin(), bi.end());

	ll b;
	if(n % 2 == 0){
		b = (bi[n / 2 - 1] + bi[n / 2]) / 2;
	} else {
		b = bi[n / 2];
	}

	ll ans = 0;
	for(int i = 0; i < n; i++){
		ans += abs(bi[i] - b);
	}

	cout << ans << endl;
}



Measured memory_bytes: 3328
//Author : Vipul Sharma
 
// LIBRARIES

#include<iostream>
#include<set>
#include<algorithm>
#include<map>
#include <bits/stdc++.h>
 
// MACROS
#define ll long long int
#define ld long double
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rev(i,b,a) for(ll i=b-1;i>=a;i--)
#define eqrep(i,b) for(ll i=1;i<=b;i++)
#define itrep(at) for (auto it = at.begin(); it != at.end(); it++)
#define ld long double
#define pb push_back
#define eb emplace_back
#define w(t) while (t--)
#define booster                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define deb1(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;
#define deb4(x, y, z, w) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << "\t" << #w << " : " << w << endl;
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define deb6(a, b, c, d, e, f) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
using namespace std;
long long cost = 1e18;
 
 
 
int main()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	booster;
	ll n,cnt=0;
	cin>>n;
	vector<ll>a(n);
	rep(i,0,n) cin>>a[i];
	sort(a.begin(),a.end());
	for(ll i=n-1;i>=1;i--)
	{
		ll l=0,r=i-1;
		while(l<r)
		{
			if(a[l]+a[r]>a[i])
			{
				cnt+=r-l;
				r--;
			}
			else l++;
		}
	}
	cout<<cnt<<endl;

	//cout<<umap.size()<<endl;
	return 0;
}

Measured memory_bytes: 3596
package main

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

func min64(a,b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max64(a,b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func answer(n int64) int64 {
	if (n < 10) {
		return n;
	}
	if (n < 100) {
		return 9;
	}
	if (n < 1000) {
		return (n - 99)  +  9;
	}
	if (n < 10000) {
		return 900 +  9;
	}
	if (n < 100000) {
		return (n - 9999) + 900 +  9;
	}
	return 90000 + 900 + 9;
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		text := scanner.Text()
		N, _ := strconv.ParseInt(text, 10, 0)


		result := answer(N);
		fmt.Printf("%d", result)
	}
}


Measured memory_bytes: 640
n = int(input())
B = list(map(int, input().split()))

#print(len(B))
ans = []
while B:
    for i in reversed(range(len(B))):
        if B[i] == i+1:
            ans.append(B[i])
            del B[i]
            break
    else:
        print(-1)
        exit()
for i in reversed(range(len(ans))):
    print(ans[i])

Measured memory_bytes: 38640
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <bitset>
#define ull unsigned long long
#define lf long float
#define MAX 2e9
#define MIN -2e9
#define PI 3.14159265
#define fst first
#define scd second
#define mp make_pair
#define forn(i, x) for(int i = 0; i < x; i++)
#define pb push_back
using namespace std;
 
set<pair<int, int> > vertex;
set<pair<int, int> > ans;
 
void deicstja(int st, int ed, vector<vector<pair<int, int> > > &g) {
   vector<int> cost(g.size(), 1e9);
   vector<int> way(g.size(), -1);
   set<pair<int, int> > q;
   q.insert(mp(0, st));
   cost[st] = 0;
   while(!q.empty()) {
      int v = q.begin()->second;
      q.erase(q.begin());
      for(int i = 0; i < g[v].size(); i++) {
         int to = g[v][i].first;
         int cst = g[v][i].second;
         if(cost[v] + cst < cost[to]) {
            q.erase(mp(cost[to], to));
            cost[to] = cost[v] + cst;
            q.insert(mp(cost[to], to));
            way[to] = v;
         }
      }
   }
  int p = ed;
   while(p != -1) {
      int per = way[p];
      if(per == -1) {
         break;
      }
      ans.insert(mp(min(p, per), max(p, per)));
      p = per;
   }
}
 
int main(){
   int n, m;
   cin >> n >> m;
   vector< vector< pair<int, int> > > g(n);
   for(int i = 0; i < m; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      a--;
      b--;
      g[a].pb(mp(b, c));
      g[b].pb(mp(a, c));
      vertex.insert(mp(min(a, b), max(a, b)));
   }
   for(int i = 0; i < n - 1; i++) {
      for(int j = i + 1; j < n; j++) {
        // cout << "!!!!!!!!" <<  i << " " << j << "\n";
         deicstja(i, j, g);
      }
   }
   cout << vertex.size() - ans.size();
   return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
typedef long long ll;

ll n,x[110],minm = 9999999999;

int pot (ll q,ll w){
	ll qw = q;
	q = 1;
	for (int i = 0; i<w; i++)
		q *= qw;
	return q;
}

int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

cin >> n;

for (int i = 1; i<=n; i++)
	cin >> x[i];
	
for (int i = 1; i<= 100; i++){
	ll zbr = 0;
	for (int k = 1; k<=n; k++){
		zbr += (x[k]*x[k]) - (2*x[k]*i) + (i*i);
	}
	if (zbr < minm)
		minm = zbr;
}

cout << minm;

return 0;
}



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

import collections as col

x_e=[]
x_o=[]

for i in range(n):
	if i%2==0:
		x_e.append(x[i])
	else:
		x_o.append(x[i])

x_e_c=col.Counter(x_e).most_common()    
x_o_c=col.Counter(x_o).most_common()

if x_e_c[0][1]>x_o_c[0][1]:
	fst=x_e_c
	snd=x_o_c
else:
	if x_e_c[0][1]<x_o_c[0][1]:	
		fst=x_o_c
		snd=x_e_c
	else:
		if len(x_e_c)>1 and len(x_o_c)>1:
			if x_e_c[1][1]<=x_o_c[1][1]:	
				fst=x_e_c
				snd=x_o_c
			else:
				fst=x_o_c
				snd=x_e_c
		else:
			fst=x_o_c
			snd=x_e_c

res=0

res+=n//2-fst[0][1]
if fst[0][0]!=snd[0][0]:
	res+=n//2-snd[0][1]
else:
	if len(snd)>1:
		res+=n//2-snd[1][1]
	else:
		res+=n//2

print(res)

Measured memory_bytes: 21084
#define ENABLE_LL
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);

const int N = 100005;
int a[N];
int n, m, v, p;

void init() {
    scanf(IIII,&n,&m,&v,&p);
    rep (i,n) scanf(I,&a[i]);
    sort(a, a+n); 
    rep (i,n) ses(a[i]); see("");
}

int b[N];
bool jury(int u) {
    rep (i,n) b[i] = a[i];
    b[u] += m;
    sort(b, b+n);
    int id = 0;
    rep (i,n) if (b[i] == a[u] + m) id = i;
    if (n-id > p) return 0;
    int sp = (p-1) * m;
    rep (i,n-p) {
        sp += min(m, b[id] - b[i]);
    }   
    if (sp >= m*(v-1)) return 1;
    return 0;
}

void solve() {
    int l=0, r=n-1;
    while (l<r) {
        int m = (l+r) / 2;
        ses(m);see(jury(m));
        if (jury(m)) {
            r = m;
        } else {
            l = m+1;
        }
    }
    printf(IN,n - l);
}

#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


Measured memory_bytes: 1792
menus = list(map(lambda x: (x - x % 10, x % 10), [int(input()) for _ in range(5)]))
tens = [ i[0] for i in menus ]
mods = sorted(list(filter(lambda x: x != 0, [ i[1] for i in menus])))
print(sum(tens) + ((mods[0]+ 10*(len(mods) - 1))if len(mods) > 0 else 0))

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    string s;
    cin >> n >> s;

    int left = 0, right = 0;
    rep(i,n){
        if(s[i]=='('){
            right++;
        }else if(s[i]== ')'){
            left++;
            if(right>0)
                right--, left--;
        }

    }
    for (int i = 0; i < left; i++)
        cout << '(';
    cout << s;
    for (int i = 0; i < right;i++)
        cout << ')';
    cout << endl;
    return 0;
}

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

using namespace std;
int n , k;
ll dp[100005];
ll a[100005];
int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    for (int i=0;i<n;i++)cin >> a[i];
    for (int i=1;i<n;i++)dp[i] = 1e18;
    k = 2;
    for (int i=1;i<n;i++)
    {
        for (int j=1;j<=k;j++)
        {
            if (i - j >= 0)
            {
                dp[i] = min(dp[i] , dp[i - j] + abs(a[i] - a[i - j]));
            }
        }
    }
    cout << dp[n-1] << endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int ans = 0;
    cin >> n;
    int p[n];
    for(int i = 0;i < n;i++)cin >> p[i];
    for(int i = 1;i < n-1;i++){
        if(p[i-1] < p[i] && p[i] < p[i+1])ans++;
        else if(p[i-1] > p[i] && p[i] > p[i+1])ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int o,n,k,i,j;
    int key;
    int A[110];
    scanf("%d",&n);
    for(i=1; i<=n; i++)
        scanf("%d",&A[i]);

    for(i=1; i<=n; i++)
    {
        key = A[i];
        j = i-1;
        while(j>0 && A[j]>key)
        {
            A[j+1]=A[j];
            j--;
        }
        A[j+1] = key;
        for(k=1; k<=n; k++)
        {
            if(k == n)
                printf("%d\n",A[k]);
            else
                printf("%d ",A[k]);
        }
    }

    return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <cstdlib>
#include <vector>
#include <map>

using namespace std;

long long comb(long long a, long long b) {
    b = min(a - b, b);
    long long r = 1;
    for (long long i = 1; i <= b; i++)
    r = r * (a - b + i) / i;
    return r;
}

int main()
{
    int n, m;
    long long r, tmp, N, answer;
    answer = 0;
    cin >> n >> m;
    
    vector<long long> a(n);
    vector<long long> mod_key;
    vector<long long> sum(n+1);
    map<long long, long long> mod;
    
    // data input
    for (int i=0; i<n+1; ++i){
        if(i != n){
            cin >> a[i];
        }
        if(i == 0){
            sum[0] = 0;
        }
        else {
            sum[i] = sum[i-1] + a[i-1];
        }
        // cout << sum[i] << endl;
    }
    for (int i=0; i<n+1; ++i){
        r = (long)(sum[i] % (long)m);
        if(mod.find(r) == mod.end()){
            mod.insert(make_pair(r, 1));
            mod_key.push_back(r);
        }
        else {
            tmp = mod.at(r);
            mod.erase(r);
            mod.insert(make_pair(r, tmp+1));
        }
    }
    for (auto itr=mod_key.begin(); itr != mod_key.end(); ++itr){
        N = mod.at(*itr);
        if(N >= 2){
            answer += comb(N, 2);
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 6264
#include <stdio.h>
#include <string.h>

#define MAX 1046527
#define NIL (-1)
#define L 14
char dict[MAX][L];

int getChar(char ch) {
    if(ch == 'A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]) {
    int len = strlen(str);
    long long sum = 0, p = 1, i;
    for(i=0; i<len; ++i) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) {return key%MAX;}
int h2(int key) {return 1+(key%(MAX-1));}

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for(i=0; ; ++i) {
        h = (h1(key)+i*h2(key))%MAX;
        if(strcmp(dict[h], str) == 0) return 1;
        else if(strlen(dict[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for(i=0; ; ++i) {
        h = (h1(key)+i*h2(key))%MAX;
        if(strcmp(dict[h], str) == 0) return 1;
        else if(strlen(dict[h]) == 0) {
            strcpy(dict[h], str);
            return 0;
        }
    }
    return 0;
}

int main()
{
     

    int i, n, h;
    char str[L], com[9];
    for(i=0; i<MAX; ++i) dict[i][0] = '\0';
    scanf("%d", &n);
    
    for(i=0; i<n; ++i) {
        scanf("%s %s", com, str);
        if(com[0] == 'i') insert(str);
        else {
            if(find(str)) printf("yes\n");
            else printf("no\n");
        }
    }

    return 0;
}



Measured memory_bytes: 16044
import bisect,collections,copy,heapq,itertools,math,numpy,string,random
import sys
from decimal import Decimal
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

D = I()
C = LI()
s = [LI() for _ in range(D)]

T = [1 for _ in range(D)]
#print(D,C)
#print(s)
#print(T)
def last(d,i):
    T_d = T[:d]
    n = [j for j, x in enumerate(T_d,1) if x == i]
    if n:
        #print(T_d,i,"n=",n)
        return max(n)
    else:
        return 0
        
def Score(T):
    score = 0
    for d in range(1,D+1):
        sum_c = 0
        for i in range(1,26+1):
            sum_c += C[i-1] * (d -last(d,i))
        score += s[d-1][T[d-1]-1] - sum_c
        #print(score)
    score_d = max(10**6 + score,0)
    #print(score_d)
    return score_d

score_0 = Score(T)
for j in range(10):
    T_new = [random.randint(1,26) if i%36 == 0 else T[i] for i in range(D)]
    if Score(T_new) > score_0:
        T = T_new
        score_0 = Score(T_new)
        
for t in T:
    print(t)

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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {//x^n
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    vector<int> vec(5);
    rep(i, 5) cin >> vec[i];
    int ans = 0;
    rep(i, 5) {
        if (vec[i] == 0) ans = i + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
N=int(input())
S=input()
T='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
S2=''
for i in range(len(S)):
    n=T.find(S[i])
    if n+N<=25:
        S2=S2+T[n+N]
    else:
        S2=S2+T[n+N-26]
print(S2)
        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
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 long long INF = 1LL << 60;

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

    if(S=="SSS")cout<<0<<endl;
    if(S=="RRS")cout<<2<<endl;
    if(S=="RSR")cout<<1<<endl;
    if(S=="SRR")cout<<2<<endl;
    if(S=="SSR")cout<<1<<endl;
    if(S=="RRR")cout<<3<<endl;
if(S=="SRS")cout<<1<<endl;
if(S=="RSS")cout<<1<<endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        string s;
        string t;
        cin >> s >> t;

        ll ns = s.size(), nt = t.size();

        unordered_map<char, vector<ll>> mp;
        rep(i, ns) {
            mp[s[i]].eb(i);
        }
        ll rev = 0;
        ll c = 0;
        ll now = -1;
        rep(i, nt) {
            if (mp[t[i]].empty()) {
                cout << -1 << endl;
                return 0;
            }

            auto itr = upper_bound(all(mp[t[i]]), now);
            if (itr == mp[t[i]].end()) {
                rev++;
                now = mp[t[i]][0];
                c = now + 1;
            } else {
                now = *itr;
                c = now + 1;
            }
        }
        cout << rev * ns + c << endl;
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
#include <stack>
#include <cmath>
#include <cstring>
#include <climits>
#include <iomanip>
using namespace std;

#define FORN(i, j, k) for(int i=j;i<k;i++)
#define FORR(i, j, k) for(int i=j;i>=k;i--)
#define REP(i, n) FORN(i, 0, n)
#define int long long
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define endl '\n'

const int MODO = 1e+9 + 7;
const int MAX = 1e+5 + 5;

int n;

void solve(){
	double p[n];
	REP(i,n){
		cin >> p[i];
	}
	double dp[n+1][n+1];
	dp[0][0] = 1;
	FORN(i, 1, n+1){
		dp[0][i] = 0;
	}
	
	FORN(i, 1, n+1){
		dp[i][0] = dp[i-1][0]*(1-p[i-1]);
	}
	
	FORN(i, 1, n+1){
		FORN(j, 1, n+1){
			dp[i][j] = dp[i-1][j-1]*p[i-1];
			dp[i][j] += dp[i-1][j]*(1-p[i-1]);
		}
	}
	
	double res=0;
	FORN(i, 1, n+1){
		int t=n-i;
		if(i>t){
			res+=dp[n][i];
		}
	}
	
	cout << std::setprecision(10 ) << res << endl;  
	return;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	solve();
	return 0;
}


Measured memory_bytes: 74080
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
namespace Solve
{
	void work()
	{
		char s[10];
		scanf("%s",s);
		if(strcmp(s,"RRR")==0) printf("3\n");
		else if(strcmp(s,"RRS")==0) printf("2\n");
		else if(strcmp(s,"RSR")==0) printf("1\n");
		else if(strcmp(s,"RSS")==0) printf("1\n");
		else if(strcmp(s,"SRR")==0) printf("2\n");
		else if(strcmp(s,"SRS")==0) printf("1\n");
		else if(strcmp(s,"SSR")==0) printf("1\n");
		else if(strcmp(s,"SSS")==0) printf("0\n");
		return;
	}
}
int main()
{
	#ifdef LOCAL
	freopen("00test.in","r",stdin);
	freopen("00test.out","w",stdout);
	#endif
	Solve::work(); 
	return 0;
}

Measured memory_bytes: 3756
#include <iostream>   
#include <cstdlib>    

using std::cout;      
using std::endl;      
using std::cin;       

int main(){
  int n,q;  cin >> n;
  int lin_s[n];       
  for(int i=0;i<n;i++)    cin >> lin_s[i];  

  cin >> q;
  int lin_t[q];
  for(int i=0;i<q;i++)
    cin >> lin_t[i];

  int target, cnt=0;
  for(int i=0;i<q;i++){
    target=lin_t[i];
    for(int j=0;j<n;j++){
      if(target==lin_s[j]) {
        cnt++;
        break;
      }
    }
  }
  cout << cnt << endl;
}


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

namespace ConsoleApplication36
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            string CurrentS = "";
            int Count = 0;
            for (int i = N; 0 < i; i--)
            {
                if (CurrentS == S.Substring(i - 1, 1))
                {

                }
                else
                    Count++;

                CurrentS = S.Substring(i - 1, 1);
            }

            Console.WriteLine(Count);
        }
    }
}


Measured memory_bytes: 17376