akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    vector<int> v(3, 0), cnt(3, 0);
    int N, M;
    cin >> N >> M;
    v[3 - N] = 1;
    if (N == 1) v[2] = 0;
    int d, n;
    for (int i = 0; i < M; i++) {
        cin >> d >> n;
        int ind = 3 - N + d - 1;
        if (cnt[ind] > 0 && v[ind] != n) {
            cout << -1 << '\n';
            return 0;
        }
        else {
            cnt[ind]++;
            v[ind] = n;
        }
    }
    int ret = 0;
    for (int i = 0; i < 3; i++) {
        ret += pow(10, 2 - i) * v[i];
    }
    string retS = to_string(ret);
    if (retS.size() != N) {
        cout << -1 << '\n';
        return 0;
    }
    else {
        cout << retS << '\n';
    }
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,sum=0;
    cin>>n;
    int T[50];
    for (int i=0;i<n;i++)
        cin>>T[i];
    for (int i=0;i<n-1;i++)
    {
        for (int j=i+1;j<n;j++)
        {
            sum=sum+T[i]*T[j];
        }

    }
    cout<< sum;

    return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < w+2; i++) cout << '#';
  cout << endl;
  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;
    cout << '#' + s + '#' << endl;
  }
  for (int i = 0; i < w+2; i++) cout << '#';
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
char a[300010];
int w[300010],e[300010];
int ans=0x7fffffff;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<=n;i++)
	{
		scanf("%c",&a[i]);
		w[0]=e[0]=0;
		if(a[i]=='W') w[i]=w[i-1]+1,e[i]=e[i-1];
		else e[i]=e[i-1]+1,w[i]=w[i-1];
	}
	for(int i=1;i<=n;i++)
		ans=min(ans,w[i-1]+e[n]-e[i]);
	printf("%d",ans);
	return 0;
}

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

