akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  const int MAX = 1e5;
  for(int n,m;cin>>n>>m,n;){
    int cost[m][m];
    int time[m][m];
    for(int i=0;i<m;i++){
      for(int j=0;j<m;j++){
	cost[i][j] = MAX;
	time[i][j] = MAX;
      }
    }
    int a,b,c,t;
    for(int i=0;i<n;i++){
      cin>>a>>b>>c>>t;
      cost[max(a-1,b-1)][min(a-1,b-1)] = c;
      time[max(a-1,b-1)][min(a-1,b-1)] = t;
    }
    for(int k=0;k<m;k++){
      for(int i=0;i<m;i++){
	for(int j=0;j<=i;j++){
	  int mai = max(i,k),mii=min(i,k);
	  int maj = max(j,k),mij=min(j,k);
	  if(cost[i][j]>cost[mai][mii]+cost[maj][mij])
	    cost[i][j] = cost[mai][mii]+cost[maj][mij];
	  if(time[i][j]>time[mai][mii]+time[maj][mij])
	    time[i][j] = time[mai][mii]+time[maj][mij];
	}
      }
    }
    int l,r;
    cin>>l;
    for(int i=0;i<l;i++){
      cin>>a>>b>>r;
      if(r)
	cout<<time[max(a-1,b-1)][min(a-1,b-1)]<<endl;
      else
	cout<<cost[max(a-1,b-1)][min(a-1,b-1)]<<endl;      
    }
  }
  return 0;
}

Measured memory_bytes: 940
n,m=map(int,input().split())

l=[0 for _ in range(n)]

for i in range(m):
  for j in map(int,input().split()):
    l[j-1]+=1

c=0
for i in range(n):
  if l[i]%2==1:
    c+=1
    break

if c==0:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 9940
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    double R;
    double L;
    cin >> R;
    L = M_PI * R * 2;
    cout << L;
    return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> Poly; 
const double EPS = 1e-10;

// 外積、符号付面積の２倍　|a||b|sinθ
double cross(Point a, Point b){
	// return a.real() * b.imag() - a.imag() * b.real();
	return (conj(a) * b).imag();
}
// 多角形の面積 = 任意の点pから隣接する2点へのベクトルの外積の総和/2
double poly_area(Poly p){
    if(p.size() < 3) return 0.0;
    double res = cross(p[p.size() - 1], p[0]);
    for(int i = 0; i < p.size() - 1; i++){
        res += cross(p[i], p[i + 1]);
    }
    return res / 2.0;
}

int main(){
    int n;
    cin >> n;
    Poly pl(n);
    for(int i = 0; i < n; i++){
        double x, y;
        cin >> x >> y;
        pl[i] = {x, y};
    }
    printf("%.1f\n", poly_area(pl));
}


Measured memory_bytes: 3212
#include<stdio.h>

#define SIZE 100001

int main(){
  int N,M;
  scanf("%d", &N);
  scanf("%d", &M);
  int X,Y;
  scanf("%d", &X);
  scanf("%d", &Y);

  int x[SIZE], y[SIZE];
  int xmax, ymin;
  for(int i=0; i<N; i++){
    scanf("%d", &x[i]);
    if(i==0 || xmax<x[i]) xmax=x[i];
  }
  for(int i=0; i<M; i++){
    scanf("%d", &y[i]);   
    if(i==0 || ymin>y[i]) ymin=y[i];
  }

  if(xmax>=ymin || ymin<=X || xmax>=Y){
    printf("War\n");
    return 0;
  }
  else{
    printf("No War\n");
    return 0;
  }

  /*
  while(1){
    int flag = 1;
    for(int i=1; i<3; i++){
      if(x[i-1]<x[i]){
	int tmp = x[i-1];
	x[i-1] = x[i];
	x[i] = tmp;
	flag = 0;
      }
    }
    if(flag) break;
  }

  int ans = x[0]*10+x[1]+x[2];
  printf("%d\n", ans);
  */
  return 0;
}


Measured memory_bytes: 128
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m,q=map(int,input().split())
T=[[0]*(n+2) for _ in range(n+2)]
for _ in range(m):
  l,r=map(int,input().split())
  T[l][r]+=1
for i in range(1,n+1)[::-1]:
  for j in range(1,n+1):
    T[i][j+1]+=T[i][j]
for j in range(1,n+1):
  for i in range(1,n+1)[::-1]: 
    T[i-1][j]+=T[i][j]

for _ in range(q):
  p,q=map(int,input().split())
  print(T[p][q])

Measured memory_bytes: 9740
N = int(input())
H = list(map(int, input().split()))  

count=0

for i in range(1,N-1):
    re_list=list([H[i-1],H[i],H[i+1]])
    re_list.sort()
    if re_list[1]==H[i]:
        count+=1


print(count)

Measured memory_bytes: 3060
#include<stdio.h>

