akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define pi acos(-1.0)/*
#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second*/
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


int main()
{

    ll n,k,i,v=0,p,tot,num;

    cin>>n>>k;

    ll a[n+2];
    ll m[n+2]={0},c[n+2]={0};

    for(i=1;i<=n;++i)
            cin>>a[i];

    ++m[1];
    c[1]=0;

    p=1;

    while(1)
    {
        p = a[p];
        ++m[p];
        ++v;

        if(v==k)
        {
            cout<<p;
            return 0;
        }

        if(m[p]==2)
            break;

        c[p]=v;
    }

    tot = v-c[p];

    k = k - v;

    num = k%tot;


    while(num!=0)
    {
        p = a[p];
        --num;
    }

    cout<<p;


    return 0;
}

Measured memory_bytes: 8308
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

int main()

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

    int n, d, z = 0, ans = 0;

    cin >> n >> d;

    int a[n][d];

    for (int i = 0; i < n; i++) {

        for (int j = 0; j < d; j++) {

            cin >> a[i][j];
        }
    }

    for (int i = 0; i < n; i++) {

        for (int j = i+1; j < n; j++) {

            for (int k = 0; k < d; k++) {

                z += ((a[i][k]-a[j][k])*(a[i][k]-a[j][k]));
            }

            if (ceil(sqrt(z)) == floor(sqrt(z))) ans++;

            z = 0;
        }

        z = 0;
    }

    cout << ans;

    return 0;
}


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

int main() {
  char C;
  cin >> C;
  if(C == 'a' || C == 'i' || C == 'u' || C == 'e' || C == 'o' )
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
deal :: [Int] -> [Int] -> [Int] -> [Int]
deal [] xs ys = ys ++ reverse xs
deal [x] xs ys = x:xs ++ reverse ys
deal (x:y:zs) xs ys = deal zs (x:xs) (y:ys)
 
putList = putStr . unwords . map show
 
main = do
  _ <- getLine
  as <- map read . words <$> getLine
  putList $ deal as [] []

Measured memory_bytes: 121980
use std::cmp::min;
use std::io;
use std::str;

pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

impl<R: io::BufRead> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buffer: vec![],
        }
    }

    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }

    pub fn tokens<T: str::FromStr>(&mut self) -> Vec<T> {
        assert!(self.buffer.is_empty());
        let mut input = String::new();
        self.reader.read_line(&mut input).expect("Failed read");
        input
            .split_whitespace()
            .map(|x| x.parse().ok().expect("Failed parse"))
            .collect()
    }
}

// f(n) -> f(n + 1), cost: |heights[n] - heights[n + 1]|
// f(n) -> f(n + 2), cost: |heights[n] - heights[n + 2]|

const INF: i32 = 1000000000;

fn pull_dp(n: usize, heights: &[i32]) -> i32 {
    let mut dp = vec![INF; n];
    dp[0] = 0;
    dp[1] = (heights[0] - heights[1]).abs();
    for i in 2..n {
        dp[i] = dp[i].min(min(dp[i - 1] + (heights[i] - heights[i - 1]).abs(), dp[i - 2] + (heights[i] - heights[i - 2]).abs()));
    }
    dp[n - 1]
}

fn push_dp(n: usize, heights: &[i32]) -> i32 {
    let mut dp = vec![INF; n];
    dp[0] = 0;
    for i in 0..n {
        if i + 1 < n {
            dp[i + 1] = dp[i + 1].min(dp[i] + (heights[i] - heights[i + 1]).abs());
        }
        if i + 2 < n {
            dp[i + 2] = dp[i + 2].min(dp[i] + (heights[i] - heights[i + 2]).abs());
        }
    }
    dp[n - 1]
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let n: usize = scan.token();
    let heights: Vec<i32> = scan.tokens();
    let ans = push_dp(n, &heights);
    writeln!(out, "{}", ans).ok();
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    solve(&mut scan, &mut out);
}


