akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  char s[101];
  scanf("%s",s);
  int c=0;
  int i;
  for(i=0;i<n;i++){
    if(s[i]=='('){
      c++;
    } else if(c>0){
      c--;
    } else {
      putchar('(');
    }
  }
  printf("%s",s);
  for(i=0;i<c;i++) putchar(')');
  putchar('\n');
}

int main(void){
  run();
  return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define size_of(a) (int)a.size()

typedef pair< int, int > pii;

struct Edge {
	int v, t;
	Edge(int _v, int _t) : v(_v), t(_t) {}
};

vector< vector< Edge > > edges;
bool use[22];

pii dfs(int v, int p, int tt) {
	pii res(v, tt);
	
	int e_size = size_of(edges[v]);
	for_(i,0,e_size) {
		Edge e = edges[v][i];
		if (e.v == p || !use[e.v]) continue;
		pii p = dfs(e.v, v, tt + e.t);
		if (res.second < p.second) res = p;
	}
	
	return res;
}

int main() {
	int N;
	
	while (cin >> N, N) {
		edges.assign(N, vector< Edge >());
		
		for_(i,0,N-1) {
			int a, b, t; cin >> a >> b >> t;
			--a; --b;
			edges[a].push_back(Edge(b, t));
			edges[b].push_back(Edge(a, t));
		}
		
		memset(use, 0, sizeof(use));
		for_(i,0,N) if (size_of(edges[i]) != 1) use[i] = true;
		use[0] = true;
		
		pii mx = dfs(0, -1, 0);
		
		int ans = 0;
		
		for_(i,0,N) {
			if (!use[i]) continue;
			
			int e_size = size_of(edges[i]);
			for_(j,0,e_size) {
				Edge e = edges[i][j];
				if (!use[e.v]) continue;
				ans += e.t;
			}
		}
		
		cout << ans - mx.second << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int A, B, C; cin >> A >> B >> C;
    cout << A << ' ' << B << ' ' << -A-B+3*C << '\n';
    cout << -2*A-B+4*C << ' ' << C << ' ' << 2*A+B-2*C << '\n';
    cout << A+B-C << ' ' << -B+2*C << ' ' << -A+2*C << '\n';
    return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;
// clang-format on

int main() {
    llint n, k;
    cin >> n >> k;
    vector<vector<llint>> v(2, vector<llint>(n + 2, 0));
    REP(i, n) {
      
        scanf("%lld",&v[0][i]);
    }
    bool flag;
    REP(i, k + 1) {
        flag = true;
        v[(i + 1) % 2] = vector<llint>(n + 2, 0);
        //    cout << "UNKO" << endl;
        REP(j, n) {
            if(v[i % 2][j] < n) {
                flag = false;
            }
            v[(i + 1) % 2][max(j - v[i % 2][j], 0ll)]++;
            v[(i + 1) % 2][min(j + v[i % 2][j] + 1, n + 1)]--;
        }
        REP(j, n) {
            v[(i + 1) % 2][j + 1] += v[(i + 1) % 2][j];
        }
        if(flag) {
            break;
        }
    }
    REP(i, n - 1) {
        cout << v[(k) % 2][i] << " ";
    }
    cout << v[(k) % 2][n - 1] << endl;

    return 0;
}


Measured memory_bytes: 7812
using System;

namespace paizaTest
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var count = int.Parse(Console.ReadLine());

            var minVal = int.Parse(Console.ReadLine());
            var maxVal = int.MinValue;
            for (var i = 1; i < count; i++)
            {
                var val = int.Parse(Console.ReadLine());
                maxVal = val - minVal > maxVal ? val - minVal : maxVal;
                minVal = minVal > val ? val : minVal;
            }

            Console.WriteLine(maxVal.ToString());
        }
    }
}

