akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int N, Y;
	cin >> N >> Y;

	int ret[3] = {-1, -1, -1};

	for(int i=0; i<=N; i++){
		for(int j=0; j<=N-i; j++){
			int k = N - i - j;
			int sum = 10000*i + 5000*j + 1000*k;
			if(sum == Y){
				ret[0] = i;
				ret[1] = j;
				ret[2] = k;

				i = j = k = N;
				break;
			}
		}		
	}

	for(int i=0; i<3; i++)
		cout << ret[i] << (i!=2 ? ' ' : '\n');

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <vector>
#include <unordered_map>
#include <utility>

int main() {
  std::int64_t n, m;
  std::vector<std::int64_t> a;
  std::vector<std::int64_t> s;

  std::cin >> n >> m;
  s.push_back(0);
  for (std::int64_t i = 0; i < n; ++i) {
    std::int64_t a_i;
    std::cin >> a_i;
    a.push_back(a_i % m);
    s.push_back((s.back() + a_i) % m);
  }

  std::unordered_map<std::int64_t, std::int64_t> map;
  for (const std::int64_t& s_i : s) {
    ++map[s_i];
  }

  std::int64_t sum = 0;
  for (const std::pair<std::int64_t, std::int64_t>& kv : map) {
    if (kv.second > 1) {
      sum += kv.second * (kv.second - 1) / 2;
    }
  }

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

Measured memory_bytes: 5228
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int x=sc.nextInt();
		int tostart=0;
		int togoal=0;

		for(int i=0;i<m;i++) {
			int buf=sc.nextInt();
			if(buf<x) {
				tostart++;
			}else {
				togoal++;
			}
		}
		int ans=(tostart<togoal)?tostart:togoal;
		System.out.println(ans);
	}

}

Measured memory_bytes: 21844
n = int(input())
d, x = map(int, input().split())
total = x
for i in range(n):
    y = int(input())
    total += 1
    for j in range(1, 100):
        current = y * j + 1
        if current <= d:
            total += 1
        else:
            break
print(total)


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  vector<string> s(3);
  rep(i, 3) cin >> s[i];
  int t = 0;
  int now = 0;
  while(s[now].size() != 0) {
    
    now = (s[t][0] - 'a');
    s[t].erase(0, 1);
    t = now;
  }
  
  string ans = "";
  ans = now + 'A';
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  char ch[3];
  cin>>ch;
  for(int i = 0;i<3;i++)
  {
    if(ch[i]=='9')
       ch[i] = '1';
    else if(ch[i]=='1')
       ch[i] = '9';
  }
  
  cout<<ch<<endl;
  }

Measured memory_bytes: 3584
import sys

#+++++
		
def main():
	R,G,B,N = map(int, input().split())
	cc=0
	ri=0
	while ri * R <= N:
		gi=0
		while G*gi + ri*R <= N:
			nn=N-(G*gi+R*ri)
			if nn % B == 0:
				cc+=1
			gi+=1
		ri+=1
	
	print(cc)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    ct=1
    alp='abcdefghijklmnopqrstuvwxyz'
    for i in range(1,16):
        temp=n-26**i
        #print(temp)
        if temp<=0:
            n-=1
            break
        else:
            n=temp
            ct+=1
    
    
    name=['a']*ct
    n_t=[]
    
    while n!=0:
        a=n%26
        n_t.insert(0,alp[a])
        n=n//26
    l=len(n_t)
    #print(ct,l)
    #print(n_t)
    #print(name[0:ct-l])
    ans=name[0:ct-l]+n_t
    
    print(*ans,sep='')
        
if __name__ == '__main__':
    do()

Measured memory_bytes: 9224
#include <iostream>
#include <string>
#include <vector>
#include <stack>
using namespace std;

class BinaryTree
{
public:
	BinaryTree *parent;
	BinaryTree *left;
	BinaryTree *right;
	int no;

	BinaryTree()
	{
		parent	= NULL;
		left	= NULL;
		right	= NULL;
		no		= 1;
	}

	BinaryTree( BinaryTree *p )
	{
		parent	= p;
		left	= NULL;
		right	= NULL;
		no		= p->no + 1;
	}
};

vector <BinaryTree> Nodes( 5000 );
int Nodes_cnt = 0;

BinaryTree getTree( string in )
{
	stack <int> lrs;
	int lr = 0;

	BinaryTree	root;
	BinaryTree*	now;

	bool first = true;
	now = &root;

	for ( string::iterator it = in.begin(); it != in.end(); it++ )
	{
		if ( first )
		{
			first = false;
			continue;
		}

		if ( *it == '(' )
		{
			if ( lr == 0 )
			{
				now->left  = new BinaryTree( now );
				now = now->left;
			}
			else
			{
				now->right = new BinaryTree( now );
				now = now->right;
			}

			lrs.push( lr );
			lr = 0;
		}
		else if ( *it == ')' )
		{
			if ( now->parent != NULL )
			{
				now = now->parent;
				lr = lrs.top();
				lrs.pop();
			}

		}
		else if ( *it == ',' )
		{
			lr++;
		}
	}

	return root;
}