Measured memory_bytes: 2948
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((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())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    string s;
    cin >> s;
    int i = s.length();
    while (i > 0) {
        if (i >= 5) {
            if (s.substr(i - 5, 5) == "dream") {
                i -= 5;
                continue;
            }
            if (s.substr(i - 5, 5) == "erase") {
                i -= 5;
                continue;
            }
        }
        if (i >= 6) {
            if (s.substr(i - 6, 6) == "eraser") {
                i -= 6;
                continue;
            }
        }
        if (i >= 7) {
            if (s.substr(i - 7, 7) == "dreamer") {
                i -= 7;
                continue;
            }
        }
            cout << "NO" << endl;
            return 0;
    }

    cout << "YES" <<
         endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int fa[N],si[N],ans[N];
int find(int x){
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
int main(){
	int n,m,k,x,y;scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++)fa[i]=i,si[i]=1;
	for(int i=0;i<m;i++){
		scanf("%d%d",&x,&y);ans[x]++,ans[y]++;
		x=find(x),y=find(y);
		if(x!=y)fa[y]=x,si[x]+=si[y];
	}
	for(int i=0;i<k;i++){
		scanf("%d%d",&x,&y);
		if(find(x)==find(y))ans[x]++,ans[y]++;
	}
	for(int i=1;i<=n;i++){
		int x=find(i);
		printf("%d ",si[x]-ans[i]-1);
	}
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string t;
    cin >> t;
    for(int i = 0; i < t.size(); i++){
        if(t[i] == '?'){
            t[i] = 'D';
        }
    }
    cout << t << endl;
}


Measured memory_bytes: 3740
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
int n,x,y,p,i;
ll ans;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	//freopen("sol.in","r",stdin);
	cin>>n>>p;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		if((x&1))y++;
	}
	if(y)ans=(1LL<<(n-1));
	else if(p && !y)ans=0;
	else ans=(1LL<<n);
	cout<<ans<<endl;
	return 0;
}

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


int main() {
 string S;
  cin >> S;
  int ans=0;
  for(int i=0; i<4; i++){
    if( S.at(i)=='+' ){
      ans++;
    }
    else{
      ans--;
    }
  
}
  cout << ans << endl;
}



Measured memory_bytes: 256
#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--)
//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;

void rohan_algo()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}



int32_t main()
{
	rohan_algo();
	int a; cin >> a;
	if (a == 1) {
		cout << 0 << endl;
	} else
		cout << 1 << endl;
}





















Measured memory_bytes: 3584
import sys
input=sys.stdin.readline
from collections import defaultdict,deque
n,m=map(int,input().split())
route=10**6
Edges=defaultdict(set)
Visited=defaultdict(bool)
for _ in range(m):
    p,q,c=map(int,input().split())
    Edges[p].add(p+c*route)
    Edges[p+c*route].add(p)
    Edges[p+c*route].add(q+c*route)
    Edges[q+c*route].add(p+c*route)
    Edges[q].add(q+c*route)
    Edges[q+c*route].add(q)
q=deque()
q.append((1,0))
cost=-1
while q:
    fr,c=q.popleft()
    Visited[fr]=True
    if fr==n:
        cost=c
        break
    for to in Edges[fr]:
        if Visited[to]:
            continue
        if fr<=10**5 and to>route:
            q.append((to,c+1))
        else:
            q.appendleft((to,c))
print(cost)

Measured memory_bytes: 221784
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.ST                 as ST
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n $ BS.unpack <$> BS.getLine
toPair [x, y] = (x, y)

main = do
  [s] <- readString
  let ans = if length (group s) == 1 then "No" else "Yes"
  putStrLn ans





Measured memory_bytes: 380
import collections
import math
import re
import numpy
def ai():return input()#s
def a():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
def say(i):return print("Yes" if i == 0 else "No")
def Say(i):return print("YES" if i == 0 else "NO")
k= [0]
l = []
f = 0
s=0
c=0
e =1
a  =a()
x = lma() +[0]
m = min(x)
for i in range(1,a+1):
    if x[i] < x[i-1]:
        s+=x[i-1]-m
        m = x[i]
print(s)

Measured memory_bytes: 12344
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int h = a / 3600;
            int m = (a % 3600) / 60;
            int s = ((a % 3600) % 60);
            Console.WriteLine(h + ":" + m + ":" + s);
        }
    }
}