Measured memory_bytes: 9212
fn main() {
    let n = read::<usize>();
    let p = read_vec::<f64>();

    let mut dp: Vec<Vec<f64>> = vec![vec![0.0; n+1]; n+1];

    dp[0][0] = 1.0;
    for i in 0..n {
        for j in 0..i+1 {
            dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
            dp[i+1][j+1] += dp[i][j] * p[i];
        }
    }

    let mut ret = 0.0;
    for i in (n+1)/2..n+1 {
        ret += dp[n][i];
    }

    println!("{}", ret);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

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

Measured memory_bytes: 90364
N = int(input())
A = list(map(int,input().split()))
B = [A[i]-i-1 for i in range(N)]
B.sort()

ave1,ave2 = B[N//2],B[N//2-1]
ans1,ans2 = 0,0
for i in range(N):
    ans1 += abs(B[i]-ave1)
    ans2 += abs(B[i]-ave2)
print(min(ans1,ans2))

Measured memory_bytes: 26020
a = input()
b = list(a)
count = 0

for i in range(0, len(b)):
    if i % 2 == 0 and b[i] == 'L':
        count += 1
        print('No')
        break
    if i % 2 == 1 and b[i] == 'R':
        count += 1
        print('No')
        break
if count == 0:
    print('Yes')

Measured memory_bytes: 3060
N = int(input())
import collections

Ls = [collections.deque() for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    Ls[a - 1].append(b - 1)
    Ls[b - 1].append(a - 1)

Cs = sorted(map(int, input().split()), reverse=True)
print(sum(Cs) - Cs[0])

sw = [-1] * N
sw[0] = Cs[0]
ct = 1
stk = collections.deque()
stk.appendleft(0)
while len(stk) > 0:
    crN = stk[0]
    if len(Ls[crN]) == 0:
        stk.popleft()
        continue
    nxN = Ls[crN].popleft()
    if sw[nxN] > 0:
        continue
    sw[nxN] = Cs[ct]
    ct += 1
    stk.append(nxN)
print(" ".join(map(str, sw)))

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

int main(){
  string str;
  int aj,ai;

  while(cin >> str){
    aj = 0;
    ai = 0;
    for(int i=0;i<str.size()-2;i++){
      if(str[i]=='J')
	if(str[i+1]=='O')
	  if(str[i+2]=='I')aj++;
      if(str[i]=='I')
	if(str[i+1]=='O')
	  if(str[i+2]=='I')ai++;
    }
    cout << aj << endl << ai << endl;
  }
}

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

template <typename T> 
struct SegmentTree {
  
  int n;
  vector<T> node;

  T f(T a, T b) {return max(a, b);}

  SegmentTree (int sz, T init = 0) {
    n = 1; while (n < sz) n <<= 1;
    node.assign(2*n, init);
    for (int i = n - 2; i >= 0; i--) node[i] = f(node[2*i+1], node[2*i+2]);
  }

  void update(int k, T x) {
    k += (n - 1);
    node[k] += x;
    while (k > 0) {
      k = (k - 1) >> 1;
      node[k] = f(node[2*k+1], node[2*k+2]);
    } 
  }

  T query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return node[k];
    T vl = query(a, b, 2*k+1, l, (l+r)/2);
    T vr = query(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }

  T getvalue(int k) {
    return query(k,k+1);
  }

};

int main(){ 
  int h, w, m;
  cin >> h >> w >> m;
  vector<int> cnt(h + 1, 0); 
  vector<vector<int>> v(h + 1);
  SegmentTree<int> seg(w + 1, 0);
  rep(i,m) {
    int x, y;
    cin >> x >> y;
    cnt[x]++;
    seg.update(y, 1);
    v[x].emplace_back(y);
  }

  int res = 0;

  for (int i = 0; i <= h; i++) {
    for (int j = 0; j < v[i].size(); j++) {
      seg.update(v[i][j], -1);
    }

    res = max(res, cnt[i] + seg.query(0, w + 1));

    for (int j = 0; j < v[i].size(); j++) {
      seg.update(v[i][j], 1);
    }
  }

  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 24888
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
p_list = list(map(int, input().split()))
ref_list = [i for i in range(0, 102)]
res = 0
val_abs = 1000
for i in ref_list:
  if i not in p_list:
    val = abs(x - i)
    if val < val_abs:
      val_abs = val
      res = i
print(res)

Measured memory_bytes: 9192
S = input()
YY = int(S[:2])
MM = int(S[2:])

if 0 < MM and MM < 13:
    if 0 < YY and YY < 13:
        print('AMBIGUOUS') 
    else:
        print('YYMM')
elif 0 < YY and YY < 13:
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,A;
  cin >> N >> A;
  vi x(N);
  rep(i,N) {
    cin >> x[i];
    x[i] -= A;
  }
  const int geta = 3000;
  vl dp(2*geta,0);
  dp[geta]=1;
  rep(i,N) {
    vl dp2(dp);
    rep(j,2*geta) {
      if(dp[j]) {
        dp2[j+x[i]]+=dp[j];
      }
    }
    dp = dp2;
  }
  ll ans = dp[geta]-1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
import queue
H, W = map(int, input().split())
g = [list(input()) for _ in range(H)]

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
def bfs(g, sh, sw):
    # [[-1, -1, -1], [-1, -1, -1]]
    dist = [[-1] * W for _ in range(H)]
    que = queue.Queue()
    res = 0
    que.put((sh,sw))
    dist[sh][sw] = 0
    while not que.empty():
        sh, sw = que.get()
        res = max(res, dist[sh][sw])
        for i in range(4):
            nh = sh + dx[i]
            nw = sw + dy[i]
            if nh < 0 or nw < 0 or nh >= H or nw >= W:
                continue
            if g[nh][nw] == '#':
                continue
            if dist[nh][nw] == -1:
                dist[nh][nw] = dist[sh][sw] + 1
                que.put((nh, nw))
    return res

ans = 0
for sh in range(H):
    for sw in range(W):
        if g[sh][sw] == '#':
            continue
        ans = max(ans, bfs(g, sh, sw))
print(ans)

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
typedef long long ll;
//ll par[2000010],sizem[2000010],sizel[2000010],size[2000010],a,b,q1,q2,q3,x,y;
ll a[101],n,k;
ll dp[101][100001];
ll sum[100001];

ll calc(ll a,ll b)
{
	if(b<=0)
		return sum[a];
	return (sum[a]-sum[b-1]+mod)%mod;
}

int main()
{
	cin>>n>>k;
	dp[0][0]=1;;
	for (int i = 1; i <= n; ++i)
	{
		dp[i][0]=1;
		cin>>a[i];
	}
	//memset(dp,-1,sizeof(dp));
	for (int i = 1; i <= n; ++i)
	{
		sum[0]=dp[i-1][0];
		for (int j = 1; j <= k; ++j)
		{
			sum[j]=(sum[j-1]+dp[i-1][j])%mod;
		}
		for (int j = 1; j <= k; ++j)
		{
			dp[i][j]=calc(j,j-a[i]);
		}
		
	}
	cout<<dp[n][k]<<endl;
	return 0;
}

Measured memory_bytes: 79104
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;
import java.time.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int K = Integer.parseInt(st.nextToken());
         if(K%2 == 0)
            System.out.println(-1);
         else if(true)
         {
            long curr = 7L;
            int res = 1;
            long lol = System.currentTimeMillis();
            while(System.currentTimeMillis()-lol <= 1050)
            {
               curr %= K;
               if(curr == 0)
               {
                  System.out.println(res);
                  return;
               }
               curr = (curr*10)%K+7L;
               res++;
            }
            System.out.println(-1);
         }
         else
            System.out.println(-1);
      }
      public static boolean isPrime(long n) 
      {
          if(n < 2) return false;
          if(n == 2 || n == 3) return true;
          if(n%2 == 0 || n%3 == 0) return false;
          long sqrtN = (long)Math.sqrt(n)+1;
          for(long i = 6L; i <= sqrtN; i += 6) {
              if(n%(i-1) == 0 || n%(i+1) == 0) return false;
          }
          return true;
      }
   }

Measured memory_bytes: 32692
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int N = Integer.parseInt(scan.next());
	int[] a = new int[N];
	int total = 0;
	for (int i = 0; i < N; i++) {
	    a[i] = Integer.parseInt(scan.next());
	    total += a[i];
	}

	int A1 = total / N;
	int A2 = A1 + 1;
	int score1 = 0;
	int score2 = 0;
	for (int i = 0; i < N; i++) {
	    score1 += (a[i] - A1)*(a[i] - A1);
	    score2 += (a[i] - A2)*(a[i] - A2);
	}

	System.out.println(Integer.min(score1, score2));
	scan.close();
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
    vector<vector<int> > c(3, vector<int>(3));
    vector<int> a(3), b(3);
    a[0] = 0; //なんでもいいので

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < 3; i++) b[i] = c[0][i] - a[0];
    for(int i = 0; i < 3; i++) a[i] = c[i][0] - b[0];

    bool is_right = true;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(a[i] + b[j] != c[i][j]){
                is_right = false;
            }
        }
    }

    if(is_right == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;

}