void printTree( BinaryTree* tree )
{
	cout << "(";
	if ( tree->left != NULL )
		printTree( tree->left );
	cout << ",";
	if ( tree->right != NULL )
		printTree( tree->right );
	cout << ")";
}

BinaryTree* getIntersection( BinaryTree* a, BinaryTree* b, BinaryTree* p )
{
	// ツ仰、ツ津環づ按閉板閉ェツづーツ個ゥツづつつッツづゥ
	int nc = Nodes_cnt;
	Nodes_cnt++;
	BinaryTree& node = Nodes[nc];
	if ( p == NULL )
		node = BinaryTree();
	else
		node = BinaryTree( p );

	if ( ( a != NULL && a->left != NULL ) && ( b != NULL && b->left != NULL ) )
	{
		BinaryTree* next = getIntersection( a==NULL?NULL:a->left, b==NULL?NULL:b->left, &node );
		node.left = next;
	}
	if ( ( a != NULL && a->right != NULL ) && ( b != NULL && b->right != NULL ) )
	{
		BinaryTree* next = getIntersection( (a==NULL?NULL:a->right), (b==NULL?NULL:b->right), &node );
		node.right = next;
	}

	return &Nodes[nc];
}

BinaryTree* getUnion( BinaryTree* a, BinaryTree* b, BinaryTree* p )
{
	// ツづづつソツつゥツづ可甘慊づ慊づェツづつ「ツづゥツづ按づァOK
	int nc = Nodes_cnt;
	Nodes_cnt++;
	BinaryTree& node = Nodes[nc];
	if ( p == NULL )
		node = BinaryTree();
	else
		node = BinaryTree( p );

	if ( ( a != NULL && a->left != NULL ) || ( b != NULL && b->left != NULL ) )
	{
		BinaryTree* next = getUnion( (a==NULL?NULL:a->left), (b==NULL?NULL:b->left), &node );
		node.left = next;
	}
	if ( ( a != NULL && a->right != NULL ) || ( b != NULL && b->right != NULL ) )
	{
		BinaryTree* next = getUnion( (a==NULL?NULL:a->right), (b==NULL?NULL:b->right), &node );
		node.right = next;
	}

	return &Nodes[nc];
}

int main( void )
{
	string type;
	string in_a;
	string in_b;

	while ( cin >> type >> in_a >> in_b )
	{
		BinaryTree a_root = getTree( in_a );
		BinaryTree b_root = getTree( in_b );

		if ( type == "i" )
		{
			BinaryTree* intersectionTree = getIntersection( &a_root, &b_root, NULL );
			printTree( intersectionTree );
			cout << endl;
		}
		else if ( type == "u" )
		{
			BinaryTree* unionTree = getUnion( &a_root, &b_root, NULL );
			printTree( unionTree );
			cout << endl;
		}
	}

}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int A, P;
  cin >> A >> P;
  cout << (A * 3 + P) / 2 << endl;
  return 0;
}


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

int main(){
	int N, M, C;
	cin>>N>>M>>C;
	int B[M];
	int i=0;
	for(i=0;i<M;i++){
		cin>>B[i];
	}
	int A[N][M];
	for(int k=0;k<N;k++){
		for(int l=0;l<M;l++){
			cin>>A[k][l];
		}
	}

	int kosu=0;
	int source=0;	
	for(int j=0;j<N;j++){
		int wa=0;
		for(int m=0;m<M;m++){
			wa += A[j][m]*B[m];
		}
		wa += C;
		if(wa>0){
			kosu += 1;
		}	
	}	
	cout<<kosu;
	return 0;
}	


Measured memory_bytes: 256
#include<stdio.h>