Measured memory_bytes: 9040
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

typedef struct RMQandRAQ {
  i64 *add;
  i64 *max;
  i32 bit;
  i32 size;
} RMQandRAQ;

RMQandRAQ* new_RMQandRAQ (const i32 n) {
  i32 k = 0;
  while ((1 << k) < n) ++k;
  RMQandRAQ *s = (RMQandRAQ *) calloc (1, sizeof (RMQandRAQ));
  s->add = (i64 *) calloc (2 << k, sizeof (i64));
  s->max = (i64 *) calloc (2 << k, sizeof (i64));
  s->bit = k;
  s->size = 1 << k;
  return s;
}

static inline i64 max (i64 a, i64 b) {
  return a > b ? a : b;
}

static inline i64 eval (RMQandRAQ *s, i32 k) {
  return s->add[k] + s->max[k];
}

void propagate (RMQandRAQ *s, i32 x) {
  x += s->size;
  for (i32 bit = s->bit; bit > 0; bit--) {
    i32 k = x >> bit;
    s->add[2 * k] += s->add[k];
    s->add[2 * k + 1] += s->add[k];
    s->add[k] = 0;
    s->max[k] = max (eval (s, 2 * k), eval (s, 2 * k + 1));
  }
}

void save (RMQandRAQ *s, i32 x) {
  for (i32 k = (x + s->size) >> 1; k >= 1; k >>= 1) {
    s->max[k] = max (eval (s, 2 * k), eval (s, 2 * k + 1));
  }
}

void add (RMQandRAQ *s, i32 l, i32 r, i64 v) {
  for (i32 x = l + s->size, y = r + s->size; x < y; x >>= 1, y >>= 1) {
    if (x & 1) s->add[x++] += v;
    if (y & 1) s->add[--y] += v;
  }
  save (s, l);
  save (s, r - 1);
}

i64 find (RMQandRAQ *s, i32 l, i32 r) {
  //propagate (s, l);
  //propagate (s, r - 1);
  i64 ans = 0;
  for (l += s->size, r += s->size; l < r; l >>= 1, r >>= 1) {
    if (l & 1) ans = max (ans, eval (s, l++));
    if (r & 1) ans = max (ans, eval (s, --r));
  }
  return ans;
}

typedef struct node {
  i32 l, v;
} node;

void run (void) {
  i32 n = read_int();
  i32 m = read_int();
  node **p = (node **) calloc (n + 1, sizeof (node *));
  i32 *len = (i32 *) calloc (n + 1, sizeof (i32));
  i32 *max_len = (i32 *) calloc (n + 1, sizeof (node));
  for (i32 i = 0; i < m; ++i) {
    i32 l = read_int();
    i32 r = read_int();
    i32 v = read_int();
    if (len[r] == max_len[r]) {
      max_len[r] = 2 * max_len[r] + 1;
      p[r] = (node *) realloc (p[r], sizeof (node) * max_len[r]);
    }
    p[r][len[r]++] = (node) {l, v};
  }
  RMQandRAQ *s = new_RMQandRAQ (n + 1);
  for (i32 i = 1; i <= n; ++i) {
    i64 v = find (s, 0, i);
    add (s, i, i + 1, v);
    for (i32 j = 0; j < len[i]; ++j) {
      add (s, p[i][j].l, i + 1, p[i][j].v);
    }
  }
  print_int (find (s, 0, n + 1));
  putchar ('\n');
}

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


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

int n, m, k;
char g[8][8], t[8][8];

void reset() {
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < m; ++j)
            t[i][j] = g[i][j];
}

void color(int k) {
    if(k >= n) {
        k -= n;
        for(int i = 0; i < n; ++i)
            t[i][k] = '.';
        
    }
    else {
        for(int j = 0; j < m; ++j)
            t[k][j] = '.';
    }
}

int count() {
    int cnt = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < m; ++j)
            if(t[i][j] == '#') ++cnt;
    return cnt;
}