Measured memory_bytes: 256
import collections as cl

W,H,N = [int(i) for i in input().split()]
action_list = []
ACTION_INDEX = {
	"X" : 0,
	"Y" : 1,
	"TYPE" : 2
}
ACTION_TYPE = {
	"LESS_THAN_X" : 1,
	"MORE_THAN_X" : 2,
	"LESS_THAN_Y" : 3,
	"MORE_THAN_Y" : 4,
}

for i in range(N) :
	action_list.append([int(i) for i in input().split()])

arr = [[0 for i in range(H)] for j in range(W)]

for actions in action_list :
	if(actions[ACTION_INDEX["TYPE"]] == ACTION_TYPE["LESS_THAN_X"]) :
		for i in range(actions[ACTION_INDEX["X"]]) :
			for j in range(H) :
				arr[i][j] = 1

	elif (actions[ACTION_INDEX["TYPE"]] == ACTION_TYPE["MORE_THAN_X"]) :
		for i in range(actions[ACTION_INDEX["X"]], W) :
			for j in range(H) :
				arr[i][j] = 1
	elif (actions[ACTION_INDEX["TYPE"]] == ACTION_TYPE["LESS_THAN_Y"]) :
		for i in range(W) :
			for j in range(actions[ACTION_INDEX["Y"]]) :
				arr[i][j] = 1
	elif (actions[ACTION_INDEX["TYPE"]] == ACTION_TYPE["MORE_THAN_Y"]) :
		for i in range(W) :
			for j in range(actions[ACTION_INDEX["Y"]], H) :
				arr[i][j] = 1