int a[110][110];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)scanf("%d",&a[i][j]);
	for(int i=0;i<n;i++){
		int ans=0;
		for(int j=0;j<m;j++)ans+=a[i][j];
		a[i][m]=ans;
	}
	for(int j=0;j<=m;j++){
		int ans=0;
		for(int i=0;i<n;i++)ans+=a[i][j];
		a[n][j]=ans;
	}
	for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)printf("%d%c",a[i][j],j==m?'\n':' ');
}


Measured memory_bytes: 2120
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <unordered_set>
#include <string>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <thread>
#include <algorithm>
#include <iterator>

using namespace std;

const int N = 3e5 + 10;
vector <int> G[N];

pair <int, int> dfs(int v, int p = -1) {
	pair <int, int> lr = { 0, v };
	for (auto x : G[v]) {
		if (x == p) continue;
		auto res = dfs(x, v);
		res.first++;
		lr = max(lr, res);
	}
	return lr;
}

bool res(int x) {
	if (x % 3 == 1) {
		return false;
	}
	return true;
}

int main()
{
	srand(time(NULL));
	::ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	pair <int, int> lr = dfs(0);
	lr = dfs(lr.second);
	if (res(lr.first)) {
		cout << "First\n";
	}
	else {
		cout << "Second\n";
	}
	

	return 0;
}