int main() {
    scanf("%d %d %d", &n, &m, &k);
    for(int i = 0; i < n; ++i)
        scanf("%s", g+i);
    int cnt = 0;
    int x = (1<<(n+m)) - 1;
    for(int i = 0; i <= x; ++i) {
        reset();
        for(int j = 0; j < n+m; ++j)
            if((1<<j) & i)
                color(j);
        if(count() == k) ++cnt;
    }
    printf("%d", cnt);
    return 0;
}

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

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

	vector<tuple<string, int, int>> data;

	rep(i, N) {
		string s;
		int p;
		cin >> s >> p;
		data.push_back(make_tuple(s, -p, i+1));
	}

	sort(data.begin(), data.end());
  
  rep(i,N){
    cout << get<2>(data[i]) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
ts = gets.chomp.split(" ").map(&:to_i)
ts_sum = ts.inject(:+)
m = gets.chomp.to_i
m.times do
  p, x = gets.chomp.split(" ").map(&:to_i)
  puts ts_sum - ts[p-1] + x
end


Measured memory_bytes: 1788
#include<stdio.h>
int main(){
  char s[4];
  int a=0,b=0,c=0;
  scanf("%s",s);
  for(int i=0; i<3; i++){
    if(s[i]=='a'){
      a++;
    }else if(s[i]=='b'){
      b++;
    }else{
      c++;
    }
  }
  if(a==1&&b==1&&c==1){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

#define FALSE 0
#define TRUE  1

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

int X[N][N];

void init();
void printBord();
void recursive(int );

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

  init();

  for(i=0;i<N;i++){
    for(j=0;j<N;j++) X[i][j]=FALSE;
  }

  scanf("%d",&k);

  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    X[r][c]=TRUE;
  }

  recursive(0);

return 0;

  }

  void init(){
    int i;
    for(i=0;i<N;i++){
      row[i]=FREE;
      col[i]=FREE;
    }
    for(i=0;i<2*N-1;i++){
      dpos[i]=FREE;
      dneg[i]=FREE;
    }
  }

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

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

      recursive(i+1);

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



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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cin.exceptions(cin.failbit);
#define int long long int //Comment when Unnecessary
#define ll long long
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define pii pair<int, int>
#define vi vector<int>
#define F first
#define S second
#define endl "\n" // Remove on Interactive

const int N = 300009;
const int mod = 1000000007;

int a[3][3];
int n;
int b[N];
int is[3][3];

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	// memset(is, 0, sizeof(is));
	rep(i, 0, 3)
	{
		rep(j, 0, 3)
		{
			cin >> a[i][j];
			is[i][j] = 0;
		}
	}
	cin >> n;
	rep(i, 0, n)
	{
		cin >> b[i];
		rep(j, 0, 3)
		{
			rep(k, 0, 3)
			{
				if (b[i] == a[j][k])
					is[j][k] = 1;
			}
		}
	}
	bool hai = 0;
	rep(i, 0, 3)
	{
		int cnt = 0;
		rep(j, 0, 3)
		{
			if (is[i][j])
				cnt++;
		}
		if (cnt == 3)
		{
			hai = 1;
			break;
		}
	}
	rep(j, 0, 3)
	{
		int cnt = 0;
		rep(i, 0, 3)
		{
			if (is[i][j])
				cnt++;
		}
		if (cnt == 3)
		{
			hai = 1;
			break;
		}
	}
	int cnt = 0;
	rep(i, 0, 3)
	{
		if (is[i][i])
		{
			cnt++;
		}
	}
	if (cnt == 3)
		hai = 1;
	cnt=0;
	rep(i, 0, 3)
	{
		if (is[i][2 - i])
		{
			cnt++;
		}
	}
	if (cnt == 3)
		hai = 1;
	if (hai)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    std::string s;
    std::cin >> s;
    std::reverse(s.begin(), s.end());
    std::vector<std::string> cand { "maerd", "remaerd", "esare", "resare" };
    for (auto it = s.begin(); it != s.end(); ) {
        bool found = false;
        for (const auto &c : cand) {
            if (std::equal(c.begin(), c.end(), it)) {
                found = true;
                it += c.size();
                break;
            }
        }
        if (!found) {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }

    std::cout << "YES" << std::endl;
    return 0;
}


Measured memory_bytes: 512
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, A, B;
    cin >> n >> A >> B;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    auto dp = initVec3<int>(n + 1, 401, 401, INF);
    dp[0][0][0] = 0;
    rep(i, n){
        rep(j, 401){
            rep(k, 401){
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
                if(j + a[i] > 400 || k + b[i] > 400){
                    continue;
                }
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i]);
            }
        }
    }

    int aa = A;
    int bb = B;
    int ans = INF;
    while(aa <= 400 && bb <= 400){
        ans = min(ans, dp[n][aa][bb]);
        aa += A;
        bb += B;
    }
    cout << (ans == INF ? -1 : ans) << endl;

    return 0;
}