arr2 = []
for i in range(W) :
	for j in range(H) :
		arr2.append(arr[i][j])
c = cl.Counter(arr2)
print(c[0])

Measured memory_bytes: 3436
#include <cstdio>
int n;
int main()
{
	int count=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		if(i>=1&&i<=9) count++;
		if(i>=100&&i<=999) count++;
		if(i>=10000&&i<=99999) count++;
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
n = int(raw_input())
s = [raw_input() for _ in xrange(n)]
cnt = [[0] * 26 for _ in xrange(n)]
for i in xrange(n):
    for j in xrange(len(s[i])):
        cnt[i][ord(s[i][j]) - ord("a")] += 1
ans = ""
for j in xrange(26):
    cntmn = 10**9
    for i in xrange(n):
        cntmn = min(cntmn, cnt[i][j])
    ans += chr(j + ord("a")) * cntmn
print ans

Measured memory_bytes: 2568
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
Y.append(0)
midg = Y[(N + 1) // 2]
midl = Y[(N + 1) // 2 - 1]
for i in range(N):
    if X[i] < midg:
        print(midg)
    elif X[i] >= midl:
        print(midl)


Measured memory_bytes: 25620
#include<bits/stdc++.h>
#define   ll    long long int
#define   sz    200010
#define   pb    push_back
#define   py    printf("Yes\n")
#define   pn    printf("No\n")

using namespace std;


int main()
{
    ll n,i,j,a,b;

    cin>>n;

    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            if(i*j==n)
            {
                py;
                return 0;
            }
        }
    }
    pn;

    return 0;
}


Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())
theta_A = 2 * math.pi * (H * 60 + M) / 720
theta_B = 2 * math.pi * M / 60

xA, yA = A * math.sin(theta_A), A * math.cos(theta_A) 
xB, yB = B * math.sin(theta_B), B * math.cos(theta_B)

print(math.sqrt((xA - xB)**2 + (yA - yB)**2))

Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)x.size())
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vi  = vector<int>;

template <class Monoid>
class SegmentTree {
    using T = typename Monoid::T;
    int size;
    vector<T> data;
    void build() {
        rrep(i, 1, size) {
            data[i] = Monoid::op(data[i * 2], data[i * 2 + 1]);
        }
    }
public:
    SegmentTree(int n) {
        size = 1;
        while (size < n) size *= 2;
        data.assign(size * 2, Monoid::identity());
    }
    template <class It>
    SegmentTree(It first, It last) : SegmentTree(std::distance(first, last)){
        copy(first, last, std::begin(data) + size);
        build();
    }

    // 0-indexed
    void update(int p, const T &value) {
        for (data[p += size] = value; p /= 2; ) {
            data[p] = Monoid::op(data[p * 2], data[p * 2 + 1]);
        }
    }
    // [l, r)  0-indexed
    T query(int l, int r) {
        T resl = Monoid::identity(), resr = Monoid::identity();
        for (l += size, r += size; l < r; l /= 2, r /= 2) {
            if (l & 1) resl = Monoid::op(resl, data[l++]);
            if (r & 1) resr = Monoid::op(data[--r], resr);
        }
        return Monoid::op(resl, resr);
    }
    // 0-indexed
    T get(int p) {
        return data[p + size];
    }
};

struct RMQ {
    using T = int;
    static T op(T a, T b) { return min(a, b); }
    static constexpr T identity() { return (1LL << 31) - 1; }
};

struct RSQ {
    using T = int;
    static T op(T a, T b) { return a + b; }
    static constexpr T identity() { return 0; }
};