Measured memory_bytes: 29184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i=1; i<=n; i++) {
        int v = i;
        int x = 0;
        while (v) {
            x += (v%10);
            v /= 10;
        }
        if (x>=a && x<=b) ans += i;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#! /usr/bin/env python3

# from math import gcd
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

import copy
H, W, K = [int(_) for _ in input().split()]
C = [input() for i in range(H)]

def calc(lis):
    global C, K

    c = copy.copy(C)

    for i in lis:
        if i // 10 == 1:
            c[i%10-1] = "-" * W
        else:
            for j in range(H):
                tmp = list(c[j])
                tmp[i-1] = "-"
                c[j] = "".join(tmp)

    ct = 0
    for i in c:
        a = Counter(i)
        ct += a["#"]
    
    if ct == K:
        return 1
    return 0
                
count = 0
lis = list(range(1, W + 1)) + list(range(11, 10 + H + 1))

ret = 0
for i in range(H+W):
    for com in list(combinations(lis, i)):
        ret += calc(com)

print(ret)


Measured memory_bytes: 10480
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	string S;
	cin>>S;
	int bcnt=0,wcnt=0;
	ll ans=0;
	REP(i,S.size()){
		if(S[i]=='W'){
			ans+=i-wcnt;
			wcnt++;
		}
		else bcnt++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 720
s = input()
n = len(s)
ls = [[0] for i in range(26)]
for i in range(n):
  x = ord(s[i])-97
  ls[x].append(i+1)
for i in range(26):
  ls[i].append(n+1)
ans = n
for i in range(26):
  ans = min(ans,max([ls[i][j]-ls[i][j-1] for j in range(1,len(ls[i]))]))
print(ans-1)

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

#define inf 1000000000

int minCostOptimized(int n, int* height) {
	int cost1 = 0, cost2 = inf, cost3 = 0;
	for (int i = 2; i <= n; i++) {
		int op1 = cost1 + abs(height[i - 1] - height[i]);
		int op2 = i == 2 ? inf : cost2 + abs(height[i - 2] - height[i]);
		cost3 = min(op1, op2);
		cost2 = cost1;
		cost1 = cost3;
	}
	return cost3;
}


int main() {
	int n;
	cin >> n;
	int* height = new int[n + 1];
	for (int i = 1; i <= n ; ++i)
	{
		cin >> height[i];
	}

	cout << minCostOptimized(n, height) << endl;
}

Measured memory_bytes: 3508
#include <stdio.h>
#include <string.h>
#define MAX 1001
int main(void)
{
	char str[MAX], work[MAX]={'\0'}, p[MAX], ope[8];
	int a, b, q, len, i, j;
	scanf("%s%d", str, &q);
	for(i=0; i<q; i++){
		scanf("%s", ope);
		switch(ope[2]){
			case 'i':
				scanf("%d%d", &a, &b);
				for(j=a; j<=b; j++){
					printf("%c", str[j]);
				}
				puts("");
				break;
			case 'v':
				scanf("%d%d", &a, &b);
				len = (int)strlen(str);
				strncpy(work, str, len);
				for(j=0; j<(b-a+1); j++){
					str[a+j] = work[b-j];
				}
				break;
			case 'p':
				scanf("%d%d%s", &a, &b, p);
				for(j=0; j<(b-a+1); j++){
					str[a+j] = p[j];
				}
				break;
			default:
				break;
		}
	}
	return 0;
}

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

using namespace std;

int N;
int M;
int X;
int Y;
int X1[102];
int Y1[102];

int main(){
  cin >> N >> M >> X >> Y;
  for(int i=0;i!=N;i++){
    cin >> X1[i];
  }
  for(int i=0;i!=M;i++){
    cin >> Y1[i];
  }
  sort(X1,X1+N,greater<int>());
  sort(Y1,Y1+M);
  if(Y1[0]<=X){
    cout << "War" << endl;
  }
  else if(X1[0]>=Y){
    cout << "War" << endl;
  }
  else if(Y1[0]<=X1[0]){
    cout << "War" << endl;
  }
  else{
    cout << "No War" << endl;
  }
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        N: i32,
        K: i32,
        As: [i32; N],
    }

    for i in K..N {
        if As[(i - K) as usize] < As[i as usize] {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


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

int main() {
  int K, S;
  cin >> K >> S;
  
  int count = 0;
  for (int x = 0; x <= K; x++) {
    if (x > S) break;
    for (int y = 0; y <= K; y++) {
      // cerr << x << ' ' << y << ' ' << S - (x + y) << endl; 
      if (x + y > S) break;
      if (S - (x + y) > K) continue;
      count++;
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
using namespace std;
int main()
{
	int n, m;
	cin>>n>>m;
	int ways = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++)	
			ways++;
	}
	for(int i = 0; i < m; i++){
		for(int j = i + 1; j < m; j++)
			ways++;
	}
	cout<<ways<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define INF 1000000000

int main()
{
	int n[100], x[100];
	int count = 0;
	int i, j,k;

	for (i = 0;; i++)
	{
		scanf("%d%d", &n[i], &x[i]);
		if (n[i] == 0 && x[i] == 0)
			break;

		count++;
	}

	int h;
	int sum = 0;

	for (h = 0; h < count; h++)
	{
		sum = 0;
		for (i = 1; i <= n[h]-2; i++)
		{
			for (j = i+1; j <= n[h]-1; j++)
			{
				for (k = j+1; k <= n[h]; k++)
				{
					if (i + k + j == x[h])
						sum++;
				}
			}
		}
		printf("%d\n", sum);
	}
	return 0;
}


Measured memory_bytes: 2028
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1000001;
const int XRZ = 1000000007;
int n, ans, jc[maxn] = {1};
int qpow(int a , int b) {
    int ans = 1;
    int base = a % XRZ;
	while(b > 0) {
        if(b & 1) {
            ans = (ans * base) % XRZ;
		}
		base = (base * base) % XRZ;
		b >>= 1;
	}
	return ans;
}
int c(int i, int j) {
	return jc[i] * qpow(jc[j] * jc[i - j] % XRZ, XRZ - 2) % XRZ;
}
signed main() {
	for(int i = 1; i <= 1000000; ++ i) {
		jc[i] = jc[i - 1] * i % XRZ;
	}
	cin >> n;
	for(int i = 1; i <= n; ++ i) {
		ans = (ans + (XRZ + qpow(2, i) - 2) * qpow(8, n - i) % XRZ * c(n, i)) % XRZ;
	}
	cout << ans;
	return 0;
}


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

#define int              long long 
#define FOR( i, m, n )   for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )      FOR( i, 0, n )
#define ALL( a )         (a).begin(), (a).end()

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

const int INF = 1e9;

signed main(){
  int b;
  while( cin >> b, b ){ 
    int n = 1, bottom = b;

    FOR( i, 1, sqrt( 2 * b ) ){
      int t = 2 * b / i - i + 1 ;
      if( 2 * b % i == 0 && t / 2 >= 1 && t % 2 == 0 ){
	if( chmax( n, i ) ) {
	  bottom = t / 2;
	}
      }
    }

    cout << bottom << " " << n << endl;
  }
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    ll h,w;
    cin >> h >> w;
    if(h == 1 || w == 1)cout << 1 << endl;
    else{
        cout << (h*w+1)/2 << endl;
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
//Product.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
        int b=sc.nextInt();
        
        int ans=a*b;
        if(ans%2==0){
            System.out.println("Even");
        }
        else{
            System.out.println("Odd");
        }
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, n);
	
	string s;
	function<void(int, int)> dfs = [&](int l, int k) {
		if(l == n) { OUT(s); return; }
		inc(i, k + 1) {
			s.PB('a' + i);
			dfs(l + 1, k + (i == k ? 1 : 0));
			s.pop_back();
		}
	};
	dfs(0, 0);
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000010
#define mod 1000000007
int n,f[MAXN],add;
int main()
{
    scanf("%d",&n);
    f[n]=n;
    f[n-1]=(long long)n*n%mod;
    for(int i=n-2;i>=1;--i)
    {
        add=(add+f[i+3])%mod;
        f[i]=f[i+1];
        f[i]=(f[i]+(long long)(n-1)*(n-1)%mod)%mod;
        f[i]=(f[i]+add)%mod;
        f[i]=(f[i]+i+1)%mod;
    }
    printf("%d\n",f[1]);
}

Measured memory_bytes: 4096
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int H,N; cin>>H>>N;
  vi A(N); REP(i,N) cin>>A[i];

  int sum = 0;
  REP(i,N) sum+=A[i];

  string ans = sum>=H ? "Yes" : "No";
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? 0 : 1) << "\n";
}
constexpr double EPS = 1e-8;
int GaussJordan(vector<vector<int>> &A, bool is_extended = false) {
    int m = A.size(), n = A[0].size();
    int rank = 0;
    for (int col = 0; col < n; ++col) {
        if (is_extended && col == n-1) break;
        int pivot = -1;
        int ma = EPS;
        for (int row = rank; row < m; ++row) {
            if (abs(A[row][col]) > ma) {
                ma = abs(A[row][col]);
                pivot = row;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < m; ++row) {
            if (row != rank && abs(A[row][col]) > EPS) {
                for (int col2 = 0; col2 < n; ++col2) {
                    A[row][col2] ^= A[rank][col2];
                }
            }
        }
        rank++;
    }
    return rank;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin >> T;
    REP(t, T) {
        int N;
        cin >> N;
        vector<lint> A(N);
        REP(i, N) cin >> A[i];
        string S;
        cin >> S;
        vector<vector<int>> X;
        bool flg = true;
        int rank = 0;
        IREP(i, N) {
            vector<int> tmp(60);
            REP(k, 60) if((A[i]>>k&1)==1) tmp[k] = 1;
            X.push_back(tmp);
            int rank2 = GaussJordan(X);
            //cout << i << " " << rank2 << "\n";
            if(rank2 > rank && S[i] == '1') {
                flg = false;
                break;
            }   
            rank = rank2; 
        }
        yes(flg);  
    }
}

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

int main(){
  long long n;
  cin>>n;
  long long ans;
  bool ok=false;
 for(long long i=0;i<=n;i++){
    if(n<=i*1.08 && i*1.08<n+1){ok=true;
                  ans=i;
                  break;
                 }
  }
  if(ok)cout<<ans<<endl;
  else cout<<":("<<endl;
  
    
}


Measured memory_bytes: 256
from itertools import accumulate
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(k):
    b = [0] * (n + 1)
    for j in range(n):
        b[max(0, j - a[j])] += 1
        b[min(n, j + a[j] + 1)] -= 1
    a = list(accumulate(b))
    if sum(a) == n ** 2:
        a.pop()
        print(*a)
        exit()

a.pop()
print(*a)

Measured memory_bytes: 181264
#include <iostream>
#include <complex>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;
typedef complex<double> Point;
typedef pair<Point,Point> Line;
typedef pair<Point,double> Circle;
typedef vector<Point> Poly;
#define X real()
#define Y imag()
const double EPS = (1e-10), pi = acos(-1);

double dot(Point a,Point b){
    return a.X * b.X + a.Y * b.Y;
}

double cross(Point a,Point b){
    return a.X * b.Y - a.Y * b.X;
}

Point projection(Point a,Point b){
    return dot(a, b) / abs(b) / abs(b) * b;
}

int ccw(Point a,Point b,Point c) {
    b -= a; c -= a;
    if(cross(b,c) > EPS) return +1;
    if(cross(b,c) < -EPS) return -1;
    if(dot(b,c) < 0) return +2;
    if(abs(b) + EPS < abs(c)) return -2;
    return 0;
}

double pointSegmentDistance(Point a,Line s){
    Point sf = s.first, ss = s.second;
    if(dot(ss-sf,a-sf) >= 0 && dot(sf-ss,a-ss) >= 0)
        return abs(cross(sf-ss,a-ss))/abs(sf-ss);
    return min(abs(a-sf), abs(a-ss));
}

double pointLineDistance(Point a, Line s){
    Point sf = s.first, ss = s.second;
    return abs(cross(sf-ss,a-ss))/abs(sf-ss);
}

vector<Point> cpcl(Circle c,Line l){
    double d = pointLineDistance(c.first,l), r = c.second;
    Point m = l.first + projection(c.first-l.first,l.second-l.first);
    Point x = sqrt(r*r-d*d)/abs(l.second-l.first)*(l.second-l.first);
    vector<Point> cp(2,m);
    cp[0] -= x;
    cp[1] += x;
    return cp;
}

double getCirclePolyArea(Circle c,Poly p){
    double ret = 0, r = c.second;
    int n = p.size();
    for(int i = 0; i < n; ++i) p[i] -= c.first;
    for(int i = 0; i < n; ++i){
        if(abs(p[i]*p[(i+1)%n]) < EPS) continue;
        double d = arg(p[(i+1)%n]/p[i]);
        ret += r*r*d/2.0;
        if(pointSegmentDistance(Point(0,0),Line(p[i],p[(i+1)%n])) < r - EPS){
            vector<Point> cps = cpcl(Circle(Point(0,0),r),Line(p[i],p[(i+1)%n]));
            Point a, b;
            if(ccw(p[i],p[(i+1)%n],cps[0]) == 0 &&
               ccw(p[i],p[(i+1)%n],cps[1]) == 0)
                a = cps[0], b = cps[1];
            else if(!ccw(p[i],p[(i+1)%n],cps[0]))
                a = cps[0], b = p[(i+1)%n];
            else if(!ccw(p[i],p[(i+1)%n],cps[1]))
                a = p[i], b = cps[1];
            else
                a = p[i], b = p[(i+1)%n];
            if(abs(a*b) < EPS) continue;
            d = arg(b/a);
            ret += cross(a,b)/2.0 - r*r*d/2.0;
        }
    }
    return ret;
}

int main(){
    int n;
    double r;
    cin >> n >> r;
    Poly Pol;
    Circle circle(Point(0,0),r);
    for(int i = 0;i < n;++i){
        double x,y;
        cin >> x >> y;
        Point p(x,y);
        Pol.push_back(p);
    }
    double ans = getCirclePolyArea(circle,Pol);
    printf("%.12f\n",ans);
}



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

int main(void)
{
    long long int k, a, b, ans;
    cin >> k >> a >> b;

    if (b <= a) {
        cout << k + 1 << endl;
    }else {
        
        ans = a + ((k - (a - 1))/2)*(b - a);
        if ((k - (a - 1)) % 2 > 0) ans++;

        if (k + 1 > ans){
            cout << k + 1 << endl;
        }else {
            cout << ans << endl;
        }
    }

    return 0;
}

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

using namespace std;


int main(){
    string str, com, p, STR;
    int q, a, b;
    cin >> str >> q;
    for (int i = 0; i < q; i++) {
        cin >> com >> a >> b;
        if (com == "print") {
            cout << str.substr(a, b-a+1) << endl;
        }
        else if (com == "reverse") {
            STR = str.substr(a, b-a+1);
            for (int i = 0; i < STR.size(); i++) {
                str[a+i] = STR[STR.size()-i-1];
            }
        }
        else if (com == "replace") {
            cin >> p;
            str.replace(a, b-a+1, p);
        }
    }
    return 0;
}


Measured memory_bytes: 3196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	 int n = Integer.parseInt( br.readLine() );
	 int cnt;

	 int m = n;
	 int [] G = new int[m];
	 //G[0] = 4;
     //G[1] = 1;
	 G[0] = 1;

	 int I;
	 for (I = 0; I < 100 && G[I] < m; I++) {
         G[I + 1] = 3 * G[I] + 1;
     }

     if(I>0){
    	 m = I;
     }

    int [] A = new int[n];
    for(int i = 0; i < n ; i++){
          A[i] = Integer.parseInt( br.readLine() );
    }

    cnt = 0;
    for(int i = 0; i < m ; i++){

       for( int j = G[(m-1)-i]; j < n ; j++ ){
    	   int v = A[j];
    	   int x = j - G[(m-1)-i];

    	   while( x >= 0 && A[x] > v ){
    		   A[x+G[(m-1)-i]] = A[x];
               x = x-G[(m-1)-i];
               cnt++;
    	   }
    	   A[x+G[(m-1)-i]] = v;

       }

    }

     System.out.println(m);
    for(int i = 0; i < m ; i++){
    	System.out.print(G[(m-1)-i]);
        if(i < m-1){
            System.out.print(" ");
        }
    }
    System.out.println();
    System.out.println(cnt);

    for(int i = 0; i < n ; i++){
    	System.out.println(A[i]);

    }

 }
}

Measured memory_bytes: 102696
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
//#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)
     
using namespace std;
      
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<ll> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<ll, ll, ll> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<ll> > vvi;
typedef vector<char> vc;
      
const ll INF = 1e9 + 228;
const ll INFLL = 1e18;
const ll MOD = 1e9 + 7;
//static const int maxn = 2e5 + 228;;
const ld eps = 1e-7;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1<<18);
const ld PI = atan2l(0, -1);
     
void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef DEBUG
//      freopen("haybales.in", "r", stdin);
//      freopen("haybales.out", "w", stdout);
    #endif
}

void solve(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<set<int> > ch(26);
	for(int i=0; i<n; i++){
		ch[s[i]-'a'].insert(i);
	}
	int m;
	cin >> m;
	for(int i=0; i<m; i++){
		int t;
		cin >> t;
		if(t==1){
			int pos;
			char c;
			cin >> pos >> c;
			pos--;
			ch[s[pos]-'a'].erase(pos);
			s[pos] = c;
			ch[s[pos]-'a'].insert(pos);
		} else{
			int l, r;
			cin >> l >> r;
			l--, r--;
			int ans = 0;
			for(int i=0; i<26; i++){
				auto it = ch[i].lower_bound(l);
				if(it == ch[i].end()){
					continue;
				}
				ans += (*it<=r);
			}
			cout << ans << endl;
		}
	}
}

signed main(){
        fast_io();
	srand(time(NULL));
//	cout << fixed << setprecision(12);
	int q = 1;
//	cin >> q;
	while(q--)
		solve();
     
}





Measured memory_bytes: 24184
#include<iostream>
#include<vector>

using namespace std;

int main(){
	int sunuke, okashi;
  
  	cin>>sunuke>>okashi;
  
  	vector<int> d(okashi);
  	vector<vector<int> > A(okashi);
  	
  	for(int i=0;i<okashi;i++){
  	cin>>d.at(i);
      //cout<<i<<"番目"<<d.at(i)<<endl;


      for(int j=0;j<d.at(i);j++){
        int num;
        cin>>num;
        A.at(i).push_back(num);
      	
      }
    }
    int k;
    vector<int> count(sunuke, 0);
      for(int i=0;i<okashi;i++){
        for(int j=0;j<d.at(i);j++){
          for(k=0;k<sunuke;k++){
            if(A.at(i).at(j)==k+1){
              count.at(k)++;
            }
          }
        }

      }

      int itazura=0;
      for(int i=0;i<sunuke;i++){
        if(count.at(i)==0){
          itazura++;
        }
      }

      cout<<itazura<<endl;

}

Measured memory_bytes: 3628
#include <stdio.h>
#include <math.h>

 typedef struct{
  double x;
  double y;
}XY;
 
void kock(int,XY,XY);

int main(){
  int n;
  XY P1,P2;
  P1.x=0.0;
  P1.y=0.0;
  P2.x=100.0;
  P2.y=0.0;

  
  scanf("%d",&n);
 printf("%.8f %.8f\n",P1.x,P1.y);
  kock(n,P1,P2);
 printf("%.8f %.8f\n",P2.x,P2.y);
  return 0;

}

void kock(int n,XY p1,XY p2)
{
  XY s,t,u;
 
  if(n == 0) return;
 
  s.x = ((2 * p1.x) + (1 * p2.x)) /3;
  s.y = ((2 * p1.y) + (1 * p2.y)) /3;
  t.x = ((1 * p1.x) + (2 * p2.x)) /3;
  t.y = ((1 * p1.y) + (2 * p2.y)) /3;
  u.x = (t.x - s.x) * 1/2 - (t.y - s.y) * sqrt(3) /2 + s.x;
  u.y = (t.x - s.x) * sqrt(3) /2 + (t.y - s.y) * 1/2 + s.y;
 
  kock(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
 
  kock(n-1,t,p2);
}

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

const int INF = 1e8;

int main()
{
	int T;
	while (cin >> T, T) {
		vector<int> t(T);
		for (int i = 0; i < T; i++) {
			cin >> t[i];
		}
		vector<int> H(100, 24);
		int N;
		cin >> N;
		for (int i = 0; i < N; i++) {
			int D, M;
			cin >> D >> M; D--;
			H[D] = min(H[D], M);
		}
		vector<vector<int>> dp(100, vector<int>(T, INF));
		dp[0][0] = 0;
		for (int i = 1; i < 100; i++) {
			for (int j = 0; j < T; j++) {
				if (dp[i - 1][j] != INF) {
					dp[i][0] = min(dp[i][0], dp[i - 1][j] + 1);
					if (t[(j + 1) % T] <= H[i]) {
						dp[i][(j + 1) % T] = min(dp[i][(j + 1) % T], dp[i - 1][j]);
					}
				}
			}
		}
		int res = INF;
		for (int i = 0; i < T; i++) {
			res = min(res, dp[99][i]);
		}
		cout << res << endl;
	}
	return 0;
}

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

N = int(input())
S = input()
if(N%2 != 0):
  print('No')
else:
  s1 = S[:int(N/2)]
  s2 = S[int(N/2):]
  if(s1 == s2):
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<complex>
#include <string>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)n; i++)
 
int main(){
	string s;
	cin >> s;
	int slen = (int)s.length();

    int bit = 1 << (slen-1);
    long ans = 0;
    rep(i, bit) {
        int end_s = 0;
        int res_bit = i;
        rep(j, slen) {
            if (i & (1<<j)) {
                long sub = atoll(s.substr(end_s, j - end_s + 1).c_str());
                ans += sub;
                end_s = j + 1;
            }
            res_bit = res_bit / 2;
        }
        long sub = atoll(s.substr(end_s, slen-end_s).c_str());
        ans += sub;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
   int N, K; cin >> N >> K;
   vector<long long> x;
   x.resize(N);
   for(int i=0; i < N; i++) cin >> x[i];
   long long res = 1ll<<60;
   for(int i=0; i+K-1 < N; i++) {
       long long left = x[i], right = x[i + K - 1];
       res = min(res, min(abs(left), abs(right)) - left + right);
   }
   cout << res << endl;
}

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

int main () {
  int w, a, b;
  cin >> w >> a >> b;
  if(b > a + w) {
    cout << (b - a - w);
  } else if(b + w < a) {
    cout << (a - b - w);
  } else {
    cout << 0;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        // 宣言
        Scanner sc  = new Scanner(System.in);
        int count = 0;
        // 入力値取得
        int rod = sc.nextInt();
        int lens[] = new int[rod];
        while(sc.hasNext()){
            lens[count] = sc.nextInt();
            count++;
        }
        
        // Arrays.sort(lens);
        // 組み合わせ抽出処a理
        Arrays.sort(lens);
        count = 0;
        for(int i=0;i<lens.length;i++){
            for(int j=i+1;j<lens.length;j++){
                for(int k=j+1;k<lens.length;k++){
                    if( (lens[i] < (lens[j] + lens[k])) && (lens[j] < (lens[k] + lens[i])) && (lens[k] < (lens[i] + lens[j])) ){
                        count++;                        
                    }
                    
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26044
#include <stdio.h>


int main(){
    long long n,a,b;
    scanf("%lld %lld %lld",&n,&a,&b);
    long long blue = a*(n/(a + b));
    if(n % (a + b) >= a){
        blue += a;
    }else{
        blue += n % (a + b);
    }
    printf("%lld",blue);
    return 0;
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	char c;
	cin>>c;++c;
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n,m=get_i
m/=2
if n>=m
  puts m
else
  puts n+(m-n)/2
end

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	/*1000????????????????????§long long int ????????????????????????????????§string??§??¨???*/
	/*string????????????????????????????????¨???????????¨char??????????????????????????§-'0'?????????????????¨??°?????¨????????¨??????*/

	string str;
	while(1){
		cin >> str;
		if(str=="0") break;
		ll int sum = 0;
		REP(i,str.size()){
			sum += (int)(str[i]-'0');
		}
		cout << sum  << endl;
	}
}

Measured memory_bytes: 1188
import sys
input = sys.stdin.readline
n,m,p = map(int,input().split())
abd = [list(map(int,input().split())) for i in range(m)]
come = [[] for i in range(n+1)]
for a,b,d in abd:
  come[b].append(a)
visitable = [0]*(n+1)
stack = [n]
visitable[n] = 1
while stack:
  x = stack.pop()
  for y in come[x]:
    if visitable[y] == 0:
      visitable[y] = 1
      stack.append(y)
score = [10**15 for i in range(n+1)]
score[1] = 0
for j in range(n+1):
  flg = 0
  for i in range(m):
    v1,v2,e = abd[i]
    if visitable[v1] & visitable[v2] == 0:
      continue 
    e = -e+p
    if score[v1] != 10**15 and score[v2] > score[v1]+e:
      score[v2] = score[v1]+e
      flg = 1
      if j == n-1:
        last = score[:]
      if j == n:
        onemore = score[:]
  if flg == 0:
    break
if flg == 0:
  print(max(0,-score[n]))
else:
  if last == onemore:
    print(max(last[n],0))
  else:
    print(-1)

Measured memory_bytes: 47964
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
s = 0
arr = list()
for i in range(n):
  arr.append(v[i] - c[i])
for i in range(n):
  if arr[i] > 0:
    s += arr[i]
print(s)

Measured memory_bytes: 3060
#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

// ?????¬???????????¬??????
#define REP(i,n) for(int i=0; i<(int)n; ++i)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), c.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<long, long> pil;

// ??°?????????????????¬??????
typedef int Weight;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;


int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if (a < b && b < c) printf("Yes\n");
  else printf("No\n");

  return 0;
}

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

#define pb push_back


using namespace std;

int dfs(int src,vector<int> &dp,vector<vector<int>>&adj,map<int ,int > &visted)
{
    visted[src]++;
    for(int i:adj[src])
    {
        if(visted.find(i)==visted.end())
        {
            dp[src]=max(dp[src],dfs(i,dp,adj,visted)+1);
        }
        else
        {
            dp[src]=max(dp[src],dp[i]+1);
        }
    } 
    return dp[src];
}
int32_t main()
{
    int n;
    int k;
    cin>>n>>k;
    vector<vector<int>>adj(n+1);
    while(k--)
    {
         int a;
         int b;
         cin>>a>>b;
         adj[a].push_back(b);
    }

    vector<int> dp(n+1,0);

    map<int ,int > visted;

    for(int i=1;i<=n;i++)
    { 
        if(visted.find(i)==visted.end())
        {
            dp[i]=dfs(i,dp,adj,visted);
        }
    }
   
    cout<<*max_element(dp.begin(),dp.end());

}


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

int main()
{
    long Q,H,S,D;
    cin >> Q >> H >> S >> D;
    long N;
    cin >> N;
    long min,min1;
    if(2*Q<H) min=2*Q;
    else min=H;
    if(2*min<S) min=2*min;
    else min=S;
    if(2*min<D) min1=2*min;
    else min1=D;
    long long sum;
    if(N%2==0) sum=(N/2)*min1;
    else sum=((N-1)/2)*min1+min;
    cout << sum << endl ;
    return 0;
}

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

namespace AGC35
{
    class Program
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var ans = 0;
            foreach (var i in a)
                ans ^= i;
            if (ans == 0)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 20064
import numpy as np
n,t=map(int,input().split())
T=np.array(list(map(int,input().split())))
S=T+t
temp=0
for i in range(n-1):
    if T[i+1]-S[i]>0:
        temp+=T[i+1]-S[i]
print(S[n-1]-temp)

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

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b)
  {
    if(b!=c)
    {
      cout << "Yes" << endl;
    }
    else 
    {
      cout << "No" << endl;
    }
  }
  else if (a==c)
  {
    if(a!=b)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }
  else if(b==c)
  {
    if(a!=b)
    {
      cout << "Yes" << endl;
    }
    else 
    {
      cout << "No" << endl;
    }
  }
  else 
  {
cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
public class Main {
      public static void main(String[] args) {
    	java.util.Scanner scanner = new java.util.Scanner(System.in);
    	int n = scanner.nextInt();
    	int[] a = new int[n];
            int mincount = Integer.MAX_VALUE;
    	for (int i = 0; i < n; i++) {
    		a[i] = scanner.nextInt();
    	}
    	
            for (int i = 0; i < n; i++ ) {
                    int count = 0;
                    while(a[i] % 2 == 0) {
                            a[i] = a[i] / 2;
                            count++;
                    }
                    mincount = Math.min(mincount, count);
            }
    	System.out.println(mincount);
      }
    }

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 998244353

long mod_pow(long x, long n, long p=MOD){
  if(x==0) return 0;
  long res=1;
  x %= p;
  while(n>0){
    if(n&1) res=res*x%p;
    x=x*x%p;
    n>>=1;
  }
  return res;
}

int main(){
  int n;
  cin>>n;
  vector<int> x(n),y(n);
  rep(i,n) cin>>x[i]>>y[i];

  long ans = mod_pow(2, n);
  ans -= n+1; // size = 0,1

  map<pair<pair<int,int>, int>, set<int>> ma;
  rep(i,n) rep(j,i){
    int dx = x[i] - x[j];
    int dy = y[i] - y[j];
    int g = __gcd(dx,dy);
    dx /= g; dy /= g;
    if(dx<0 || (dx==0 && dy<0)) dx*=-1, dy*=-1;
    auto key = mp(mp(dx,dy), x[i]*dy - y[i]*dx);
    ma[key].insert(i);
    ma[key].insert(j);
  }

  for(auto &&p : ma){
    int sz = p.se.size();
    long rm = mod_pow(2, sz) - sz - 1;
    ans -= rm;
  }

  ans %= MOD;
  if(ans<0) ans += MOD;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4352
import math
from typing import List, NoReturn


def sum_gcd(k: int) -> int:
    cache: List[List[List[int]]] = [[[0] * (k + 1) for i in range(k + 1)] for j in range(k + 1)]

    def cached_gcd(a: int, b: int, c: int) -> int:
        k0: int
        k1: int
        k2: int
        k0, k1, k2 = sorted([a, b, c])

        result: int = cache[k0][k1][k2]
        if result > 0:
            return result
        else:
            result = math.gcd(math.gcd(k0, k1), k2)
            cache[k0][k1][k2] = result
            return result

    answer: int = 0
    for h in range(1, k + 1):
        for i in range(1, k + 1):
            for j in range(1, k + 1):
                answer += cached_gcd(h, i, j)

    return answer


def main() -> NoReturn:
    k: int = int(input().rstrip())
    print(sum_gcd(k))


if __name__ == '__main__':
    main()


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

int main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	//freopen("text.in", "r", stdin);
	//freopen("text.out", "w", stdout);

	int n, m;
	cin >> n >> m;
	if ((n + m) % 2 == 0)cout << (n + m) / 2 << '\n';
	else cout << "IMPOSSIBLE" << '\n';

	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using ll = long long;

struct Q
{
	ll a, b;
};

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

	vector<Q> q1, q2;

	rep(i, n)
	{
		string s;
		cin >> s;

		Q q = {};
		{
			ll close = 0, open = 0;
			rep(j, s.length())
			{
				if (s[j] == ')')
				{
					close++;
				}
				if (s[j] == '(')
				{
					open++;
				}
				q.a = max(q.a, close - open);
			}
		}
		reverse(all(s));
		{
			ll close = 0, open = 0;
			rep(j, s.length())
			{
				if (s[j] == ')')
				{
					close++;
				}
				if (s[j] == '(')
				{
					open++;
				}
				q.b = max(q.b, open - close);
			}
		}

		if (q.b - q.a >= 0)
			q1.push_back(q);
		else
			q2.push_back(q);
	}

	//auto p = &Q::a;
	//auto f = [p](Q x, Q y)
	//{
	//	return x.*p < y.*p;
	//};

	sort(all(q1), [](const Q& x, const Q& y) {
		return x.a < y.a;
		});

	//p = &Q::b;
	sort(all(q2), [](const Q& x, const Q& y) {
		return x.b > y.b;
		});

	ll pos = 0, min_pos = 0;
	rep(i, q1.size())
	{
		pos -= q1[i].a;
		min_pos = min(min_pos, pos);
		pos += q1[i].b;
	}
	rep(i, q2.size())
	{
		pos -= q2[i].a;
		min_pos = min(min_pos, pos);
		pos += q2[i].b;
	}

	if (pos == 0 && min_pos >= 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 18576