int func(int a,int b)
{
    int r = a % b;
    while( r > 0 )
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int main(void)
{
    int w,h,c,s;
    
    scanf("%d %d %d",&w,&h,&c);
    
    s = func(w,h);
    
    w = w / s;
    h = h / s;
    
    printf("%d\n",h*w*c);
    
    return 0;
}


Measured memory_bytes: 2056
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
ll T,n,m;
const int fact[10] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
int p[20];
int q[20];
int main() {
	int a[20];
	a[1] = 1;
	for(int i=2;i<9;i++)
		a[i] = a[i-1]*i;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>p[i];
	for(int i=0;i<n;i++)
		cin>>q[i];
	int cnt1=0,cnt2=0;
    for (int i = 0; i < n; ++i) {
        int cnt = 0; // 在 i 之后，比 i 还小的有几个
        for (int j = i + 1; j < n; ++j)
            if (p[i] > p[j]) ++cnt;
        cnt1 += cnt * fact[n - i - 1];
    }
	for (int i = 0; i < n; ++i) {
        int cnt = 0; // 在 i 之后，比 i 还小的有几个
        for (int j = i + 1; j < n; ++j)
            if (q[i] > q[j]) ++cnt;
        cnt2 += cnt * fact[n - i - 1];
    }
	cout<<abs(cnt1-cnt2)<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	const mod = int(1e9 + 7)

	k8, k9, k10 := 1, 1, 1
	for i := 0; i < n; i++ {
		k8 *= 8
		k8 %= mod
		k9 *= 9
		k9 %= mod
		k10 *= 10
		k10 %= mod
	}
	ans := (k10 - k9*2 + k8) % mod
	if ans < 0 {
		ans += mod
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

int main() {
  int N , M , count ;
  cin >> N >> M ;
  vector<int> vec(2*M) ;
  for ( int i = 0 ; i < 2 * M ; i++ ){
    cin >> vec.at(i) ;
  }
  
  for ( int i = 0 ; i < N ; i++ ){
    count = 0 ;
    for ( int j = 0 ; j < 2 * M ; j++ ){
      if ( vec.at(j) == i + 1 ){
        count++;
      }
    }
    cout << count << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		int j,n,team1,team2,point1,point2,cnt;
		
		n=sc.nextInt();
		int score[]=new int[n+1];
		int stand[]=new int[n+1];
		for(int i=0;i<n*(n-1)/2;i++){
			team1=sc.nextInt();
			team2=sc.nextInt();
			point1=sc.nextInt();
			point2=sc.nextInt();			
			if(point1>point2){
				score[team1]+=3;
			}
			else if(point1<point2){
				score[team2]+=3;
			}
			else{
				score[team1]+=1;
				score[team2]+=1;
			}
		}
		for(int i=1;i<=n;i++){
			cnt=1;
			for(j=1;j<=n;j++){
				if(score[i]<score[j]){
					cnt++;
				}
			}
			System.out.println(cnt);
		}
		
	}

}

Measured memory_bytes: 42220
/*
* @Author: 王文宇
* @Date:   2018-03-25 19:56:18
* @Last Modified by:   王文宇
* @Last Modified time: 2018-03-25 20:19:46
*/
#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=a;i<=b;i++)
const int maxn = 100006;
long long n,a[maxn],b[maxn],sum,c[maxn];
int main(int argc, char const *argv[])
{
	cin>>n;
	_for(i,1,n)
	{
		cin>>a[i];
		b[i]=abs(a[i]-a[i-1]);
		sum+=b[i];
	}
	b[n+1]=abs(a[n]);
	sum+=b[n+1];
	_for(i,1,n)
	{
		int k = abs(a[i+1]-a[i-1]);
		c[i]=b[i]+b[i+1]-k;
	}
	_for(i,1,n)
	{
		cout<<sum-c[i]<<endl;
	}
	return 0;
}

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

using namespace std;

const int N = 100010;

int head[N], num, i, n, x, y;
struct edge {
	int to, nxt;
} e[N * 2];

int rd() {
	int x = 0; char c = getchar();
	while (c > '9' || c < '0') c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
	return x;
}

void add_edge(int x, int y) {
	e[++num].nxt = head[x], e[head[x] = num].to = y;
}

int sg(int x, int p) {
	int now = 0, i, y;
	for (i = head[x]; i; i = e[i].nxt) {
		y = e[i].to;
		if (y == p) continue;
		now ^= (sg(y, x) + 1);
	}
	return now;
}

int main() {
	n = rd();
	for (i = 1; i < n; i++) {
		x = rd(), y = rd();
		add_edge(x, y), add_edge(y, x);
	}
	if (sg(1, 1)) puts("Alice"); else puts("Bob");
	return 0;
}

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

vector<unordered_set<int> > v(50);
vector<int> visit(50);
vector<pair<int, int> > br(50);

void dfs(int i){
    visit[i]=1;
    for(auto p : v[i]){
        if(visit[p]==0) dfs(p);
    }
}
int main(void){
    int n, m;
    cin>>n>>m;
    rep(i, m){
        int a, b;
        cin>>a>>b;
        --a;--b;
        v[a].insert(b);
        v[b].insert(a);
        br[i]=make_pair(a, b);
    }
    int ans=0;
    rep(i, m){
        rep(i, n) visit[i]=0;
        v[br[i].first].erase(br[i].second);
        v[br[i].second].erase(br[i].first);
        dfs(0);
        int now=0;
        rep(i, n) {
            //cout<<visit[i]<<" ";
            now+=visit[i];
        }
        //cout<<endl;
        if(now!=n) ans++;
        v[br[i].first].insert(br[i].second);
        v[br[i].second].insert(br[i].first);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

namespace lib
{
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		for (auto i : boost::irange(0, 63))
		{
			if (p & (1ULL << i))
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
	template<std::uint64_t Mod>class modnum :
		private boost::addable<modnum<Mod>>,
		private boost::subtractable<modnum<Mod>>,
		private boost::multipliable<modnum<Mod>>,
		private boost::dividable<modnum<Mod>>
	{
		std::uint64_t val;
		void clamp()
		{
			val %= Mod;
		}
	public:
		modnum() = default;
		modnum(std::int64_t v) :val()
		{
			if (v < 0)
			{
				v += (std::abs(v) / Mod + 1) * Mod;
			}
			val = v;
			clamp();
		}
		modnum(std::uint64_t v) :val(v)
		{
			clamp();
		}
		modnum(std::int32_t v) :modnum(static_cast<std::int64_t>(v))
		{

		}
		modnum(std::uint32_t v) :modnum(static_cast<std::uint64_t>(v))
		{

		}
		friend std::ostream& operator<<(std::ostream& os, modnum const& num)
		{
			return os << num.val;
		}
		auto& operator+=(modnum const& rhs)
		{
			val += rhs.val;
			clamp();
			return *this;
		}
		auto& operator-=(modnum const& rhs)
		{
			val += Mod - rhs.val;
			clamp();
			return *this;
		}
		auto& operator*=(modnum const& rhs)
		{
			val *= rhs.val;
			clamp();
			return *this;
		}
		auto& operator/=(modnum const& rhs)
		{
			val *= pow(rhs, Mod - 2).val;
			clamp();
			return *this;
		}
		auto const& operator*()const
		{
			return val;
		}
	};
}
using mod_t = lib::modnum<1000000007>;

void Main()
{
	int N, K;
	std::cin >> N >> K;
	for (int i : boost::irange(0, K))
	{
		int red = N - K - i;
		int blue = K - (i + 1);
		if (red < 0)
		{
			std::cout << 0 << std::endl;
			continue;
		}
		auto rs = i + 1;
		auto bs = i;
		boost::multi_array<mod_t, 2> red_dp(boost::extents[rs + 1][red + 1]);
		boost::multi_array<mod_t, 2> blue_dp(boost::extents[bs + 1][blue + 1]);
		for (int n : boost::irange(0, red + 1))
		{
			red_dp[0][n] = 1;
		}
		for (int n : boost::irange(0, blue + 1))
		{
			blue_dp[0][n] = 1;
		}
		for (int n : boost::irange(0, rs))
		{
			red_dp[n + 1][0] = red_dp[n][0];
			for (int x : boost::irange(1, red + 1))
			{
				red_dp[n + 1][x] = red_dp[n + 1][x - 1] + red_dp[n][x];
			}
		}
		for (int n : boost::irange(0, bs))
		{
			blue_dp[n + 1][0] = blue_dp[n][0];
			for (int x : boost::irange(1, blue + 1))
			{
				blue_dp[n + 1][x] = blue_dp[n + 1][x - 1] + blue_dp[n][x];
			}
		}
		auto r = red_dp[rs][red];
		auto b = blue_dp[bs][blue];
		std::cout << r * b << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 4444
import sys
input = sys.stdin.buffer.readline

from itertools import accumulate

N, K = map(int, input().split())
A = list(map(int, input().split()))

A = [(a + 1) / 2 for a in A]
#print(A)

Acum = [0] + list(accumulate(A))
answer = -1
for i in range(N + 1 - K):
    answer = max(answer, Acum[i + K] - Acum[i])
    
print(answer)

Measured memory_bytes: 21176
from itertools import chain, combinations
import copy

def powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
def del_list_indexes(l, id_to_del):
    somelist = [i for j, i in enumerate(l) if j not in id_to_del]
    return somelist
def splitw(word): 
    return [char for char in word] 
def countBlacks(rows,paintRows,paintCols):
  c = copy.deepcopy(rows)
  t = 0
  
  c = del_list_indexes(c,paintRows)
  for i in paintCols:
    for ii in c:
      ii[i] = 'r'
  # count
  for i in c:
    for ii in i:
      if ii == "#":
        t +=1

  return t

i = input().split(" ")
h,w,k = int(i[0]),int(i[1]),int(i[2])

rows = []
for i in range(h):
    ii = input()
    rows.append(splitw(ii))
    
    
rowChoices = []
for i in range(h):
  rowChoices.append(str(i)+'row')
colChoices = []
for i in range(w):
  colChoices.append(str(i)+'col')

l = powerset(rowChoices+colChoices)

correct = 0
for i in l:
  paintRows = []
  paintCols = []
  for paint in i:
    if 'row' in paint:
      paintRows.append(int(paint[0]))
    if 'col' in paint:
      paintCols.append(int(paint[0]))
      
  numBlack = countBlacks(rows,paintRows,paintCols)
  if numBlack == k:
    correct += 1
print(correct)

Measured memory_bytes: 9268
import java.util.Scanner;

public class Main{ 
        public static void main(String[] args){
            int i=0,j,k,count=0;
            int a[];
            int b[];
            a = new int[100000];
            b = new int[100000];
                Scanner n = new Scanner(System.in);
                while(true){
                     a[i] = n.nextInt();
                     b[i] = n.nextInt();
                     if(a[i]==0 && b[i]==0){
                         break;
                     }
                     count++;
                     i++;
                }
                i=0;
                while(count>i){
                        for(k=0;k<a[i];k++){
                            if(k%2==0){
                            for(j=0;j<b[i];j++){
                                if(j%2==0){
                                System.out.print("#");
                                }else{
                                    System.out.print(".");
                                }
                            }
                            System.out.printf("\n");
                        }else{
                            for(j=0;j<b[i];j++){
                                if(j%2!=0){
                                System.out.print("#");
                                }else{
                                    System.out.print(".");
                                }
                            }
                            System.out.printf("\n");
                        }
                        }
                     i++;
                     System.out.printf("\n");
                }
        }
    }


Measured memory_bytes: 38836
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ld p[7];
ld q[7];
const ld eps = 1e-12;
ld prob(ld mid)
{
	ld ans = 0;
	for(int i = 0; i < 6; i++)
	{
		ans += max(mid*p[i], (1-mid)*q[i]);
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	for(int i = 0; i < 6; i++)
	{
		cin>>p[i];
		p[i]*=0.01;
	}
	for(int i = 0; i < 6; i++)
	{
		cin>>q[i];
		q[i]*=0.01;
	}
	ld lo = 0; ld hi = 1;
	for(int i = 0; i < 90; i++)
	{
		ld r1 = lo + (hi-lo)/3;
		ld r2 = lo + 2*(hi-lo)/3;
		//cerr<<fixed<<setprecision(12)<<r1<<' '<<r2<<'\n';
		ld d1 = prob(r1);
		ld d2 = prob(r2);
		if(d1<d2)
		{
			hi = r2;
		}
		else
		{
			lo = r1;
		}
	}
	cout<<fixed<<setprecision(12)<<prob(lo)<<'\n';
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>
#include <random>
#include <fstream>


using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)
#define MD 1000000007

int main() {
	
	long n, max,mid, mid_u, mid_d;
	cin >> n;

	vector <long>a(n);
	rep(i, 0, n)cin >> a[i];
	sort(a.begin(), a.end());

	if (n == 2) {
		cout << a[1] << " " << a[0] << endl;
		return 0;
	}

	max = a[n - 1];
	mid = max / 2;

	auto itr = lower_bound(a.begin(), a.end(), mid);
	size_t index = std::distance(a.begin(), itr);

	mid_u = a[index];
	mid_d = a[index - 1];

	if (abs(mid - mid_d) < abs(mid - mid_u)) {
		cout << max << " " << mid_d << endl;
	}
	else {
		cout << max << " " << mid_u << endl;
	}





	return 0;
}


Measured memory_bytes: 1024
fn main() {
    proconio::input! {
        k: usize,
        a: usize,
        b: usize,
    }
    let ans = if a + 2 >= b {
        1 + k
    } else {
        let pre = a - 1;
        if pre + 2 > k {
            1 + k
        } else {
            let remain = k - pre;
            let cicle = remain / 2;
            let cicle_add = b - a;
            let post = remain % 2;
            a + cicle * cicle_add + post
        }
    };
    println!("{}", ans);
}


Measured memory_bytes: 2120
package main

import (
	"fmt"
	"sort"
)

func main() {
	n, m := 0, 0
	_, _ = fmt.Scan(&n, &m)
	memo := make(map[int]int)
	keys := make([]int, 0)
	for i := 0; i < n; i++ {
		a, b := 0, 0
		_, _ = fmt.Scan(&a, &b)
		val, ok := memo[a]
		if ok {
			memo[a] = val + b
		} else {
			memo[a] = b
			keys = append(keys, a)
		}
	}
	sort.Sort(sort.IntSlice(keys))
	amount := 0
	count := 0
	key := 0
	for _, k := range keys {
		key = k
		amount += memo[k] * k
		count += memo[k]
		if count >= m {
			break
		}
	}
	fmt.Println(amount - ((count - m) * key))
}

Measured memory_bytes: 10116
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long q1,q2,q3,q4;
	q1=a*c;
	q2=a*d;
	q3=b*c;
	q4=b*d;
	cout<<max(max(q1,q2),max(q3,q4))<<endl;
	return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var M = vals[1];

        if (N == M)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13396
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tommy6073
 */

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

class APlacingMarbles {
public:
    void solve(std::istream& in, std::ostream& out) {
        string s;
        in >> s;

        out << count(s.begin(), s.end(), '1');
    }
};


int main() {
	APlacingMarbles solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005,mod=998244353;
int n,k,l[N],r[N],dp[N]={1},s[N]={1};
int main()
{
	scanf("%d%d",&n,&k);
	n--;
	for(int i=1;i<=k;i++)
		scanf("%d%d",&l[i],&r[i]);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(l[j]>i)
				continue;
			int x=max(0,i-r[j]),y=i-l[j];
			int v=(s[y]+mod-s[x-1])%mod;
			dp[i]=(dp[i]+v)%mod;
		}
		s[i]=(s[i-1]+dp[i])%mod;
	}
	printf("%d\n",dp[n]);
	return 0;
}

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

#define PB push_back
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define CL(A,I) (memset(A,I,sizeof(A)))
#define aa first
#define bb second
#define FOR(i, m, n) for (int i(m); i < (int)n; i++)
#define REP(i, n) FOR(i, 0, n)
#define F(n) FOR(i, 0, n)
#define FF(n) FOR(j, 0, n)
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

int n, a[123456];

int main() {
    scanf("%d", &n);
    F(n) scanf("%d", &a[i]);
    int ctr = 0;
    F(n) if (a[i] % 2) ctr++;
    if (ctr % 2 == 0)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*🍈( '-'  🍈*/

int main(){
	int N;
	cin >> N;
	vector<int> d(N);

	REP(i,N){
	    cin >> d[i];
	}

	sort(ALL(d));

	cout << d[N/2] - d[N/2-1] << "\n";


	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    string s;
    cin >> s;
    REP(i,s.size()){
	s[i] = (char)( ((int)(s[i]-'A') + 26 - 3)%26 + 'A');
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define bit(x) (1LL << x)
#define PI acos(-1.0)
#define EPS 1e-9

#define mod 1000000007
#define maxn 200005

using namespace std;

using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///All indexing is 0-based
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

typedef long long ll;
typedef double ld;
typedef pair<ll, ll> par;


int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int a,b,c,d,t=0;
    cin >> a >> b >> c >> d;

    while(a>=0 && b>=0)
    {
        if(c - b<=0 ){
            t=1;
            break;
        }
        c-=b;
        if(a-d<=0){
            t=0;
            break;
        }
        a-=d;
    }
    if(t)
        cout << "Yes\n";
    else
        cout << "No\n";



}


Measured memory_bytes: 3652
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right,*left,*parent;
};

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while( x != NIL) {
    y=x;
    if(z->key < x->key){
      x=x->left;
    } else {
      x=x->right;
    }
  }

  z->parent = y;
  if(y == NIL){
    root=z;
  } else {
    if( z->key < y->key){
      y->left=z;
    } else {
      y->right=z;
    }
  }
}

void inorder(Node *u) {
  if( u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;

  scanf("%d",&n);

  for( i=0; i<n; i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }else if (com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 24688
from heapq import *

def main():
    h, w, a, b = map(int, input().split())
    r = []
    c = []
    t = [[0] * w for _ in range(h)]
    br = False
    for x in range(h + 1):
        for y in range(w + 1):
            if a * (h - x) + (w - a) * x == b * (w - y) + (h - b) * y:
                br = True
                break
        if br: break
    else:
        print("No")
        exit()
    for i in range(x):
        heappush(r, [-w + a, i])
    for i in range(x, h):
        heappush(r, [-a, i])
    for j in range(y):
        heappush(c, [-h + b, j])
    for j in range(y, w):
        heappush(c, [-b, j])
    while r:
        e0, i = heappop(r)
        tmp = []
        for _ in range(-e0):
            e1, j = heappop(c)
            t[i][j] = 1
            if -e1 > 1: tmp.append([e1 + 1, j])
        for l in tmp:
            heappush(c, l)
    for x in t:
        print(*x, sep="")

main()


Measured memory_bytes: 13684
// ABC048A - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	string A, B, C;
	cin >> A >> B >> C;

	cout << 'A' << B[0] << 'C' << endl;
	return 0;
}


Measured memory_bytes: 256
s = str(input())
l_s = list(s)

def inv(l_s):
    l_s_res = []
    for i in l_s[::-1]:
        l_s_res.append(i)
    return l_s_res

def repeat_str(l_s):
    return l_s == inv(l_s)

def first_rep(l_s):
    return repeat_str(l_s)

def second_rep(l_s):
    N = len(l_s)
    l_s_tmp = l_s[:int((N-1)/2)]
    return repeat_str(l_s_tmp)

def third_rep(l_s):
    N = len(l_s)
    l_s_tmp = l_s[int((N+3)/2-1):]
    return repeat_str(l_s_tmp)

if first_rep(l_s) == True and second_rep(l_s) == True and third_rep(l_s) == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    alpha=split("zabcdefghijklmnopqrstuvwxy","")
    ans=""
    while n>0
        ans=alpha[n%26+1]*ans
        if n%26==0
            n=n÷26-1
        else
            n÷=26
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 154540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define roop(i, n) for(int i=0; i < n; i++)

constexpr ull mod = 1e9+7;
constexpr int N = 13;
ull dp[100010][N];

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

//============================================================================
// 解法
// 漸化式：
// dp[i][j] = 先頭i文字目として考えられるもののうち、13で割った余りがjのもの
// 
// iの昇順にdpを見ると、i-1文字目までを13で割ったあまり(dp[i-1][j]のj)と
// s[i]としてあり得る数字をすべて試すことでdp[i][0] ~ dp[i][12]の値がわかる
// 13で割った余りが5となるものを出力すればよい。(dp[n][5]が答え)
//============================================================================

int main() {
	int i, j, k;
	string s;
	cin >> s;

	int n = s.length();
	dp[0][0]=1;

	roop(i, n) {
		if(s[i]=='?'){
			roop(k, 10){
				roop(j, N) {
					dp[i + 1][(10*j+k) % N] += dp[i][j];
					dp[i + 1][(10*j+k) % N] %= mod;
				}
			}
		} else {
			int k = s[i]-'0';
			roop(j, N) {
				dp[i + 1][(10*j+k) % N] += dp[i][j];
				dp[i + 1][(10*j+k) % N] %= mod;
			}
		}
	}
	ull ans = dp[n][5]%mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10624
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let (n, m): (usize, usize);
    input!(n, m);
    p(2_usize.pow(m as u32) * (1900 * m + 100 * (n - m)));
}

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

int main() {
  int H, W;
  string str;
  cin >> H >> W;
  
  for(int i=0; i<W+2; i++){
  	cout << '#';
  }
  cout << endl;
  for(int i=0; i<H; i++){
  	cin >> str;
    cout << '#' << str << '#' << endl;
  }
  for(int i=0; i<W+2; i++){
  	cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long a[88];
void init()
{
    a[0]=2,a[1]=1;
    for(int i=2;i<=86;i++){
        a[i]=a[i-1]+a[i-2];
    }
}
int main()
{
    int n;
    init();
    while(cin>>n){
        cout<<a[n]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int n,m,cap;
vector<PI> G[4000];
bool lpg[4000];
bool vis[4000][4000];

map<string,int> stoi;
int getnum(string s){
  if(stoi.count(s))return stoi[s];
  int sz=SZ(stoi);
  return stoi[s]=sz;
}

void solve(){
  stoi.clear();
  memset(lpg,0,sizeof(lpg));
  memset(vis,0,sizeof(vis));  
  string src,dest;
  cin>>src>>dest;
  int st=getnum(src),go=getnum(dest);
  
  rep(i,n+1)G[i].clear();
  rep(i,n){
    string p,q;
    int c;
    cin>>p>>q>>c;
    int u=getnum(p);
    int v=getnum(q);
    G[u].pb(mp(v,c));
    G[v].pb(mp(u,c));
  }
  rep(i,m){
    string s;
    cin>>s;
    int t=getnum(s);
    //if(t>4000)exit(0);
    lpg[t]=1;
  }

  priority_queue<pair<int,PI> >q;
  q.push(mp(0,mp(cap*10,st)));
  while(!q.empty()){
    int cc=-q.top().F;
    int ca=q.top().S.F;
    int cv=q.top().S.S;

    q.pop();
    if(lpg[cv])ca=cap*10;
    if(vis[cv][ca])continue;
    vis[cv][ca]=true;
    if(cv==go){
      cout<<cc<<endl;
      return;
    }

    rep(i,SZ(G[cv])){
      int to=G[cv][i].F;
      int co=G[cv][i].S;
      if(co>ca)continue;
      int nca=ca-co;
      if(to>4000 || nca>4000)break;
      if(vis[to][nca])continue;
      q.push(mp(-cc-co,mp(nca,to)));
    }
  }
  cout<<-1<<endl;
}

main(){
  while((cin>>n>>m>>cap)&&n)
    solve();
}

Measured memory_bytes: 41000
class VectorSpace:
    def __init__(self, k):
        self.k = k
        self.E = [0] * k
    
    def chk(self, n):
        for i in range(self.k)[::-1]:
            n = min(n, n ^ self.E[i])
        return 1 if n == 0 else 0
    
    def add(self, n):
        for i in range(self.k)[::-1]:
            n = min(n, n ^ self.E[i])
        if n: self.E[n.bit_length() - 1] = n
        return 1 if n == 0 else 0
    
    def dimension(self):
        return len(self.E)

T = int(input())
for _ in range(T):
    N = int(input())
    A = [int(a) for a in input().split()]
    S = [int(a) for a in input()]
    vs = VectorSpace(60)
    for i in range(N)[::-1]:
        a = vs.add(A[i])
        if S[i] and a == 0:
            print(1)
            break
    else:
        print(0)

Measured memory_bytes: 68384
#include<stdio.h>
int main(void){
	int a[1000][3],n,i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<n;i++){
		if(a[i][0] < a[i][1]){
			k=a[i][0];
			a[i][0]=a[i][1];
			a[i][1]=k;
		}
		if(a[i][0] < a[i][2]){
			k=a[i][0];
			a[i][0]=a[i][2];
			a[i][2]=k;
		}
		if(a[i][0]*a[i][0]==a[i][1]*a[i][1]+a[i][2]*a[i][2]){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}


Measured memory_bytes: 1816
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <climits>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n,atk;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a.begin(),a.end());
    for(int i=0;i<n-1;i++){
        while(1){
            atk=a[i+1]/a[i];
            a[i+1]-=a[i]*atk;
            if(a[i+1]<a[i]){
                int sub=a[i];
                a[i]=a[i+1];
                a[i+1]=sub;
            }
            if(a[i]==0)break;
        }
        if(a[n-2]==0)break;
    }
    cout<<a[n-1];
}

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

int main() {
    string s, t;
    cin >> s >> t;

    int difs = 0;
    for (int i = 0; i < s.size(); ++i)
        if (s[i] != t[i])
            ++difs;

    cout << difs;
    return 0;
}

Measured memory_bytes: 3852
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, T, A, H[1001];
	scanf("%d", &N);
	scanf("%d %d", &T, &A);
	for (i = 1; i <= N; i++) scanf("%d", &(H[i]));
	
	int min = abs(T * 1000 - H[1] * 6 - A * 1000), argmin = 1;
	for (i = 2; i <= N; i++) {
		if (abs(T * 1000 - H[i] * 6 - A * 1000) < min) {
			min = abs(T * 1000 - H[i] * 6 - A * 1000);
			argmin = i;
		}
	}
	printf("%d\n", argmin);
	fflush(stdout);
	return 0;
}

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

using namespace std;

template<typename T>
class Dice {

private:
   void Init() {
      upId = 0;
      frontId = 1;
      rightId = 2;
   }

public:
   Dice() :
      number{1, 2, 3, 4, 5, 6}
   {
      Init();
   }
   Dice(T (&n)[6]) :
      number{n[0], n[1], n[2], n[3], n[4], n[5]}
   {
      Init();
   }
   virtual ~Dice() {;}

   enum Direction {
      north,
      south,
      east,
      west
   };

   void Roll(Direction direction) {
      switch (direction) {
      case north: {
         int tmp = upId;
         upId = frontId;
         frontId = 5 - tmp;
         break;
      }
      case south: {
         int tmp = frontId;
         frontId = upId;
         upId = 5 - tmp;
         break;
      }
      case east: {
         int tmp = rightId;
         rightId = upId;
         upId = 5 - tmp;
         break;
      }
      case west: {
         int tmp = upId;
         upId = rightId;
         rightId = 5 - tmp;
         break;
      }
      }
   }

   T Print() {
      return number[upId];
   }   

private:
   T number[6];
   int upId;
   int frontId;
   int rightId;

};

template<typename T>
class NWSEDice : public Dice<T> {

public:
   NWSEDice(T (&n)[6]) :
      Dice<T>(n)
   {}
   ~NWSEDice() {;}

   void CommandRoll(char command) {
      switch(command) {
      case 'N': {
         this->Roll(Dice<T>::north);
         break;
      }
      case 'S': {
         this->Roll(Dice<T>::south);
         break;
      }
      case 'E': {
         this->Roll(Dice<T>::east);
         break;
      }
      case 'W': {
         this->Roll(Dice<T>::west);
         break;
      }
      }
   }

};

int main() {

   int number[6]{};
   for (int i = 0; i < 6; ++i) {
      cin >> number[i];
   }
   NWSEDice<int> dice(number);

   string line;
   cin >> line;
   for (auto command : line) {
      dice.CommandRoll(command);
   }
   cout << dice.Print() << endl;

   return 0;

}

Measured memory_bytes: 3224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    while (true) {
        var count = 0
        val (n, target) = readLine()?.split(" ")?.map { it.toInt() } ?: return
        if (n == 0 && target == 0) break
        val checker = hashSetOf<CustomTriple>()
        (1..n).forEach { i ->
            (2..n).forEach { j ->
                (3..n).forEach { k ->
                    if (i != j && j != k && k != i && i + j + k == target) {
                        var hasCombination = false
                        val tri = CustomTriple(i,j,k)
                        for (it in checker)  {
                            if (it.equals(tri)) {
                                hasCombination = true
                                break
                            }
                        }
                        if (!hasCombination){
                            count++
                            checker.add(tri)
                        }
                    }
                }
            }
        }
        println(count)
    }
}

data class CustomTriple(val f: Int, val s: Int, val t:Int){

    override fun equals(other: Any?): Boolean {
        return other != null &&
                other is CustomTriple &&
                (this.f == other.f || this.f == other.s || this.f == other.t) &&
                (this.s == other.f || this.s == other.s || this.s == other.t) &&
                (this.t == other.f || this.t == other.s || this.t == other.t)
    }

    override fun hashCode(): Int {
        return super.hashCode()
    }
}


Measured memory_bytes: 47888
//
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <vector>
//#ifdef atom #else #endif
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define X first
#define Y second
#define vi vector<int>
#define vvi vector< vi >
#define vii vector< ii >
#define mp make_pair
#define pb push_back
int main()
{
    //#ifndef atom freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif
    string s; cin >> s;
    bool ok = 1;
    for(int k = 1; k< (int) s.size(); k++) if(s[k] != '9') ok = 0;
    if(ok)
    {
        int sum = 0;
        for(int k = 0; k< (int) s.size(); k++) sum += s[k]-'0';
        cout << sum << endl;
    }
    else
    {
        int sum = 0;
        sum += (s[0]-'0'-1);
        sum += 9*(s.size()-1);
        cout << sum << endl;
    }
}


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

#define ll long long

int main() {
	int n;
	ll d;
	cin >> n >> d;
    int ans = 0;
    for (int i = 0; i<n; i++){
        ll x,y;
        cin >> x >> y;
        if (x*x+y*y <= d*d){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604