signed main() {
    int N, Q;
    cin >> N >> Q;
    SegmentTree<RSQ> seg(N);
    rep(i, 0, Q) {
        int C, X, Y;
        cin >> C >> X >> Y;
        if (C == 0) {
            // add
            X--;
            int old_value = seg.get(X);
            seg.update(X, old_value + Y);
        } else {
            // getsum
            X--, Y--;
            cout << seg.query(X, Y + 1) << endl;
        }
    }
}



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

using namespace std;

using ll = long long;

int max_self(ll &a , ll b){
    a = max(a , b);
return a;
}

int main (){
    int n , w;
    scanf("%d %d"  , &n , &w);
    vector<ll> dp(w + 1);
    for(int item = 0; item < n; ++item){
        int weight , value;
        scanf("%d %d" , &weight , &value);
        for(int walready = w - weight; walready >= 0;  --walready){
            max_self(dp[walready + weight] , dp[walready] + value);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= w; ++i){
        max_self(answer , dp[i]);
    }
    printf("%lld" , answer);
return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n ,m;
cin>>n>>m;
if(n == m){
 cout<<"Yes"<<endl;
}
else{
 cout<<"No"<<endl;
}
}



Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int N,K;
int M[108],p[108][108],l[108];

void init(){
  for(int i=0;i<108;i++){
    M[i]=0;
    l[i]=0;
    for(int j=0;j<108;j++){
      p[i][j]=0;
    }
  }
}

int solve(){
  bool flg=false;
  int res;

  for(int i=0;i<N;i++){
    bool cookies[108];
    for(int q=0;q<108;q++)
      cookies[q]=false;
    for(int j=0;j<K;j++){
      for(int g=0;g<M[i];g++){
        if(l[j]==p[i][g]){
          cookies[l[j]]=true;
        }
      }
    }
    bool flg2=true;
    for(int k=0;k<K;k++){
      if(cookies[l[k]]==false)
        flg2=false;
    }
    if(flg2==true && flg==true) return -1;
    else if(flg2==true && flg==false){
      flg=true;
      res=i+1;
    }
  }

  if(flg==false) return -1;
  if(flg==true) return res;

}

int main(){
  while(1){
    init();
    scanf("%d",&N);
    if(N==0) break;
    for(int i=0;i<N;i++){
      scanf("%d",&M[i]);
      for(int j=0;j<M[i];j++){
        scanf("%d",&p[i][j]);
      }
    }
    scanf("%d",&K);
    for(int i=0;i<K;i++)
      scanf("%d",&l[i]);

    printf("%d\n",solve());

  }
  return 0;
}

Measured memory_bytes: 1072
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	double n,m;
	cin>>n>>m;
	for(int i=0;i<=10000;i++){
		if(floor((double)i*0.08)==n&&floor((double)i*0.1)==m) return cout<<i,0;
	}
	cout<<-1;
	return 0;
}


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

string n;
int k;

long dp[110][2][9];

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

	dp[0][1][0] = 1;
	for (int i = 0; i < (int)n.size(); ++i) {
		for (int j = 0; j < 2; ++j) {
			int x = (j ? n[i] - '0' : 9);
			for (int a = 0; a <= x; ++a) {
				for (int b = 0; b <= k; ++b) {
					if (a != 0) dp[i + 1][j && (a == x)][b + 1] += dp[i][j][b];
					else dp[i + 1][j && (a == x)][b] += dp[i][j][b];
				}
			}
		}
	}

	cout << dp[(int)n.size()][0][k] + dp[(int)n.size()][1][k];
	return 0;
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  int L_max = numeric_limits<int32_t>::min();
  int R_min = numeric_limits<int32_t>::max();

  for (int i = 0; i < M; i++) {
    int L, R;
    cin >> L >> R;
    L_max = max(L_max, L);
    R_min = min(R_min, R);
  }

  if (R_min < L_max) {
    cout << 0 << endl;
  } else {
    cout << R_min - L_max + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		long ans = 0;
		for(int i = 0; i < n; i++) {
			ans += sc.nextInt()-1;
		}
		System.out.println(ans);
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

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

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 33344
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace AtCoder_Beginner_Contest_128
{
    class Program
    {
        public struct Pair
        {
            public string S;
            public long P;
            public long Num;
            public Pair(string s, long p, long num) { S = s; P = p;Num = num; }
        }
        static public int[] SIn() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public string[] SInS() { return ReadLine().Split().ToArray(); }
        static void Main(string[] args)
        {
            var N = SIn()[0];
            var SPpair = new List<Pair>(N);
            for(var i=0;i<N;++i)
            {
                var SP = SInS();
                SPpair.Add(new Pair(SP[0], int.Parse(SP[1]), i + 1));
            }
            var orderd = SPpair.OrderBy(sp => sp.S).ThenByDescending(p => p.P);
            foreach(var sp in orderd)
            {
                WriteLine(sp.Num);
            }
        }
    }
}

Measured memory_bytes: 13664
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
 
        FastIO

        int a,b,c;
        cin>>a>>b>>c;

        cout<<c<<" "<<a<<" "<<b;
        return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    cin >> n;
    if(n % 2 == 0){
        cout << n * (n - 1) / 2 - n / 2 << endl;
        int t = 1 + n;
        for(int i = 1; i < n; i++){
            for(int j = i + 1; j <= n; j++){
                if(i + j == t) continue;
                cout << i << " " << j << endl;
            }
        }
    }else{
        cout << n * (n - 1) / 2 - n / 2 << endl;
        int t = 1 + n - 1;
        for(int i = 1; i < n; i++){
            for(int j = i + 1; j <= n; j++){
                if(i + j == t) continue;
                cout << i << " " << j << endl;
            }
        }
    }
    return 0;
}


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