Measured memory_bytes: 53504
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  set<int>a,b;
  cin>>n;
  while(n--){
    int x;
    cin>>x;
    a.insert(x);
  }
  cin>>n;
  while(n--){
    int x;
    cin>>x;
    b.insert(x);
  }
  vector<int>c;
  set_difference(a.begin(),a.end(),b.begin(),b.end(),back_inserter(c));
  for(int i=0;i<c.size();i++)cout<<c[i]<<endl;
}



Measured memory_bytes: 22620
#include <iostream>
using namespace std;
int main(){
    int d; cin>>d;
    if(d == 25) cout<<"Christmas"<<endl;
    else if(d == 24) cout<<"Christmas Eve"<<endl;
    else if(d == 23) cout<<"Christmas Eve Eve"<<endl;
    else if(d == 22) cout<<"Christmas Eve Eve Eve"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long A, B;
	int ans = 0;
	cin >> A;
	B = A;
	int dem = 0;
	while (B >= 10) {
		B /= 10; // hay n = n /10;
		dem++;
	}
	dem += 1;
	ans = 0;
	/*if (dem == 1) {
	ans = A;
	}
	else {*/
	while (dem >= 1) {
		switch (dem)
		{
		case 1:
			if (A >= 9) {
				ans += 9;
			}
			else {
				ans += A;
			}
			break;
		case 3:
			if (A <= 999) {
				ans += (A - 100);
			}
			else {
				ans += (999 - 100);
			}
			ans += 1;
			break;
		case 5:
			if (A <= 99999) {
				ans += (A - 10000);
			}
			else {
				ans += (99999 - 10000);
			}
			ans += 1;
				break;
		case 2:
		case 4:
		case 6:
			ans += 0;
			break;
		}
		dem--;
	}
	//}
	cout << ans;
	cout << endl;
	return 0;
}

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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

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

	map<string, int> m;
	string w;

	cin >> w;

	char last = w[w.size()-1];

	m[w] = 1;

	FOR(i, 1, N){
		cin >> w;

		if(w[0] != last){
			cout << "No" << endl;
			return 0;
		}

		if(m.count(w) > 0){
			cout << "No" << endl;
			return 0;
		}

		m[w] = 1;
		last = w[w.size()-1];
	}

	cout << "Yes" << endl;

	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<vector>
#include<cmath>
#include<cstdlib>
using namespace std;
 
typedef long long ll;
const int maxn = 1e5 + 5;
const ll ma = 5e18 + 5;
ll n,k,m,seq[maxn + 5];
 
struct Point{
	ll x,y;
}a[maxn];
 
bool cmp(Point A,Point B){
	if(A.x == B.x) return A.y < B.y;
	return A.x < B.x;
}
 
void Init(){
	scanf("%lld %lld",&n,&k);
	for(ll i = 1;i <= n;i++) scanf("%lld %lld",&a[i].x,&a[i].y);
	sort(a + 1,a + n + 1,cmp);
}
 
void Insert(ll ny){
	seq[++seq[0]] = ny;
	ll p = seq[0];
	while(p > 1LL && seq[p] < seq[p - 1]) swap(seq[p],seq[p - 1]),p--;
}
 
 
int GetW(ll seq[]){
	ll res = ma;
	for(ll i = 1;i <= seq[0];i++){
		if(i + m - 1LL > seq[0]) break;
		res = min(res,seq[i + m - 1LL] - seq[i]);
	}
	return res;
}
 