int main(){
    int X;
    cin >> X;
    int ans;
    if(400<=X&&X<600){
        ans = 8;
    }
    if(600<=X&&X<800){
        ans = 7;
    }
    if(800<=X&&X<1000){
        ans = 6;
    }
    if(1000<=X&&X<1200){
        ans = 5;
    }
    if(1200<=X&&X<1400){
        ans = 4;
    }
    if(1400<=X&&X<1600){
        ans = 3;
    }
    if(1600<=X&&X<1800){
        ans = 2;
    }
    if(1800<=X&&X<2000){
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K, C = MAP()
S = input()

L = [0] * K
cur = 0
idx = 0
while idx < K:
    if S[cur] == 'o':
        L[idx] = cur
        idx += 1
        cur += C + 1
    else:
        cur += 1
R = [0] * K
cur = N - 1
idx = K - 1
while idx >= 0:
    if S[cur] == 'o':
        R[idx] = cur
        idx -= 1
        cur -= C + 1
    else:
        cur -= 1

ans = []
for i in range(K):
    if L[i] == R[i]:
        ans.append(L[i])
[print(a+1) for a in ans]


Measured memory_bytes: 23820
from collections import deque


def read_input():
    n = int(input())
    edges = {i: [] for i in range(n)}
    edge_list = []
    for _ in range(n - 1):
        a, b = map(int, input().split())
        edge_list.append((a - 1, b - 1))
        edges[a - 1].append(b - 1)
        edges[b - 1].append(a - 1)

    return n, edges, edge_list


def submit():
    n, edges, edge_list = read_input()

    # node 0からスタートし、bfsで色を塗っていく
    # あるnode xについて、現在のcolor_maxのうち、自身にたどり着いた色以外を用いて、
    # 探索をすすめる
    curr_color_max = -1
    color = {}
    q = deque()
    q.appendleft((0, 0))

    while len(q):
        curr, from_color = q.pop()
        color_count = 1
        for e in edges[curr]:
            key = (min(curr, e), max(curr, e))
            if key in color.keys():
                continue
            else:
                if color_count == from_color:
                    color_count += 1
                if color_count > curr_color_max:
                    curr_color_max = color_count     
                color[key] = color_count
                q.appendleft((e, color_count))
                color_count += 1

    print(curr_color_max)
    for e in edge_list:
        print(color[e])


if __name__ == "__main__":
    submit()    

Measured memory_bytes: 62504
from scipy.special import comb
mod = 10**9 + 7
N, K = map(int,input().split())
for i in range(1,K+1):
    a = K-i
    b = i-1
    c = N-(i-1)-K
    d = i
    print(comb(a+b,b,exact=True)*comb(c+d,d,exact=True)%mod)


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
    vector<int> num(3);
    int k = 0;
    cin >> num[0] >> num[1] >> num[2] >> k;
    sort(num.begin(), num.end());
    int max = num[2];
    REP(i, k)
    {
        max *= 2;
    }

    COUT(num[0] + num[1] + max);


    return 0;
}

Measured memory_bytes: 256
#

import sys
input=sys.stdin.readline

def main():
    N,A,B=map(int,input().split())
    if N%(A+B)<=A:
        print(A*(N//(A+B))+N%(A+B))
    else:
        print(A*(N//(A+B))+A)
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main(int argc, char** argv)
{
	int n, i, i_max;
	int a, first=0, second=0;
	
	scanf("%d", &n);
	for(i=0;i<n;++i){
		scanf("%d", &a);
		if(a > first){
			second = first;
			first = a;
			i_max = i;
		} else if(a > second){
			second = a;
		}
	}
	for(i=0;i<n;++i){
		if(i!=i_max){
			printf("%d\n", first);
		} else {
			printf("%d\n", second);
		}
	}
	return 0;
}


Measured memory_bytes: 1536
from itertools import groupby
S=input()
T=groupby(S)
s=0
total=0
keys=[]
groups=[]
for key,group in T:
    keys.append(key)
    groups.append(len(list(group)))

if keys[0]==">":
    total+=sum([i for i in range(groups[0]+1)])
if keys[-1]=="<":
    total+=sum([i for i in range(groups[-1]+1)])
for i in range(len(keys)-1):
    if keys[i]=="<":
        if groups[i]<=groups[i+1]:
            total+=sum([j for j in range(groups[i])])
            total+=sum([j for j in range(groups[i+1]+1)])
        else:
            total+=sum([k for k in range(groups[i]+1)])
            total+=sum([k for k in range(groups[i+1])])
print(total)

Measured memory_bytes: 23620
#include<stdio.h>
#include<math.h>
int main(void)
{
    int n;
    int num=0;
    int x[1000];
    int y[1000];
    double p1ans;
    double p2ans;
    double p3ans;
    double p4ans;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&y[i]);
    }
    for(int i=0;i<n;i++){
        p1ans+=fabs(x[i]-y[i]);
    }
    for(int i=0;i<n;i++){
        p2ans+=pow(fabs(x[i]-y[i]),2);
    }
    p2ans=sqrt(p2ans);
    for(int i=0;i<n;i++){
        p3ans+=pow(fabs(x[i]-y[i]),3);
    }
    p3ans=pow(p3ans,1.0/3.0);
    for(int i=0;i<n;i++){
        num=fabs(x[i]-y[i]);
        if(num>p4ans){
            p4ans=num;
        }
    }
    printf("%.8f\n%.8f\n%.8f\n%.8f\n",p1ans,p2ans,p3ans,p4ans);
    return 0;
}


Measured memory_bytes: 2104
"""memo:
for Cx, Cy in zip(range(0, 101), range(0, 101))
hi + abs(Xi-Cx)+abs(Yi-Cy) == hj + abs(Xj-Cx)+abs(Yj-Cy)
in All points

Complexity: O(N^2) <= 10000
"""
import sys
from itertools import product

input = sys.stdin.readline

N = int(input())
xyh_list = [tuple(map(int, input().split())) for _ in range(N)]

for Cx, Cy in product(range(101), range(101)):
    last_H = None
    valid_flag = True
    counter = 0
    h_max = 0
    for i, (xi, yi, hi) in enumerate(xyh_list):
        if hi == 0:
            continue
        currnt_H = hi + abs(xi - Cx) + abs(yi - Cy)
        counter += 1
        if last_H is None:
            last_H = currnt_H
        elif last_H != currnt_H:
            valid_flag = False
            break

    if valid_flag:
        if counter != 1:
            print(Cx, Cy, last_H)
        else:
            for xi, yi, hi in xyh_list:
                if hi == 0:
                    continue
                print(xi, yi, hi)
        exit()


Measured memory_bytes: 3064
import sys

def isEmpty(S):
  if len(S) == 0:
    return True
  
def isFull(S):
  if len(S) >= 101:
    return True

def push(x):
  if isFull(S):
    print 'Error'
  S.append(x)
  
def pop(top):
  if isEmpty(S):
    print 'error'
  k = S[top]
  S.pop()
  return k

S = []
top = -1

x = sys.stdin.readline().strip()
x_list = x.split(" ")

for i in range(0, len(x_list)):
  if x_list[i] == '*':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(a * b)
    top += 1
    
  elif x_list[i] == '+':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(a + b)
    top += 1
    
  elif x_list[i] == '-':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(b - a)
    top += 1
    
  else:
    push(x_list[i])
    top += 1
    
a = int(pop(top))
print a

Measured memory_bytes: 6372
import sys
import io, os
#input = sys.stdin.buffer.readline
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

q = int(input())

import heapq
L = []
R = []
heapq.heapify(L)
heapq.heapify(R)

B = 0

for i in range(q):
    query = list(map(int, input().split()))
    if query[0] == 1:
        a, b = query[1], query[2]
        B += b
        heapq.heappush(L, -a)
        heapq.heappush(R, a)
        if -L[0] > R[0]:
            l = -heapq.heappop(L)
            r = heapq.heappop(R)
            B += l-r
            heapq.heappush(L, -r)
            heapq.heappush(R, l)
    else:
        print(-L[0], B)

Measured memory_bytes: 29828
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int m  = sc.nextInt();
    int n  = sc.nextInt();
    int q  = sc.nextInt();
    int[] a = new int[q];
    int[] b = new int[q];
    int[] c = new int[q];
    int[] d = new int[q];
    int max_score = 0;

    for(int i=0; i<q; i++){
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
      c[i] = sc.nextInt();
      d[i] = sc.nextInt();
    }

    for(int i=0; i<(1<<n+m-1);i++){
      //System.out.println(i);
      int[] bitbit = new int[m];
      int bit_count = 0;
      int ball_number = 1;
      int g = 0;

      for(int j=0; j<n+m-1; j++){
        if((1&i>>j)==1){
          bit_count += 1;
        }
      }

      if(bit_count==m){
        for(int j=0; j<n+m-1; j++){
          if((1&i>>j)==1){
            bitbit[g] = ball_number;
            //System.out.println("NONO");
            g += 1;
          }else{
            ball_number += 1;
            //System.out.println("**");
          }
        }
         // for(int j:bitbit){
         //   System.out.print(j);
         // }


        int score = 0;
        for(int j=0; j<q; j++){
          if(bitbit[b[j]-1]-bitbit[a[j]-1] == c[j]){
            score += d[j];

          }
        }
        if(score>max_score){
          max_score = score;
        }

      }


      //System.out.println(i + ":" + bit_count);
      //System.out.println("max:"+max_score);

    }
      System.out.println(max_score);

  }
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
    FIO;
    int n, d;
    cin >> n >> d;

    int cnt = 0;
    for(int i = 0; i < n; ++i)
    {
        int x, y; cin >> x >> y;
        double q = 1.0 * sqrt(x * x + y * y);

        if(q <= d)
            ++cnt;
    }

    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <typeinfo>

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REP1(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define all(x) (x).begin(),(x).end()
*/

using namespace std;

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

    if (r < 1200)
        cout << "ABC";
    else if (r < 2800)
        cout << "ARC";
    else
        cout << "AGC";
}

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

typedef long long ll;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1e10;

int main(int argc, char* argv[])
{
  int N;
  std::cin >> N;
  std::vector< std::vector<ll> > vopen(N, std::vector<ll>(10, 0LL));
  for (ll y = 0; y < N; y++) {
    for (ll x = 0; x < 10; x++) {
      std::cin >> vopen[y][x];
    }
  }
  std::vector< std::vector<ll> > vp(N, std::vector<ll>(11, 0LL));
  for (ll y = 0; y < N; y++) {
    for (ll x = 0; x < 11; x++) {
      std::cin >> vp[y][x];
    }
  }

  ll ans = -INF;
  for (int S = 1; S < std::pow(2, 10); S++) {
    ll benefit = 0;
    for (int y = 0; y < N; y++) {
      int cnt = 0;
      for (int k = 0; k < 10; k++) {
	int x = S >> k;
	if (x & 1 && vopen[y][k] == 1) {
	  cnt++;
	}
      }
      benefit += vp[y][cnt];
    }
    ans = std::max(ans, benefit);
  }

  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

void print(string str, int a, int b){
    for(int i=a; i<=b; i++){
        cout << str[i];
    }
    cout << endl;
}

string reverse(string str, int a, int b){
    string substr;
    substr = str.substr(a, b-a+1);
    int idx=substr.size()-1;
    for(int i=a; i<=b; i++){
        str[i]=substr[idx--];
    }
    return str;
}

string replace(string str, int a, int b, string p){
    int len = b - a + 1;
    str.replace(a, len, p);
    return str;
}


int main(){
    
    string str, query, p;
    int q, a, b;

    cin >> str;
    cin >> q;

    for(int i=0; i<q; i++){
        cin >> query >> a >> b;
        if(query=="print"){
            print(str, a, b);
        }else if(query=="reverse"){
            str = reverse(str, a, b);
        }else if(query=="replace"){
            cin >> p;
            str = replace(str, a, b, p);
        }
    }

    return 0;
}




Measured memory_bytes: 3204
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// 1行、2つ(複数)数字
		String[] ss0 = br.readLine().trim().split(" ", 0);
		long X = Long.parseLong(ss0[0]);
		long A = Long.parseLong(ss0[1]);
		long B = Long.parseLong(ss0[2]);

		if(A-B>=0){ System.out.println("delicious"); return; }
		if(B-A>X){ System.out.println("dangerous"); return; }

		System.out.println("safe"); return;
	}
	//-----------------------------------------------------------------
	// Debug.Print
	static void dp(String s) {
		System.out.println(s);
	}
	static void dp(StringBuilder s) { dp(s.toString()); }
	static void dp(int i) { dp(String.valueOf(i)); }
	static void dp(long i) { dp(String.valueOf(i)); }
}


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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < ll > vl;

const int MAXN = 3100;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 18;
const double EPS = 1e-9;
const double PI = 3.1415926535;

string s, t;
int dp[MAXN][MAXN];

string backtrack() {
    int i = s.size();
    int j = t.size();
    string ans = "";

    while(i != 0 && j != 0) {
        if(s[i - 1] == t[j - 1]) {
            ans += s[i - 1];
            i --; j --;
        }
        else if(dp[i][j] == dp[i - 1][j])
            i --;
        else if(dp[i][j] == dp[i][j - 1])
            j --;
    }

    reverse(ans.begin(), ans.end());
    return ans;
}

int main() {
    int sz, tz;

    cin >> s >> t;
    sz = s.size();
    tz = t.size();

    for(int i = 1; i <= sz; i++) {
        for(int j = 1; j <= tz; j++) {
            if(s[i - 1] == t[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    cout << backtrack() << endl;
    return 0;
}


Measured memory_bytes: 37120
#include "cstring"
#include "cstdio"
#include "vector"
#include "queue"
using namespace std;

const int maxn=11000;

struct edge{int to,d,c;};
edge edges[4100000];
int p;

vector<int>g[maxn];

int dis[maxn],vis[maxn],cos[maxn];
int n,m,sn;

void add(int u,int v,int d,int c)
{
	edges[++p].d=d;
	edges[p].to=v;
	edges[p].c=c;
	g[u].push_back(p);
}

int spfa(int s)
{
	memset(cos,0x3f3f3f3f,sizeof(cos));
	memset(dis,0x3f3f3f3f,sizeof(dis));
	memset(vis,0,sizeof(vis));
	
	queue<int>qn;
	qn.push(s);
	dis[s]=0;
	cos[s]=0;
	vis[s]=1;
	
	while(!qn.empty())
	{
		int nn=qn.front();qn.pop();
		vis[nn]=0;
		for(int i=0,d=g[nn].size();i<d;i++)
		{
			edge &e= edges[g[nn][i]];
			if(dis[e.to]>dis[nn]+e.d || ((dis[e.to]==dis[nn]+e.d) && cos[e.to]>e.c))
			{
				dis[e.to]=dis[nn]+e.d;
				cos[e.to]=e.c;
				
				if(!vis[e.to])
				{
					qn.push(e.to);
					vis[e.to]=1;
				}
			}
		}	
	}
	return 0;
}

int main()
{
	//freopen("q.txt","r",stdin);
	int u,v,d,c;
	while(~scanf("%d%d",&n,&m))
	{
		if(n==0 && m==0)break;
		for(int i=0;i<=n;i++)
			g[i].clear();
		p=0;
		for(int i=0;i<m;i++)
		{
			scanf("%d%d%d%d",&u,&v,&d,&c);
			add(u,v,d,c);
			add(v,u,d,c);
		}
		int ans=0;
		spfa(1);
		for(int i=1;i<=n;i++)
			ans+=cos[i];
		printf("%d\n",ans);
	}
	return 0;
} 


Measured memory_bytes: 4048
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    rep(i,3){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF (-1000)

void enqueue(int);
int dequeue();
void BFS(int);

int n;
int d[MAX];
int c[MAX];
int M[MAX][MAX];

int Q_tail=0;
int Q_head=0;
int Q[MAX];

int main(){
  int i=0,j=0;;
  int u;
  int k;
  int v;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  BFS(0);
  
  return 0;
}

void BFS(int s){
  int u=0;
  int v=0;
  int i=0;
  enqueue(s);
  for(i=0;i<n;i++){
    d[i]=INF;
  }
  d[s]=0;
  while(Q_tail!=Q_head){
    u=dequeue();
    for(v=0;v<n;v++){
      if(M[u][v]&&c[v]==WHITE){
	c[v]=GRAY;
	d[v]=d[u]+1;
	enqueue(v);
      }
      c[u]=BLACK;
    }
  }

  for(i=0;i<n;i++){
    printf("%d ",i+1);
    if(d[i]==INF) printf("-1\n");
    else printf("%d\n",d[i]);
  }
}

void enqueue(int s){
  Q[Q_tail]=s;
  if(Q_tail + 1 == n)
    Q_tail=0;
  else Q_tail++;
}

int dequeue(){
  int x;
  x=Q[Q_head];
  if(Q_head+1==n) Q_head=0;
  else Q_head++;
  return x;
}



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

template<class Abel> struct UnionFind {
  vector<int> par,rank;
  vector<Abel> diff_weight;

  UnionFind(int n = 1, Abel SUM_UNITY = 0) {init(n, SUM_UNITY);}

  void init(int n = 1, Abel SUM_UNITY = 0) {
    par.resize(n); rank.resize(n); diff_weight.resize(n);
    for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
  }

  int root(int x) {
    if (par[x] == x) {return x;}
    else {
      int r = root(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      return par[x] = r;
    }
  }

  Abel weight(int x) {root(x);   return diff_weight[x];}

  bool issame(int x, int y) {return root(x) == root(y);}

  bool merge(int x, int y, Abel w) {
    w += weight(x); w -= weight(y);
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y), w = -w;
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x;  diff_weight[y] = w;
    return true;
  }

  Abel diff(int x, int y) {return weight(y) - weight(x);}
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind<int> uf(N);
  for (int i = 0; i < M; ++i) {
    int l, r, d;  cin >> l >> r >> d; --l, --r;
    if (uf.issame(l, r)) {
      int diff = uf.diff(l, r);
      if (diff != d) {cout << "No" << endl;  return 0;}
    }
    else {uf.merge(l, r, d);}
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int D = in.Int();
            int N = in.Int();
            if (N == 100) N++;
            out.println((int) Math.pow(100, D) * N);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



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

using lli = long long int;

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

int main(void){
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else if(s == "Rainy") cout << "Sunny" << endl;
    return 0;
}


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

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

        vector<double> x(n);
        double mean = 0;
        for(int i=0; i<n; i++){
            cin >> x[i];
            mean += x[i];
        }
        mean /= n;
        double v = 0;
        for(int i=0; i<n; i++){
            v += (x[i] -mean) *(x[i] -mean);
        }
        v /= n;
        cout << fixed << setprecision(10);
        cout << sqrt(v) << endl;
    }
    return 0;
}


Measured memory_bytes: 3304
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int A;
  cin>>A;
  cout<<A+A*A+A*A*A<<endl;
}



Measured memory_bytes: 3592
N,L = map(int,input().split())
L2 = L
count=0
while L2 < 0:
    L2+=1
    count+=1

sum =0
if L < -49:
    j = N
else:
    j = N+1
for i in range(1,j):
    if i-1 != count:
        sum += L+i-1
print(sum)

Measured memory_bytes: 3060
#include <iostream>
#include <limits>
#include <queue>
#include <utility>
#include <tuple>

int n, m;
constexpr int MAXN = 100000;
struct Node {int i, d;};
std::vector<Node> G[MAXN+1];
int C[MAXN + 1];
int D[MAXN + 1];
int MAXINT = std::numeric_limits<int>::max();

bool solve() {
    std::queue<int> Q;
    for (int i = 0; i < n; i++) {
        if (C[i] == 0) {
            int r = i;
            C[r] = 1;
            D[r] = 0;
            Q.push(r);
            while (!Q.empty()) {
                r = Q.front();
                for (auto& p: G[r]) {
                    if ((p.d < MAXINT) && (C[p.i] == 1)) {
                        if ((D[r] + p.d) != D[p.i]) {
                            return false;
                        }
                    } else if ((p.d < MAXINT) && (C[p.i] == 0)) {
                        Q.push(p.i);
                        C[p.i] = 1;
                        D[p.i] = D[r] + p.d;
                    }
                }
                Q.pop();
            }
        }
    }
    return true;
}

int main() {
    std::cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int l, r, d;
        std::cin >> l >> r >> d;
        l -= 1;
        r -= 1;
        G[l].push_back({r, d});
        G[r].push_back({l, -d});
    }

    if (solve()) {
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int x;
    cin>>x;
    int c=0,ans=0;
    string s;
    cin>>s;
    for (int i=0;i<x;i++){
        if (s[i]=='D')
            c--;
        else
            c++;
        ans=max(ans,c);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))

// const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846



// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"[";
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===


void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
void inp_mat(ll *arr,ll n,ll m)
{
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
        {
          ll x;cin>>x;
          *((arr+i*m) + j)=x;
        }
}
// syntax for inp_mat inp_mat((ll *)arr,n,m);
// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};
// int x2[]={+0,+0,+1,-1,-1,+1,-1,+1};
// int y2[]={-1,+1,+0,+0,+1,+1,-1,-1};
// int x2[]={-2,-2,-1,-1,+1,+1,+2,+2};
// int y2[]={-1,+1,-2,+2,-2,+2,-1,+1};
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGEc
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    int t=1;
    // cin>>t;
    while(t--)
    {
      
     ll n;cin>>n;
     string s;cin>>s;
     vii v;int c=0;
     f(i,0,n) 
     {
       if(s[i]=='R')
       {
        c++;v.pb(i+1);
       }
     }
     int ans=0;
    f(i,0,si(v))
    {
        if(v[i]>c)
        ans++;
    }
    cout<<ans;
    }    
} 

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

string e;
int p;
string A();
string B();
string C();

string A(){
	string w = B();
	while( e[p] != ']') w += B();
	return w;
}
string B(){
	if( e[p] == '[' ){
		p++;
		string r = A();
		if( e[p] != ']' ) throw "BUG";
		p++;
		reverse(r.begin(),r.end());
		return r;
	}else{
		if( e[p] == ']' ) throw "BUG2";
		return C();
	}
}
string C(){
	if( e[p] == '+' ){
		p++;
		string h = C();
		h[0] = (h[0]-'A'+1)%26+'A';
		return h;
	}else if( e[p] == '-' ){
		p++;
		string h = C();
		h[0] = (h[0]-'A'+25)%26+'A';
		return h;
	}else{
		if( e[p] == '[' || e[p] == ']' ) throw "><";
		return string(1,e[p++]);
	}
}

string solve(string s){
	string table = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string syori = "~";
	for(int i = 0 ; i < table.size() ; i++)
		for(int j = 0 ; j < table.size() ; j++){
			for(int k = 0 ; k < table.size() ; k++){
				string w = s;
				char tb[3] = {table[i],table[j],table[k]};
				int f = 0;
				for(int o = 0 ; o < s.size() ; o++)
					if( s[o] == '?' ) w[o] = tb[f++];
				w += "]";
				e = w;
				p = 0;
				try{
					string a = A();
					if( e.size() != p+1 ) throw ";";
					syori = min(syori,a);
				}catch(const char *msg){
				}
				
			}
		}
	return syori;
}
int main(){
	string s;
	while( cin >> s && s != "." ){
		cout << solve(s) << endl;
	}
}

Measured memory_bytes: 1200
#include <stdio.h>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define mod 1000000007
LL sum,mn,mx;
int main()
{
    int n;
    scanf("%d",&n);
    char s[15];
    map<string,int>mp;
    for(int i=0;i<n;i++)
    {
        scanf("%s",s);
        mp[s]++;
    }
    printf("%d\n",mp.size());
    return 0;
}


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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve(ll testnum)
{
    ll n;
    cin >> n;
    vll a(n);
    for(ll i=0;i<n;i++) {
    	cin >> a[i];
    }
    sort(all(a));
    ll cnt = 0;
    for(ll i=0;i<n;i++) {
    	for(ll j=i+1;j<n;j++) {
    		for(ll k=j+1;k<n;k++) {
    			if(a[i] != a[j] && a[j] != a[k] && a[k] < a[i] + a[j]) {
    				cnt++;
    			}
    		}
    	}
    }
    cout << cnt << "\n";
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1E6+7;
const ll mod=1e9+7;
ll arr[N];
ll mp[N];
ll ksm(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res%mod;
}
int main()
{
    ios::sync_with_stdio(false );
    ll n;
    cin>>n;
    ll mx=0;
    for(ll i=1;i<=n;i++){
        cin>>arr[i];
        mx=max(mx,arr[i]);
    }
    ll pos=0;
    for(ll i=1;i<=n;i++){
        ll x=arr[i];
        ll y=sqrt(x);
        for(ll j=2;j<=y;j++){
            ll cnt=0;
            while(x%j==0){
                x/=j;
                cnt++;
            }
            mp[j]=max(mp[j],cnt);
        }
        if(x!=1) mp[x]=max(mp[x],(ll)1);
    }
    ll sum=1;
    for(ll i=1;i<=mx;i++)
        sum=(sum%mod*ksm(i,mp[i])%mod)%mod;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans+=sum*ksm(arr[i],mod-2)%mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}


Measured memory_bytes: 8192
# union-find
class UnionFind:
    def __init__(self, n):
        self.prsz = [-1] * n # parent & size
    def find(self, v): # root
        if self.prsz[v] < 0: return v
        self.prsz[v] = self.find(self.prsz[v])
        return self.prsz[v]
    def union(self, v, u): # unite
        v = self.find(v); u = self.find(u)
        if v == u: return False
        if self.prsz[v] > self.prsz[u]: v, u = u, v # size(v) < size(u)
        self.prsz[v] += self.prsz[u]
        self.prsz[u] = v
        return True

n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    uf.union(a, b)
ans = set()
for i in range(n):
    ans.add(uf.find(i))
print(len(ans) - 1)


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

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		System.out.println(N * 800 - (N / 15) * 200);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}
}


Measured memory_bytes: 20308
#include<bits/stdc++.h>
	   using namespace std;
	   int main()
	   {
	   	
	   	long long int n,m,d,v,i,sum=0;
	   	scanf("%lld %lld",&n,&m);
	   	for(i=0;i<m;i++)
	   	{
	   		scanf("%lld",&d);
	   		sum=sum+d;
		   }
		   v=n-sum;
		   if(v>=0)
		   {
		   	printf("%lld\n",v);
		   }
		   else
		   {
		   printf("-1\n");
		   }
		   return 0;
	   	
	   }
	   


Measured memory_bytes: 3828
import scala.io.Source

object Main extends App {
  val in = Source.stdin.getLines
  for (line <- in; if line != "0 0") {
    val nk = line.split(' ').map(_.toInt)
    val n = nk(0)
    val s = in.next.split(' ').map(_.toInt)
    val b = in.take(n).map(x => x.split(' ').map(_.toInt))

    if (b.foldLeft(s)(subtract).exists(x => x < 0)) {
      println("No")
    } else {
      println("Yes")
    }
  }

  def subtract(a: Array[Int], b: Array[Int]): Array[Int] = {
    a.zip(b).map(x => x._1 - x._2)
  }
}



Measured memory_bytes: 94748
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);
	    int n=gi();
	    int m=gi();
	    boolean[] isa=new boolean[n];
	    int[] a=new int[n];
	    long pe =0;
	    long ac=0;
	    
        for (int i=0; i<n;i++) {
	        isa[i]=false;
	    }
	    
	    for (int i=0; i<m;i++) {
	    	int p=gi();
	    	String s=gs();
	    	boolean f =s.equals("AC");
	    	if (!isa[p-1]) {
	    		if(f) {
	    			ac++;
	    			isa[p-1]=true;
	    		}else {
	    			a[p-1]++;
	    		}
	    	}
	    }
	    
	    for (int i=0; i<n;i++) {
	        if(isa[i]==true)pe+=a[i];
	    }

	    System.out.print(ac+" "+pe);
//	    if (s.contains("AC")) {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 60016
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL vector<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<pair<LL,pair<LL,LL> > >v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n>>m;
    if(m==1 && n==1)
    {
        cout<<1<<endl;
    }
    else if(n==2 || m==2)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<max((LL)1,n-2)*max((LL)1,m-2)<<endl;
    }
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

const int limit = 100010;
int diff[limit];

// Description: 素集合を管理するデータ構造
// TimeComplexity: 初期化$\mathcal{O}(n)$ 更新$\mathcal{O}(\log n)$
// Verifyed: AOJ DSL_1_A

struct Union_find {
	Union_find(int n) {par.resize(n), iota(_all(par), 0);}
	int find(int x) {return (par[x] == x) ? x : par[x] = find(par[x]);}
	void unite(int a, int b) {a = find(a), b = find(b); par[a] = b;}
	bool same(int a, int b) {return find(a) == find(b);}
	vector<int> par;
};

// abcde
// 0a1b2c3d4e5

int total[limit];

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

	const int m = s.size();

	diff[0] = (s[0] - 'a') % 26;
	rep(i, m - 1) diff[i + 1] = (s[i + 1] - s[i] + 26) % 26;
	diff[m] = (26 - (s[m - 1] - 'a')) % 26;

	Union_find uf(m + 1);
	rep(i, m + 1) uf.unite(i, m - i);

	int n;
	cin >> n;
	rep(i,n){
		int l,r;
		cin >> l >> r;
		l--;
		uf.unite(l,r);
	}

	bool ok = true;
	rep(i,m+1) total[uf.find(i)] = (total[uf.find(i)] + diff[i]) % 26;
	rep(i,m+1) if(total[i]!=0) ok = false;
	puts(ok?"YES":"NO");

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
int main(){
  int n, w = 0;
  std::cin>>n>>w;
  std::vector<std::vector<long> > dp(n+1, std::vector<long>(n * 100+1, 0));
  dp[0][0]=0;
  for (int i = 1; i <dp[0].size() ; ++i) {
    dp[0][i]=1000000001;
  }
  std::vector<int> iv;
  std::vector<long> iw;
  for (int i = 0; i < n; ++i) {
    int a, b = 0;
    std::cin>>a>>b;
    iv.emplace_back(a);
    iw.emplace_back(b);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= dp[0].size(); ++j) {
      if (j < iv[i - 1]) {
        dp[i][j] = dp[i - 1][j];
      } else {
        dp[i][j] = std::min(dp[i - 1][j], dp[i - 1][j - iv[i - 1]] + iw[i - 1]);
      }
    }
  }
  int ans=0;
  for (int i = 0; i < dp[0].size(); ++i) {
    if(dp[n][i]<=w)ans=i;
  }
  std::cout<<ans<<std::endl;
  return 0;
}