int main()
{
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (abs(c - a) <= d)
		cout << "Yes" << endl;
	else if (abs(c - b) <= d && abs(b - a) <= d)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
	int a,b,c,k;
	cin >> a >> b >> c;
	
	if(a>b && a>c){
		cout << a*10+b+c << endl;
	}
	else if(b>c){
		cout << b*10+a+c << endl;
	}
	else
		cout << c*10+a+b <<endl;
	
	
return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll=long long;
#define MOD  1000000007

int main(int argc, char const *argv[]) {
  char s;
  std::cin >> s;
  if(s=='a' || s=='i' || s=='u' || s=='e' || s=='o') std::cout << "vowel" << '\n';

  else std::cout << "consonant" << '\n';
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  rep1(i,9){
    rep1(j,9){
      if(i*j==n){
	cout << "Yes" << endl;
	return 0;
      }

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

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
using namespace std;
int main(void){
	int h,r,ans;
	cin>>h>>r;
	if(h+r>0)ans=1;
	else if(h+r<0)ans=-1;
	else ans=0;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define Aint(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


map<ll,ll> v;

const ll mod = pow(10,9)+7;
ll max_div;

void decom(ll n)
{
    // 割る数の初期値
    ll a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            v[a]++;
            if(a>max_div) max_div = a;
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    v[n]++;
    if(n>max_div) max_div = n;
}


int main() {
  ll N;
  cin >> N;
  ll num = 1;
  FOR(i,2,N){
    decom(i);
  }

  ll ans = 1;

  for(ll i=2;i<=max_div;++i){
    ans = ans*(v[i]+1)%mod;
    // cout << v[i] << endl;
  }
  
  cout << ans << endl;


}



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

using namespace std;

int x[100010];
int dp[100010][32];

int calculate(int a, int b) {
    if (b<=a) {
        return 0;
    }
    for (int j=0; j<32;j++) {
        if (b <= dp[a][j+1]) {
            return calculate(dp[a][j],b) + (1<<j);
        }
    }
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        scanf("%d", &x[i]);
    }

    int l;
    scanf("%d", &l);

    int rightPivot = 0;
    for(int i=0; i<n; i++) {
        while(rightPivot+1  < n && x[rightPivot+1] <= x[i] + l) {
            rightPivot++;
        }
        dp[i][0] = rightPivot;
    }

    for(int j=1;j<32;j++) {
        for (int i=0; i<n;i++) {
            dp[i][j] = dp[dp[i][j-1]][j-1];
        }
    }

    int q;
    scanf("%d", &q);
    while(q--) {
        int a1, b1;
        scanf("%d%d", &a1, &b1);
        a1--;
        b1--;
        if (a1>b1) {
            swap(a1, b1);
        }
        printf("%d\n", calculate(a1, b1));
    }
return 0;} 

Measured memory_bytes: 13696
import bisect
import sys
read = sys.stdin.read
readline = sys.stdin.readline

INF = float('INF')

A, B, Q = map(int, readline().split())
stx = list(map(int, read().split()))
S = [-INF] + stx[:A] + [INF]
T = [-INF] + stx[A:-Q] + [INF]
X = stx[-Q:]

for x in X:
    S_idx = bisect.bisect_left(S, x)
    T_idx = bisect.bisect_left(T, x)

    s_left, s_right = S[S_idx-1], S[S_idx]
    t_left, t_right = T[T_idx-1], T[T_idx]
    pathA = x - min(s_left, t_left)
    pathB = max(s_right, t_right) - x
    pathC = min(x-s_left, t_right-x) + t_right - s_left
    pathD = min(x-t_left, s_right-x) + s_right - t_left
    print(min(pathA, pathB, pathC, pathD))

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

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(b-a==c-b) cout << "YES";
    else cout << "NO";
}

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

int main(){
	int n;
	double dbl[10] = {1};
	double dp[100001][10] = {};
	dp[0][1] = 1;
	for(int i = 1;i < 10;i++) dbl[i] = dbl[i - 1] / 2.0;
	for(int i = 0;i < 100000;i++){
		dp[i + 1][1] += dp[i][0];
		for(int j = 1;j < 10;j++){
			dp[i + 1][0] += dp[i][j] * (1.0 - dbl[j]);
			if(j != 9) dp[i + 1][j + 1] += dp[i][j] * dbl[j];
		}
	}
	dp[0][0] = 1;
	for(int i = 1;i < 100000;i++) dp[i][0] = dp[i - 1][0] + (1.0 - dp[i][0]);
	while(cin >> n,n){
		printf("%.8f\n",dp[n - 1][0]);
	}
	return 0;
}

Measured memory_bytes: 10860
function Main(input) {
    var a = input.split("\n");
    var flag = true;
    for(var i=0;i<3;i++){
        a[i] = a[i].split(" ").map(Number);
    }
    if(a[0][0]-a[0][1]==a[1][0]-a[1][1]&&a[1][0]-a[1][1]==a[2][0]-a[2][1]&&a[0][1]-a[0][2]==a[1][1]-a[1][2]&&a[0][1]-a[0][2]==a[2][1]-a[2][2]&&a[0][0]-a[1][0]==a[0][1]-a[1][1]&&a[0][1]-a[1][1]==a[0][2]-a[1][2]&&a[1][0]-a[2][0]==a[1][1]-a[2][1]&&a[1][0]-a[2][0]==a[1][2]-a[2][2]){
        flag = false;
    }
    console.log(flag?"No":"Yes")
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 7372
import java.util.*;

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

    String s = sc.next();
    String t = sc.next();

    int cnt = 0;
    if (s.substring(0,1).equals(t.substring(0,1))) cnt++;
    if (s.substring(1,2).equals(t.substring(1,2))) cnt++;
    if (s.substring(2,3).equals(t.substring(2,3))) cnt++;
    
    System.out.println(cnt);
  }
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s[ohara];
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n;
      rep(i,n)cin>>s[i];
      map<string,ll> mp;
      rep(i,n){
        mp[s[i]]++;
      }
      rep(i,n){
        if(mp[s[i]]>=2){
          Cout("No");
          return 0;
        }
      }
      rrep(i,1,n){
        if(s[i][0]!=s[i-1][Size(s[i-1])-1]){
          Cout("No");
          return 0;
        }
      }
      Cout("Yes");
     

       
return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
const int INF = (1e9)+10;

int n, c, k, ans;
vector<int> t;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> c >> k;
	t.resize(n);
	for(int i = 0; i < n; i++) cin >> t[i];
	sort(t.begin(), t.end());
	for(int i = 0, curr = -INF, cnt = 0; i < n; i++, cnt++) {
		if(t[i]-curr > k || cnt+1 > c) {
			ans++;
			curr = t[i];
			cnt = 0;
		}
	}
	cout << ans;
}


Measured memory_bytes: 640
def pout(i, j):
    print(" ", end="")
    print(*l[j][i], sep=" ")


l = [[[0 for k in range(10)] for j in range(3)] for i in range(4)]
n = int(input())

for _ in range(n):
    b, f, r, v = map(int, input().split())
    l[b - 1][f - 1][r - 1] += v

for j in range(4):
    [pout(i, j) for i in range(3)]
    if j != 3:
        print("#" * 20)


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

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 27
#endif

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) (int)(v.size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ar array
#define forn(i, n) for(int i = 0; i < n ; ++i)
#define for1(i, n) for(int i = 1; i <=n ; ++i)
#define ford(i, n) for(int i = n-1; i>= 0;--i)
#define UNQ(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mem(X,val) memset(X, val, sizeof((X)))

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>>  vvi ;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpi ;

const db PI = acos(-1);
const ll mod = 1e9+7;
template <class T>void smax(T& x,T y){ if(x<y)x=y;}
template <class T>void smin(T& x,T y){ if(x>y)x=y;}
template<typename T1, typename T2> T1 powz(T1 A, T2 B);
/***************************************************main code**************************************************************/
const int MXN=1e6+5;
const ll INF = 9e18+200;
const int inf = 1e9+100;
const int mxn = 2e5+20;


void test_case()
{	
	int n,k; cin >> n >> k;
	vi a(n); forn(i, n)cin >> a[i];
	vector<bool> dp(k+1);
	forn(pil, k+1){
		for(auto s : a)
			if(pil >= s && !dp[pil-s])
				dp[pil] = true;
	}
	debug(dp);
	cout << (dp[k] ? "First" : "Second");			     
}
/*************----------------------------******************/
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef VIJY_DEFINE
    freopen("input.txt","r",stdin);
#endif
//  freopen("output.txt","w",stdout);
    int Tests = 1;
//  cin >> Tests;
    
    for(int tc = 1; tc <= Tests; ++tc){
        //cout <<"Case #"<<tc<<": ";
        test_case();
        cout<<'\n';
    }
#ifdef VIJY_DEFINE
    cerr << "Time elapsed: "<< 1.0*clock() / CLOCKS_PER_SEC <<"s.\n";
#endif   
}
template<typename T1, typename T2>
T1 powz(T1 X,T2 B)
{
    ll A = X;
    ll res=1;
        A%=mod; 
        assert(B>=0); 
    for( ; B ; B>>=1){
        if(B&1)res=res*A%mod;
        A= A*A%mod;
    }
    return res;
}


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

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;
  constexpr ModInt() : x(0) {}
  constexpr ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  constexpr ModInt &operator+=(const ModInt &p) noexcept {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt &p) noexcept {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt &p) noexcept {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  constexpr ModInt &operator/=(const ModInt &p) noexcept {
    *this *= p.inverse();
    return *this;
  }
  constexpr ModInt operator-() const { return ModInt(-x); }
  constexpr ModInt operator+(const ModInt &p) const noexcept {
    return ModInt(*this) += p;
  }
  constexpr ModInt operator-(const ModInt &p) const noexcept {
    return ModInt(*this) -= p;
  }
  constexpr ModInt operator*(const ModInt &p) const noexcept {
    return ModInt(*this) *= p;
  }
  constexpr ModInt operator/(const ModInt &p) const noexcept {
    return ModInt(*this) /= p;
  }
  constexpr bool operator==(const ModInt &p) const noexcept { return x == p.x; }
  constexpr bool operator!=(const ModInt &p) const noexcept { return x != p.x; }
  constexpr ModInt inverse() const noexcept {
    int a = x, b = mod, u = 1, v = 0, t = 0;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  constexpr ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while (n) {
      if (n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend constexpr ostream &operator<<(ostream &os, const ModInt &p) noexcept {
    return os << p.x;
  }
  friend constexpr istream &operator>>(istream &is, ModInt &a) noexcept {
    int64_t t = 0;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  constexpr int get_mod() { return mod; }
};

int n;

int main() {
  cin >> n;
  ModInt<> now, res;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    res += now * a;
    now += a;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3620
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String st = br.readLine();
			String[] str = st.split(" ");
			int a = Integer.parseInt(str[0]);
			String op = str[1];
			int b = Integer.parseInt(str[2]);
			if ("?".equals(op)) {
				break;
			}
			if("+".equals(op)){
				System.out.println(a + b);
			}else if("-".equals(op)){
				System.out.println(a - b);
			}else if("*".equals(op)){
				System.out.println(a * b);
			}else if("/".equals(op)){
				System.out.println(a / b);
			}
		}
	}
}

Measured memory_bytes: 24308
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;



template< unsigned mod >
struct RollingHash {
  vector< unsigned > hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }

  RollingHash(const string &s, unsigned base = 10007) {
    int sz = (int) s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};

using RH = RollingHash< 1000000007 >;



int main(){
    int n;cin >> n;
    string s;cin >> s;
    RH rh1(s);
    RollingHash<1000000009> rh2(s);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            if(s[i]!=s[j]) continue;
            int l = 1,r = min(j-i+1,n-j+1);
            bool f = false;
            if(r<=ans) f = true;
            while(!f&&r-l>1){
                int m = (r + l) / 2;
                if(rh1.get(i,i+m) == rh1.get(j,j+m) && rh2.get(i,i+m) == rh2.get(j,j+m)){
                    l = m;
                }
                else{
                    r = m;
                }
            }
            if(!f) ans = max(ans,l);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512