void Slove(){
	ll ans = ma;
	m = k;
	a[0].x = a[n + 1].x = ma;
	for(ll i = 1;i <= n;i++){
		if(a[i].x == a[i - 1].x) continue;
		ll cnt  = 1;
		seq[0] = 0;
		seq[++seq[0]] = a[i].y;
		for(ll j = i + 1;j <= n;j++){
			Insert(a[j].y);
			cnt++;
			if(cnt >= m && a[j].x < a[j + 1].x){
				ll h = a[j].x - a[i].x;
				ll w = GetW(seq);
				ans = min(ans,h * w);
			}
		}
	}
	if(n == 1) ans = 0;
	printf("%lld\n",ans);
}
 
int main(){
	Init();
	Slove();
}

Measured memory_bytes: 256
import math
n = int(input())
A = list(map(int, input().split( )))
x1 = 0
for i in range(n):
  x1 += ((-1)**i)*A[i]
arr = [x1]
s = x1//2
for i in range(n-1):
  s = A[i]-s
  arr.append(s*2)
print(' '.join(map(str, arr)))




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

int main()
{
    int n;
    cin >> n;
    vector<int> zoro(n, 0);
    for (int i = 0; i < n; i++)
    {
        int set1, set2;
        cin >> set1 >> set2;
        if (set1 == set2) zoro[i] = 1;
    }

    for (int i = 0; i < n - 2; i++)
    {
        if (zoro[i] && zoro[i + 1] && zoro[i + 2])
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3596
n = int(input())
s, t = [], []
for i in range(n):
    a, b = input().split()
    s.append(a)
    t.append(int(b))
x = input()

count = 0
asleep = False
for i in range(n):
    if asleep:
        count += t[i]
    if s[i] == x:
        asleep = True

print(count)


Measured memory_bytes: 3316
n, w = map(int, input().split())
list_item = []
for _ in range(n):
  weight, value = map(int, input().split())
  list_item.append((weight, value))

dict_ks = {}
dict_ks[0] = 0
num_checked = 0
while num_checked < n:
  new_w, new_v = list_item[num_checked]
  for temp_w, temp_v in list(dict_ks.items()):
    if temp_w + new_w <= w:
      if temp_w + new_w not in dict_ks:
        dict_ks[temp_w + new_w] = temp_v + new_v
      else:
        dict_ks[temp_w + new_w] = max(dict_ks[temp_w + new_w], temp_v + new_v)
  num_checked += 1

print(max(dict_ks.values()))

Measured memory_bytes: 3556
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        double ans = 0;
        for (int i = 0; i < n; i++)
        {
            string[] cin = Console.ReadLine().Split();
            if (cin[1] == "JPY") ans += double.Parse(cin[0]);
            else ans += double.Parse(cin[0]) * 380000.0;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
solver::Int->Int->String
solver x y = let (x_c,y_c) = (classify x,classify y) in
            if x_c == y_c then "Yes" else "No"

data Sets = Aset | Bset | Cset deriving (Eq,Show)

classify::Int->Sets
classify x
    | elem x [1,3,5,7,8,10,12] = Aset
    | elem x [4,6,9,11] = Bset
    | elem x [2] = Cset

main::IO()
main =do
  xyc<-getLine
  let x:y:[]=map read (words xyc)
  putStr (solver x y)
  putStr "\n"


Measured memory_bytes: 508
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N),C(N);
  int Amax=0,Amin=1e9+5,Cmax=0,Cmin=1e9+5;
  for(int i=0;i<N;i++){
    cin >> A[i];
    Amax=max(Amax,A[i]);
    Amin=min(Amin,A[i]);
  }
  for(int i=0;i<N;i++){
    cin >> B[i];
  }
  for(int i=0;i<N;i++){
    cin >> C[i];
    Cmax=max(Cmax,C[i]);
    Cmin=min(Cmin,C[i]);
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  ll ans=0;
  for(int b:B){
    if(b<Amin || b>=Cmax){
      continue;
    }
    auto Ait=lower_bound(A.begin(),A.end(),b);
    auto Cit=upper_bound(C.begin(),C.end(),b);
    ans+=(Ait-A.begin())*(C.end()-Cit);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4560
s=input()
s=s.split()
n,m=int(s[0]),int(s[1])
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
mod =10**9 + 7
xrange=0
for i in range(n):
    xrange-=x[i]*(n-i*2-1)
yrange=0
for i in range(m):
    yrange-=(m-i*2-1)*y[i];
ans=(xrange*yrange)%mod
print(ans)


Measured memory_bytes: 19452
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

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


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll k;cin>>k;
  cout<<50<<endl;
  vl a(50);
  rep(i,50)a[i]=(50+k-1)/50+49;
  ll l=(50LL+k-1)/50LL*50LL-k;
  rep(i,50)a[i]+=l;
  rep(i,l)a[i]-=50LL+1;
  rep(i,50)cout<<a[i]<<" ";
  cout<<endl;
}
  
  


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

typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
typedef long long ll;
const int N = 1e5+10 , OO = 0x3f3f3f3f , mod = 1e9 + 7;

#define PI acos(-1) 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
 
int n , k;
int w[105] , v[105];
ll dp[105][N];

ll solve(int idx , int remW){
  if(remW < 0)
    return -OO;
  if(idx == n)
    return 0;
  ll &ret = dp[idx][remW];
  if(~ret)
    return ret;
  ll leave = solve(idx + 1 , remW);
  ll take = solve(idx + 1 , remW - w[idx]) + v[idx];
  return ret = max(leave , take); 
}

int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

  scanf("%d %d", &n , &k);
  for(int i = 0 ; i < n ; ++i)
    scanf("%d %d", &w[i], &v[i]);
  
  memset(dp , -1 , sizeof dp);
  printf("%lld\n" , solve(0 , k));


  return 0;
}

Measured memory_bytes: 85804
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for(ll i=0;i<n;i++) 
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main(){
  string s ;
  cin>> s ;
  ll k=s.size() ;
  
  for(ll i=0 ;2*i<k;i++){
    if(2*i==k-2||2*i==k-1) {
      cout<<s[2*i]<<endl ;
      }else {
        cout<<s[2*i] ;
      }
  }
 
  return 0;
  }

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

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    if(a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FASTIO ios::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main() {
	FASTIO;
	ll n, sum = 0;
	cin >> n;
	vector<ll> a(n);
	rep(i, n){
	    cin >> a[i];
	}
	for(int i = 1; i < SZ(a); ++i){
	    if(a[i-1] > a[i]){
	        sum += a[i-1] - a[i];
	        a[i] = a[i-1];
	    }
	}
	cout << sum << endl;
}

Measured memory_bytes: 4792
#include <iostream>
#include <utility>
#include <stdint.h>
#include <set>
#include <numeric>

using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;

  multiset<int, greater<int>> A;

  for (int n=0; n<N; ++n) {
    int a;
    cin >> a;
    A.insert(a);
  }

  for (int m=0; m<M; ++m) {
    int biggest = *A.begin();
    A.erase(A.begin());
    A.insert(biggest/2);
  }

  cout << accumulate(A.begin(), A.end(), (int64_t)0) << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, x, y, z, k);
    Cins(ll, x, a);
    DeSort(a);
    Cins(ll, y, b);
    Cins(ll, z, c);
    vector<ll> bc(y*z);
    For(i, y) For(j, z) bc[i*z+j] = b[i] + c[j];
    DeSort(bc);

    const int p = min(k, x), q = min(k, y*z);
    vector<ll> abc(p*q);
    For(i, p) For(j, q){
        abc[i*q+j] = a[i] + bc[j];
    }
    DeSort(abc);
    For(i, k) Cout(abc[i]);
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int g = 1;
    for (int i = min(a, b); i > 0; i--)
    {
        if (a % i == 0 && b % i == 0)
        {
            g = i;
            break;
        }
    }
    if (c % g == 0)
    {
        puts("YES");
    }
    else
    {
        puts("NO");
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


int expr();
int term();
int fact();

char buf[101];
int p;

int expr()
{
	int v = term();
	while (buf[p] == '+' || buf[p] == '-')
	{
		if (buf[p] == '+')
		{
			p++;
			v += term();
		} else {
			p++;
			v -= term();
		}
	}
	return v;
}

int term()
{
	int v = fact();
	while (buf[p] == '*' || buf[p] == '/')
	{
		if (buf[p] == '*')
		{
			p++;
			v *= fact();
		} else {
			p++;
			v /= fact();
		}
	}
	return v;
}

int fact()
{
	int v = 0;
	if (buf[p] == '(')
	{
		p++;
		v = expr();
		p++;
	} else {
		while (isdigit(buf[p]))
		{
			v = v * 10 + buf[p] - '0';
			p++;
		}
	}
	return v;
}


int main()
{
	int times, ans;
	
	cin >> times;
	rep(i, times)
	{
		cin >> buf;
		p = 0;
		ans = expr();
		cout << ans << endl;
	}
	
	return 0;
}


bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

ll gcd(ll a, ll b)
{
	return (b > 0) ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

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

int main () {
    int k, a, b;
    cin >> k >> a >> b;
    bool flag = false;
    for (int x = a; x <= b; x++) {
        if (x % k == 0) flag = true;
    }
    if (flag) printf("OK");
    else printf("NG");
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  cin >> n;
  vector <ll> a (n, inf), b (n - 1);

  rep (i, b.size ()) cin >> b [i];

  rep (i, b.size ())
  {
    a [i] = min (a [i], b [i]);
    a [i + 1] = min (a [i + 1], b [i]);
  }
  cout << accumulate (begin (a), end (a), typename iterator_traits <decltype (begin (a))>::value_type {}) << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String ans = "";
    for (int i = 0; i < 3; i++){
      String s[] = sc.next().split("");
      ans += s[0].toUpperCase();
    }
    System.out.println(ans);
  }
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#define IF_DEBUG 0
typedef long long ll;
typedef double db;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

int n, m, k;

int main()
{
	cin >> n >> m >> k;
	fo(i,0,n) fo(j,0,m)
	{
		int black = i*m+j*(n-i)-i*j;
		if(black == k) return 0*pf("Yes");
	}
	pf("No");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int main(){
	int sum=0,M=0;
	for(int i=0;i<3;i++){
		int A;
		cin>>A;
		sum+=A;
		M=max(M,A);
	}
	cout<<sum-M<<endl;
}

Measured memory_bytes: 256
use input::Input;

fn main() {
    let mut input = Input::default();

    let n = input.parse();
    if n == 1 {
        println!("0");
        return;
    }

    let v = f(n);

    let mut ans = 0;
    for x in v.iter() {
        let mut y = 0;
        let mut z = 0;
        while z + y + 1 <= x.1 {
            y += 1;
            z += y;
        }
        ans += y;
    }

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

fn f(mut x: u64) -> Vec<(u64, u64)> {
    let mut res = Vec::new();
    for i in 2..=x {
        if i * i > x {
            break;
        }
        let mut n = 0;
        while x % i == 0 {
            x /= i;
            n += 1;
        }
        if n > 0 {
            res.push((i, n));
        }
    }
    if x > 1 {
        res.push((x, 1));
    }
    res
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

/////////////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n;
	cin>>n;
	int k;
	cin>>k;
	int dp[n+1][k+1]={};
	int mo=1000000007;
	dp[0][0]=1;
	for(int i=1;i<=n;++i)
	{
		int d;
		cin>>d;
		++d;
		int x=0,c=0;
		for(int j=0;j<=k;++j)
		{
			++x;
			c+=dp[i-1][j];
			c%=mo;
			if(x>d){
				--x;
				c-=dp[i-1][j-x];
				c+=mo;
				c%=mo;
			}
			dp[i][j]=c;
		}
	}
	cout<<dp[n][k];
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  vector<ll> get,solve;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    get.push_back(a);
  }
  for(int i=n-1;i>=0;i--){
    ll pos=upper_bound(solve.begin(),solve.end(),get[i])-solve.begin();
    if(pos>=solve.size()) solve.push_back(get[i]);
    else solve[pos]=get[i];
  }
  cout<<solve.size()<<endl;
}


Measured memory_bytes: 2548