Measured memory_bytes: 11124
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

    if 0 in A:
        print(0)
        return
    A1 = A[::2]
    A2 = A[1::2]

    if N%2 ==1:
        ans *= A1[-1]
    for i,j in zip(A1,A2):
        ans *= i*j
        if ans >10**18:
            return print(-1)

    return print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 84724
#include <stdio.h>

int main()
{
	int h = 1, w = 1, i, j;
	while(1)
	{
		scanf("%d %d", &h, &w);
		if(h == 0 && w == 0)
			break;
		for(j = 0; j < h; j++)
		{
			for(i = 0; i < w; i++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n"); 
	}
	return 0;
}


Measured memory_bytes: 2612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int n,m,r,A[55],B[55],K[66],X[66][11],Y[66];
int V;
vi x1,x2,y;
bool dp1[55][55][600],dp2[55][55][600];
bool ok[55][55][55][55];
int dp[55][55][55][55];

void f(int n,int A[],bool dp[][55][600]){
	rep(i,2*n-1){
		dp[i][i][A[i]]=1;
	}
	rep2(len,2,n+1)rep(from,2*n-len){
		int to=from+len-1;
		rep2(cut,from,to)rep(rule,sz(x1)){
			dp[from][to][y[rule]] |=
			dp[from][cut][x1[rule]] & dp[cut+1][to][x2[rule]];
		}
	}
}

void main2(){
	rep(i,n-1)A[i+n]=A[i];
	rep(i,m-1)B[i+m]=B[i];
	V=31;
	x1.clear();
	x2.clear();
	y.clear();
	rep(i,r){
		if(K[i]==2){
			x1.pb(X[i][0]);
			x2.pb(X[i][1]);
			y.pb(Y[i]);
		}
		else rep(k,K[i]-1){
			if(k==0){
				x1.pb(X[i][0]);
				x2.pb(X[i][1]);
				y.pb(V++);
			}else if(k==K[i]-2){
				x1.pb(V-1);
				x2.pb(X[i][k+1]);
				y.pb(Y[i]);
			}else{
				x1.pb(V-1);
				x2.pb(X[i][k+1]);
				y.pb(V++);
			}
		}
	}
	
	memset(dp1,0,sizeof(dp1));
	memset(dp2,0,sizeof(dp2));
	f(n,A,dp1);
	f(m,B,dp2);
	
	memset(ok,0,sizeof(ok));
	rep(from1,2*n-1)rep2(to1,from1,2*n-1){
		rep(from2,2*m-1)rep2(to2,from2,2*m-1){
			rep(var,V){
				ok[from1][to1][from2][to2] |=
				dp1[from1][to1][var] & dp2[from2][to2][var];
			}
		}
	}
	
	rep(from1,2*n)rep2(to1,max(0,from1-1),2*n-1){
		rep(from2,2*m)rep2(to2,max(0,from2-1),2*m-1){
			dp[from1][to1][from2][to2]=
			to1==from1-1 && to2==from2-1 ? 0 : -INF;
		}
	}
	int ans=-1;
	rep2(len1,1,n+1)rep2(len2,1,m+1){
		rep(from1,2*n-len1)rep(from2,2*m-len2){
			int to1=from1+len1-1,to2=from2+len2-1;
			rep2(cut1,from1,to1+1)rep2(cut2,from2,to2+1){
				if(ok[from1][cut1][from2][cut2]){
					dp[from1][to1][from2][to2]=
					max(dp[from1][to1][from2][to2],1+dp[cut1+1][to1][cut2+1][to2]);
				}
			}
			if(len1==n && len2==m){
				ans=max(ans,dp[from1][to1][from2][to2]);
			}
		}
	}
	cout<<ans<<endl;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>n>>m>>r && n){
		rep(i,n)cin>>A[i];
		rep(i,m)cin>>B[i];
		rep(i,r){
			cin>>K[i];
			rep(j,K[i])cin>>X[i][j];
			cin>>Y[i];
		}
		main2();
	}
}

Measured memory_bytes: 47168
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;

void main(){
  auto Z=readln.split.to!(int[]),a=Z[0],b=Z[1],c=Z[2];
  if(a+b>=c)writeln("Yes");
  else writeln("No");
}  

Measured memory_bytes: 256