akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int N,s,i,j,mv[4][2]={{0,-1},{1,0},{0,1},{-1,0}},x,y,S,r;
char M[105][105],E[3][30]={"#","##\n# ","###\n# #\n# #"};

int c(int n){return 0<=n-1&&n+1<100;}

int c2(int x,int y)
{
	int i,m[5]={1,0,-1,0,1},c=0,c2=0;
	for(i=0;i<4;i++)
	{
		if(M[y+m[i]][x+m[i+1]]=='#')c++;
		if((mv[i][1]&&M[y+(mv[i][1]*2)][x]=='#')||(mv[i][0]&&M[y][x+(mv[i][0]*2)]=='#'))c2++;
	}
	return c>1?1:c2==4?2:0;
}

int main()
{
	for(scanf("%d",&N);N--;N>0?puts(""):0)
	{
		memset(M,0,sizeof(M));
		scanf("%d",&S);s=S;
		if(s<4)puts(E[s-1]);
		else
		{
			for(i=0,x=0,y=s-1;;i=(i+1)%4)
			{
				for(;0<=y+mv[i][1]&&y+mv[i][1]<s&&0<=x+mv[i][0]&&x+mv[i][0]<s;y+=mv[i][1],x+=mv[i][0])
					{
						if(c(x)&&c(y)&&(r=c2(x,y)))
						{
							if(r==2)M[y][x]='#';
							goto e;
						}
						M[y][x]='#';
						if((mv[i][1]&&M[y+(mv[i][1]*2)][x]=='#')||(mv[i][0]&&M[y][x+(mv[i][0]*2)]=='#'))
							break;
					}
			}
			e:for(i=0;i<S;i++,puts(""))
				  for(j=0;j<S;j++)
					printf("%c",M[i][j]==0?' ':M[i][j]);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 
int main(){
  string S;
  cin >> S;
  string T;
  cin >> T;
  
  // できるだけ後ろにcoderを入れる
  int index = S.size();
  for(int i = S.size() - T.size(); i >= 0; i--){
    bool flg = true;
    for(int j = 0; j < T.size(); j++){
      if(S[i+j] == '?' || S[i+j] == T[j]){
        continue;
      } else { 
        flg = false;
        break;
      }
    }
    if(flg){
      index = i;
      break;
    }
  }
  cerr << index << endl;
  string ans = "";
  for(int i = 0; i < S.size(); i++){
    if(i < index || i > index + T.size()-1){
      // Sから表示
      if(S[i] == '?') ans += "a";
      else ans += S[i];
    } else { 
      ans += T[i-index];
    }
  }
  if(index == S.size()){
    ans = "UNRESTORABLE";
  }
  cout << ans << endl;
      
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
#define X real()
#define Y imag()
#define EPS (1e-10)
typedef complex<double> P;
typedef pair<P, P> L;

namespace std{
  bool operator<(const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

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

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

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

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

bool is_cross(L a, L b){
  if(ccw(a.first,a.second,b.first)*ccw(a.first,a.second,b.second) <= 0 &&
     ccw(b.first,b.second,a.first)*ccw(b.first,b.second,a.second) <= 0) return true;
  return false;
}

P intersection(L a, L b){
  //??????
  return a.first + abs(cross(b.second-b.first,a.first-b.first)/(abs(cross(b.second-b.first,a.second-b.first))+abs(cross(b.second-b.first,a.first-b.first))))*(a.second-a.first);;
}

int main(){
  int n;
  while(cin >> n, n){
    vector<L> s;
    double x1, y1, x2, y2;
    for(int i = 0; i < n; ++i){
      cin >> x1 >> y1 >> x2 >> y2;
      s.push_back(L(P(x1,y1), P(x2,y2)));
    }
    int ans = 1;
    for(int i = 0; i < n; ++i){
      L si = s[i];
      vector<P> cp;
      cp.push_back(si.first);
      cp.push_back(si.second);
      for(int j = 0; j < i; ++j){
	if(is_cross(si,s[j]))
	  cp.push_back(intersection(si,s[j]));
      }
      sort(cp.begin(), cp.end());
      for(int j = 1; j < cp.size(); ++j)
	if(abs(cp[j-1]-cp[j]) > EPS) ++ans;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3228
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t H, W, N;
  cin >> H >> W >> N;
  vector<int64_t> A(N + 1);
  for (int64_t i = 1; i <= N; ++i) {
    cin >> A[i];
  }
  vector<vector<int64_t>> colors(H, vector<int64_t>(W, -1));
  int64_t row = 0;
  int64_t col = 0;
  int64_t color = 1;
  for (int64_t i = 0; i < H * W; ++i) {
    // cerr << row << ", " << col << endl;
    if (A[color] <= 0) {
      ++color;
    }
    colors[row][col] = color;
    --A[color];
    if (row % 2 == 0 && col == W - 1) {
      ++row;
    } else if (row % 2 == 1 && col == 0) {
      ++row;
    } else if (row % 2 == 0) {
      ++col;
    } else {
      --col;
    }
  }
  for (int64_t row = 0; row < H; ++row) {
    for (int64_t col = 0; col < W; ++col) {
      if (col != 0) {
        cout << " ";
      }
      cout << colors[row][col];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 512
import numpy as np

n = int(input())
a = list(map(int, input().split()))
s = 0
x = [-1 for i in range(n)]
for i in range(1,n):
    if i % 2 == 1:
        s += a[i]
x[0] = sum(a) - s * 2
for i in range(1, n):
    x[i] = a[i - 1] * 2 - x[i - 1]
for i in x:
    print(i,end = "")
    print(" ", end = "")

Measured memory_bytes: 23132
N = int(input())
task = []
for _ in range(N):
    A,B = map(int,input().split())
    task.append([A,B])
task.sort(key=lambda task:task[1])

time = 0
ans = "Yes"
for i in range(N):
    A = task[i][0]; B = task[i][1]
    if time + A <= B:
        time += A
    else:
        ans = "No"
        break

print(ans)

Measured memory_bytes: 38092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,arr[105],cnt1=0,cnt2=0;;
     cin>>t;
     for(int i=0;i<t;i++)
     {
         cin>>arr[i];
     }
     sort(arr,arr+t,greater<ll>());
     for(int i=0;i<t;i++)
     {
         if(i%2==0)
            cnt1+=arr[i];
         else
            cnt2+=arr[i];
     }
     cout<<cnt1-cnt2<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,m,a,t;
  cin>>n;
  multiset<long> d;
  for(int i=0;i<n;++i){
    cin>>a;
    d.insert(a);
  }
  cin>>m;
  bool can=true;
  while(m--){
   cin>>t;
   auto itr=d.find(t);
   if(itr==d.end())can=false;
   else d.erase(itr);
  }
  cout<<(can?"YES":"NO")<<endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()


int main() {
    string s;
    cin >> s;
 
    int cnt = 0;
    int size = s.size();
    for (int i = 0; i < size / 2; i++) {
        if (s[i] != s[size - 1 - i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;
using ll = long long int;
#define INF 20000000000000000
#define MOD 1000000007

int main(void){
  int a, b;
  cin >> a >> b;
  
  ll ans = 0;
  
  if(abs(a-b) >= 2){
    cout << 0 << endl;
    return 0;
  }
  
  ll aValue = 1, bValue = 1;
 
  for(int i = 1;i <= a;i++){
    aValue *= i;
    aValue %= MOD;
  }
  
  for(int i = 1;i <= b;i++){
    bValue *= i;
    bValue %= MOD;
  }
  
  ans = aValue * bValue;
  
  if(a == b) ans *= 2;
  
  ans %= MOD;
  
  cout << ans << endl;
}

Measured memory_bytes: 384
using System;

namespace c_sharp_test
{
    class Program
    {
        static void Main(string[] args)
        {
            bool flag = true; 
            string input = Console.ReadLine();
            char[] list = null;
            list = input.ToCharArray();
            for(int i = 0; i < list.Length; i++)
            {
                if((i+1)%2 == 0)
                {
                    //偶数
                    if(list[i] != 'L'&& list[i] != 'U'&& list[i] != 'D')
                    {
                        flag = false;
                    }
                }
                else
                {
                    //奇数
                    if (list[i] != 'R' && list[i] != 'U' && list[i] != 'D')
                    {
                        flag = false;
                    }
                }
            }
            if (!flag)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}


Measured memory_bytes: 13140
module Main where

import           Control.Arrow
import           Data.List
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

main :: IO ()
main = do
  n <- readLn::IO Int
  print $ VU.sum $ VU.map (f n) $ VU.enumFromN (1::Int) n
  where
    f n k = let y = n `div` k in y * (y + 1) * k `div` 2

Measured memory_bytes: 3880
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	vector<int>a(n);

  	for(int i=0;i<n;i++){
      	cin>>a[i];
    }
  	
    
  	
  	int count_1=0;
  for(int i=0;i<n;i++){
  	if(count_1+1==a[i]){
    	count_1++;
    }
  }
  	
  	if(count_1==0){
    	cout<<"-1"<<endl;
    }
  	else{
    	cout<<n-count_1<<endl;
    }
  	
}

Measured memory_bytes: 1024
#include <ext/pb_ds/assoc_container.hpp> 	// Common file
#include <ext/pb_ds/tree_policy.hpp> 		// Including tree_order_statistics_node_update
#include<bits/stdc++.h>
#define int            		long long
#define x              		first
#define y              		second
#define all(aaa)       		(aaa).begin(),(aaa).end()
#define REP(i,sss,eee) 		for(int i=sss;i<=eee;++i)
#define pb             		push_back
#define pii            		pair<int,int>
#define vi             		vector<int>
#define speed          		ios_base::sync_with_stdio(0);cin.tie(0);
#define N              		1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}

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

long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
int solve()
{
	int A,B;cin>>A>>B;
	if(B%A==0){cout<<(A+B)<<"\n";}
	else{cout<<(B-A)<<"\n";}
	
}
signed main(){
	speed
	int tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<string>S(N);
  map<string,int>M; //keyが文字列 valueが個数
  
  vector<string>A;
  
  int maxvalue = 1;
  rep(i,N){
    cin >> S[i];
    
    if(M.count(S[i])){ //すでに入っていたら
      M[S[i]]++; //Mapのvalueをプラス
      maxvalue = max(maxvalue,M[S[i]]); //最大値更新
    }
    else{ //入ってなかったら
      M[S[i]] = 1;
      A.push_back(S[i]); //Aに今まで出てきた文字列を格納しておく
    }
    
  }
  
  //ここで辞書順にソート
  sort(A.begin(),A.end());
  
  rep(i,A.size()){
    if(maxvalue == M[A[i]]){
      cout << A[i] << endl;
    }
  }
  
}


Measured memory_bytes: 31260
#include<stdio.h>
int main(){
	char moji;
	int i;
	for(i=0;i<1200;i++){
		scanf("%c",&moji);
		if(moji=='\n') break;
		if(moji>='A' && moji<='Z'){
			moji=moji+32;
			printf("%c",moji);
		}else if(moji>='a' && moji<='z'){
			moji=moji-32;
			printf("%c",moji);
		}else{
			printf("%c",moji);
		}
	}
	printf("\n");
}
			
			
	


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

class Program
{
    static void Main()
    {
        string[] cin = Console.ReadLine().Split();

        int n = int.Parse(cin[0]);
        int m = int.Parse(cin[1]);
        int c = int.Parse(cin[2]);
        int[] b = Console.ReadLine().Split().Select(t => int.Parse(t)).ToArray();

        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            int[] a = Console.ReadLine().Split().Select(t => int.Parse(t)).ToArray();
            int tmp = c;
            for (int j = 0; j < m; j++)
            {
                tmp += a[j] * b[j];
            }
            if (0 < tmp) ans++;
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#from collections import *
#from itertools import *
#from bisect import *
from heapq import *
#import copy
#N=int(input())
#X,Y=map(int,input().split())
#S=list(map(int,input().split()))
#S=[list(map(int,input().split())) for i in range(N)]

H=int(input())
count=1
while H>=2:
    H//=2
    count*=2
count*=2
count-=1
print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int d[2]={1,-1};
char p[2]={'+','-'};

int main(){
  string s;
  int a[5];
  cin>>s;
  for(int i=0;i<4;i++){
    a[i]=s[i]-'0';
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
	if(a[0]+a[1]*d[i]+a[2]*d[j]+a[3]*d[k]==7){
	  cout<<s[0]<<p[i]<<s[1]<<p[j]<<s[2]<<p[k]<<s[3]<<"=7"<<endl;
	  return(0);
	}
      }
    }
  }
  return(0);
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
var lines = input.split('\n');

var n = +lines.shift();
var G = [];
for (var i = 0; i < n; i++) {
    G.push([]);
    for (var j = 0; j < n; j++) {
        G[i][j] = Number.POSITIVE_INFINITY;
    }
    G[i][i] = 0;
}
for (var i = 0; i < n; i++) {
    var u = lines.shift().trim().split(' ').map(function(n){return +n});
    var id = u[0];
    var k = u[1];
    for (var j = 0; j < k; j++) {
        var adj = u[2 + j * 2];
        var cost = u[2 + j * 2 + 1];
        G[i][adj] = cost;
    }
}

var cost = [0];
for (var i = 1; i < n; i++) {
    cost.push(Number.POSITIVE_INFINITY);
}
var visited = {};
while (true) {
    var u = -1;
    for (var i = 0; i < n; i++) {
        if (!visited[i] && (u == -1 || cost[i] < cost[u])) {
            u = i;
        }
    }
    if (u == -1) {
        break;
    }
    visited[u] = true;

    for (var i = 0; i < n; i++) {
        cost[i] = Math.min(cost[i], cost[u] + G[u][i]);
    }
}

for (var i = 0; i < n; i++) {
    console.log(i, cost[i]);
}

Measured memory_bytes: 10436
#include <iostream>
#include <string>
using namespace std;
int main(){
    string a;
    cin >> a;
    if(a[0]!='7'&&a[1]!='7'&&a[2]!='7'){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3040
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int N,K;
	cin>>N>>K;
	unsigned long ans=0;
	if(K%2==0){
		double num;
		num=(double)N/(double)K;
		ans+=pow(N/K,3);
		ans+=pow(round(num),3);
		cout<<ans;
	}else{
		ans+=pow(N/K,3);
		cout<<ans;
	}
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split(" ");
  var a = input[0];
  var b = input[1];
  var k = input[2];
  var ary = new Array();
  for(var i = 1; i < 101; i++ ) {
    if( a%i === 0 && b%i === 0 ) {
      ary.push(i);
    }
  }
  var result = ary.slice(-k)[0];
  console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>pat[1010];
vector<int>idx[1010];
int cnt[1010][1010];
int frm[1010];
int ans[202020];
void dfs(int node, int p, int dir)
{
	if (node == p)return;
	if (cnt[p][node] >= 2)return;
	if (cnt[p][node] == 1 && frm[node] == dir)return;
	if (cnt[p][node] == 0)frm[node] = dir;
	cnt[p][node]++;
	for (int i = 0; i < pat[node].size(); i++)dfs(pat[node][i], p, dir);
}
int main()
{
	int num, way;
	scanf("%d%d", &num, &way);
	for (int i = 0; i < way; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		pat[za].push_back(zb);
		idx[za].push_back(i);
	}
	for (int i = 0; i < num; i++)
	{
		fill(frm, frm + num, -1);
		for (int j = 0; j < pat[i].size(); j++)dfs(pat[i][j], i, pat[i][j]);
	}
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < pat[i].size(); j++)
		{
			bool f = cnt[i][pat[i][j]] >= 2;
			bool g = cnt[pat[i][j]][i] >= 1;
			ans[idx[i][j]] = f != g;
		}
	}
	for (int i = 0; i < way; i++)printf(ans[i] ? "diff\n" : "same\n");
}

Measured memory_bytes: 8960
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  rep(i,n) scanf("%d",&a[i]);
  qsort(a,n,sizeof(int),upint);
  j=1;
  rep(i,n){
    if(i<n-1&&a[i]==a[i+1]){
      j++;
    }else{
	  if(j%2==1) result++;
      j=1;
    }
  }
  
  printf("%lld", result);
  
  return 0;
}



Measured memory_bytes: 2556
n, m, x = map(int, input().split())
a = [[] for _ in range(n)]
for i in range(n):
    a[i] = list(map(int, input().split()))
ans = 10000000000000
for i in range(2 ** n):
    money = 0
    understand = [0] * m
    for j in range(n):
        if i >> j & 1:
            money += a[j][0]
            for k in range(1, m + 1):
                understand[k - 1] += a[j][k]
    if min(understand) >= x:
        ans = min(money, ans)
print(ans if ans < 10000000000000 else -1)


Measured memory_bytes: 74044
//
//  main.cpp
//  H and V 2
//
//  Created by Bryan on 05/07/20.
//  Copyright © 2020 mac. All rights reserved.
//

#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int N,M,K;
    scanf ("%d %d %d", &N, &M , &K);
    int arr[N+M+2];
    int memo[N+2][M+2];
    int max = 1;
    string tempe;
    int count = 0;
    
    for (int f = 0; f<N;f++)
    {
        cin>>tempe;
        for (int g = 0; g<M;g++)
        {
            if (tempe[g] == '#')
                memo[f][g] = 1;
            else
                memo[f][g] = 0;
        }
        
    }
    for (int f = 0; f<N+M;f++)
        max*=2;
    int temp;
    bool yes[N+2][M+2];
    for (int te = 0; te<max;te++)
    {
        temp = te;
        for (int f = 0; f<N+M;f++)
        {
            if (temp%2 == 0)
                arr[f] = 0;
            else
                arr[f] = 1;
            temp/=2;
            //cout<<arr[f]<<" ";
        }
  
        for (int f = 0; f<N;f++)
        {
            for (int g = 0; g<M;g++)
                yes[f][g] = true;
        }
        for (int f = 0; f<N;f++)
        {
            for (int g = 0; g<M;g++)
            {
                if (arr[f] == 1 || arr[N+g] == 1 )
                    yes[f][g] = false;
            }
                
        }
        int cur = 0;
        for (int f = 0; f<N;f++)
        {
            for (int g = 0; g<M;g++)
            {
                if (yes[f][g] == true && memo[f][g] == 1)
                    cur++;
            }
                
        }
        //cout<<cur<<endl;
        if (cur == K)
            count++;
    }
    printf ("%d\n",count);
}


Measured memory_bytes: 3772
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/12/20 20:48:37
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int gcd(int a, int b) {
  return a%b==0 ? b : gcd(b, a%b);
}

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

  int n; cin>>n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        ans += gcd(gcd(i,j),k);
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int a[n], g[h][w];
    rep(i, n) cin >> a[i];

    int cnt = 0, color = 1;
    rep(i, h) {
        if (i % 2 == 0) {
            rep(j, w) {
                if (cnt >= a[color - 1]) color++, cnt = 0;
                g[i][j] = color, cnt++;
            }
        } else {
            for (int j = w - 1; j >= 0; j--) {
                if (cnt >= a[color - 1]) color++, cnt = 0;
                g[i][j] = color, cnt++;
            }
        }
    }

    rep(i, h) rep(j, w) {
        cout << g[i][j];
        if (j == w - 1)
            cout << endl;
        else
            cout << ' ';
    }
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for (int i=0;i<(n);i++)

int main()
{
    ll X,t,ans;
    cin >> X >> t;
    ans = X - t;
    if (ans < 0) {
        ans = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 3e5 + 10, M = 1e5 + 10;

vector<pii> events;
vector<int> trains[M];
int tree[4 * N], ans[M];

void update(int i, int l, int r, int p, int x);
int query(int i, int l, int r, int ql, int qr);

int main() {
	fast_cin();
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		int l, r;
		cin >> l >> r;
		events.pb({l, 1});
		events.pb({r + 1, -l});
	}
	sort(events.begin(), events.end());
	for (int i = 1; i <= m; ++i) {
		for (int j = i; j <= m; j += i) {
			trains[j].pb(i);
		}
	}
	int p = 0;
	for (int i = 1; i <= m; ++i) {
		while (p <= 2 * n and events[p].first <= i) {
			if (events[p].second >= 0) {
				// cout << "+ " << events[p].first << endl;
				update(1, 1, m, events[p].first, events[p].second);
			} else {
				// cout << "- " << -events[p].second << endl;
				update(1, 1, m, -events[p].second, -1);
			}
			++p;
		}
		for (auto &j : trains[i]) {
			if (j == 1) {
				// cout << "query " << i - j + 1 << ' ' << i << ' ' << query(1, 1, m, i - j + 1, i) << endl;
			}
			ans[j] += query(1, 1, m, i - j + 1, i);
		}
	}
	for (int i = 1; i <= m; ++i) {
		cout << ans[i] << '\n';
	}
}

void update(int i, int l, int r, int p, int x) {
	tree[i] += x;
	if (l == r) {
		return;
	}
	int mid = (l + r) / 2;
	if (p <= mid) {
		update(2 * i, l, mid, p, x);
	} else {
		update(2 * i + 1, mid + 1, r, p, x);
	}
}

int query(int i, int l, int r, int ql, int qr) {
	if (l > qr or ql > r) {
		return 0;
	} else if (ql <= l and r <= qr) {
		return tree[i];
	} else {
		int mid = (l + r) / 2;
		return query(2 * i, l, mid, ql, qr) + query(2 * i + 1, mid + 1, r, ql, qr);
	}
}

Measured memory_bytes: 20456
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define int long long
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 1005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[li][li];
int cev;
string s;
char c[li][li];
vector<int> v[li];

inline int add(int x,int y){
	//~ cout<<x<<" : ; "<<y<<endl;
	if(x+y>=mod)return x+y-mod;
	return x+y;
}

inline int dfs(int sat,int sut){
	int cevv=0;
	if(sat>n)return 0;
	if(sut>m)return 0;
	if(c[sat][sut]=='#')return 0;
	if(sat==n && sut==m)return 1;
	if(~dp[sat][sut])return dp[sat][sut];
	cevv=add(cevv,dfs(sat+1,sut));
	cevv=add(cevv,dfs(sat,sut+1));
	return dp[sat][sut]=cevv;
}

main(void){
	memset(dp,-1,sizeof(dp));
	scanf("%lld %lld",&n,&m);
	FOR{
		for(int j=1;j<=m;j++){
			scanf(" %c",&c[i][j]);
		}
	}
	printf("%lld\n",dfs(1,1));
	return 0;
}



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

int main(){
    int A,B,C;
    unsigned long int X,Y;
    cin>>A>>B>>C>>X>>Y;
    if(A+B<=C*2){
        cout << A*X+B*Y <<endl;
    }else{
        if(X>Y){
            if(2*C < A){
                cout << 2*C*X <<endl;
            }else{
                cout << 2*C*Y+A*(X-Y) << endl;
            }
        }else{
            if(2*C <B){
                cout << 2*C*Y <<endl;
            }else{
                cout << 2*C*X+B*(Y-X) << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define INF (1<<28)

int dp[2][1000001];

int main() {
    vector<int> a[2];
    for(int i=1;; i++) {
        const int k = i*(i+1)*(i+2)/6;
        if(k>1000000) break;
        a[0].push_back(k);
        if(k%2) a[1].push_back(k);
    }
    rep(x, 2) {
        rep(i, 1000001) dp[x][i] = INF;
        dp[x][0] = 0;
        rep(k, a[x].size()) rep(i, 1000001-a[x][k]) {
            dp[x][i+a[x][k]] = min(dp[x][i+a[x][k]], dp[x][i]+1);
        }
    }
    for(;;) {
        int n;
        scanf("%d", &n);
        if(n==0) return 0;
        printf("%d %d\n", dp[0][n], dp[1][n]);
    }
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int n, a[109];

int main(){
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  int cnt=0;
  for(int i=0;i<n;i++){
    int mni=i;
    for(int j=i;j<n;j++){
      if(a[j]<a[mni]){
        mni=j;
      }
    }
    if(mni!=i){
      cnt++;
      swap(a[mni], a[i]);
    }
  }
  for(int i=0;i<n;i++)cout << a[i] << (i<n-1?' ':'\n');
  cout << cnt << endl;
}


Measured memory_bytes: 3092
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int m, f, r;
    int t;

    while (1) {
        scanf("%d %d %d", &m, &f, &r);

        t = m + f;

        if (m == -1 && f == -1 && r == -1) {
            break;
        }

        if(m == -1 || f == -1) {
            printf("F\n");
        }else if (t >= 80) {
            printf("A\n");
        }else if (t >= 65) {
            printf("B\n");
        }else if (t >= 50) {
            printf("C\n");
        }else if (t >= 30) {
            if (r >= 50) {
                printf("C\n");
            }else {
                printf("D\n");
            }
        }else if (t < 30){
            printf("F\n");
        }
    }
    return 0;
}



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

const int MAX_N = 1000001;
const int INF = 1<<27;
vector<int> N3, N4;
int T[2][MAX_N];

void makeN4() {
  for(int n = 1; ; ++n) {
    int s = n*(n+1)*(n+2)/6;
    if(s >= MAX_N) break;
    N4.push_back(s);
  }
}

void solve(bool oddOnly) {
  int *t = T[oddOnly];
  fill(t, t+MAX_N, INF);
  t[0] = 0;

  for(int j = 0; j < N4.size(); ++j) {
    if(oddOnly && N4[j]%2 == 0) continue;
    for(int i = N4[j]; i < MAX_N; ++i) {
      t[i] = min(t[i], t[i-N4[j]] + 1);
    }
  }
  /*
  for(int i = 1; i < MAX_N; ++i) {
    for(int j = 0; j < N4.size() && N4[j] <= i; ++j) {
      if(oddOnly && N4[j]%2 == 0) continue;
      t[i] = min(t[i], t[i-N4[j]] + 1);
    }
  }
  */
}

int main() {
  makeN4();
  solve(false);
  solve(true);
  int N;
  while(cin >> N && N) {
    cout << T[0][N] << " " << T[1][N] << endl;
  }
  return 0;
}

Measured memory_bytes: 8716
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
int books[10010]={0};
int dp[10000][1000];

#define INF 999999
bool check();
double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
int main(){
	while(~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&xa1,&ya1,&xa2,&ya2,&xb1,&yb1,&xb2,&yb2)){
		(check()) ? puts("YES") : puts("NO");
	}
	return 0;
}
bool check(){
	bool x = min(xa1,xa2) <= max(xb1,xb2) && max(xa1,xa2) >= min(xb1,xb2);
	if(!x)return false;
	bool y = min(ya1, ya2) <= max(yb1, yb2) && max(ya1, ya2) >= min(yb1, yb2);
	if(!y)return false;
	return true;
}

Measured memory_bytes: 1196
#include<iostream>
using namespace std;
int main()
{
	long i,g,j,ti,tj;
while(cin>>i>>j)
{
	g=-1;ti=i;tj=j;
	while(g==-1)
	{
	if(i<j){j=j-i;}
else if(i>j){i=i-j;}
else if(i=j){g=i;}
else if (i==0){g=j;}
else if(j=0){g=i;}
	}
cout<<g<<" ";
cout<<ti/g*tj<<endl;
}


return 0;
}

Measured memory_bytes: 1160
import java.util.*;

class Main{

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

		int  N = sc.nextInt();
		
		if(N == 1){
			System.out.println("Hello World");
		} else {
			int A = sc.nextInt();
			int B = sc.nextInt();
			System.out.println(A+B);
		}

	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <boost/shared_ptr.hpp>
using namespace std;

struct bad_input { };
struct Node;
typedef boost::shared_ptr<Node> NodePtr;
struct Node {
	NodePtr left;
	NodePtr right;
};

void show_intersection_tree(NodePtr root1, NodePtr root2)
{
	std::cout << '(';
	if (root1->left && root2->left) {
		show_intersection_tree(root1->left, root2->left);
	}
	std::cout << ',';
	if (root1->right && root2->right) {
		show_intersection_tree(root1->right, root2->right);
	}
	std::cout << ')';
}

void show_union_tree(NodePtr root1, NodePtr root2)
{
	std::cout << '(';
	if ((root1 && root1->left) || (root2 && root2->left)) {
		show_union_tree(root1 ? root1->left : root1, root2 ? root2->left : root2);
	}
	std::cout << ',';
	if ((root1 && root1->right) || (root2 && root2->right)) {
		show_union_tree(root1 ? root1->right : root1, root2 ? root2->right : root2);
	}
	std::cout << ')';
}

char get_token()
{
	char c;
	while (std::cin >> c) {
		if (c == '(' || c == ',' || c == ')') {
			break;
		}
		if (c != '\n' && c != ' ') {
			throw bad_input();
		}
	}
	return c;
}

NodePtr make_node(int no)
{
	NodePtr node = NodePtr(new Node);
	char c = get_token();
	if (c == '(') {
		node->left = make_node(no + 1);
		c = get_token();
	}
	if (c == ',') {
	}
	else {
		throw bad_input();
	}
	c = get_token();
	if (c == '(') {
		node->right = make_node(no + 1);
		c = get_token();
	}
	if (c == ')') {
	}
	else {
		throw bad_input();
	}
	return node;
}

int main()
{
	char op;
	while (std::cin >> op) {
		NodePtr root1, root2;
		if (get_token() == '(') {
			root1 = make_node(0);
		}
		else {
			throw bad_input();
		}
		if (get_token() == '(') {
			root2 = make_node(0);
		}
		else {
			throw bad_input();
		}
		if (op == 'i') {
			if (root1 && root2) {
				show_intersection_tree(root1, root2);
			}
		}
		else if (op == 'u') {
			if (root1 || root2) {
				show_union_tree(root1, root2);
			}
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
const string el = "\n";
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
int out(int a){cout << a << el; return 0;}
int out(string s = "NO"){cout << s << el; return 0;}
template <class T>
inline int out(vector<T>&v,string c = " "){
    for(int i = 0; i < v.size(); ++i){
        if(i) cout << c; cout << v[i];
    } cout << el;return 0;
}
template<class T> T gcd(T a,  T b) {return b ? gcd(b, a % b) : a;}
template<class U> U lcm( U m, U n ){if((0 == m )||( 0 == n ))return 0; return ((m / gcd(m, n)) * n); }
signed main(){
    int N,K; cin >> N >> K;
    vector<int>v(N);
    for(auto& e : v) cin >> e;
    int allgd = accumulate(all(v),v.front(),[&](int a,int b){return gcd(a,b);});
    bool f = (K % allgd == 0 and *max_element(all(v)) >= K);
    out(f ? "POSSIBLE" : "IMPOSSIBLE");
}




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

int main(){
  long N, M;
  cin >> N >> M;
  if(N==1 && M==1){
    cout << "1" << endl;
    return 0;
  }
  if(N==1){
    cout << M-2 << endl;
    return 0;
  }
  if(M==1){
    cout << N-2 << endl;
    return 0;
  }
  cout << (N-2)*(M-2) << endl;
  return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
s = list(reversed(list(input())))
n = len(s)
dp = [[0,0,0,0,0,0,0,0,0,0,0,0,0]for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
    if s[i] == '?':
        for k in range(10):
            x = k*pow(10,i,13) % 13
            for j in range(13):
                dp[i+1][(j+x) % 13] += dp[i][j] % mod
    else:
        x = int(s[i])*pow(10,i,13) % 13
        for j in range(13):
            dp[i+1][(j+x) % 13] += dp[i][j] % mod
print(dp[n][5] % mod)



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

class Program
{
    static readonly long MOD = 1000000007L;
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        long ans = s.GroupBy(c => c)
                    .Select(g => g.Count())
                    .Aggregate(1L, (accum, cnt) => (accum * (cnt + 1)) % MOD);
        ans = (ans - 1 + MOD) % MOD;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 14560
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <complex>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;
typedef complex<long double> point;

long double dot(const point& a, const point& b)
{
	return real(a) * real(b) + imag(a) * imag(b);
}

long double det(const point& a, const point& b)
{
	return real(a) * imag(b) - imag(a) * real(b);
}

vector<point> convex_hull(vector<point> ps)
{
	auto sort_fn = [](const point& a, const point& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	};
	sort(ps.begin(), ps.end(), sort_fn);

	int n = ps.size();
	vector<point> qs;

	for(int i = 0; i < n; ++i) {
		while(qs.size() > 1) {
			auto& x = qs[qs.size() - 2];
			auto& y = qs[qs.size() - 1];
			auto& z = ps[i];
			if(det(y - x, z - y) > 0)
				break;
			qs.pop_back();
		}
		qs.push_back(ps[i]);
	}

	int t = qs.size();

	for(int i = n - 2; i >= 0; --i) {
		while(qs.size() > t) {
			auto& x = qs[qs.size() - 2];
			auto& y = qs[qs.size() - 1];
			auto& z = ps[i];
			if(det(y - x, z - y) > 0)
				break;
			qs.pop_back();
		}
		qs.push_back(ps[i]);
	}

	qs.pop_back();

	return qs;
}

const long double PI = 3.14159265358979323846264338327950288;

int main()
{
	vector<point> ps;
	int n;

	scanf("%d", &n);

	for(int i = 0; i < n; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		ps.push_back(complex<long double>(x, y));
	}

	auto qs = convex_hull(ps);
	int m = qs.size();

	vector<double> ans(n, 0);

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

		auto& x = qs[(i + m - 1) % m];
		auto& y = qs[i];
		auto& z = qs[(i + 1) % m];

		auto t1 = y - x;
		auto t2 = z - y;

		long double a = dot(t1, t2) / (abs(t1) * abs(t2));
		a = max(min(a, (long double)1.0), (long double)-1.0);
		long double r = acos(a);

		long double p = r / (2 * PI);

		for(int j = 0; j < n; ++j) {
			if(y == ps[j])
				ans[j] = (double)p;
		}
	}

	for(auto a : ans) {
		printf("%.20lf\n", a);
	}

	return 0;
}

/* waffle */


Measured memory_bytes: 256
fun main(args: Array<String>) {
    edpb()
}

fun edpb() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val heights = readLine()!!.split(" ").map { it.toInt() }

    val inf = Long.MAX_VALUE / 100
    val dp = LongArray(101010) { inf }
    dp[0] = 0

    for (i in heights.indices) {
        for (j in 1..k) {
            if (i + j > heights.lastIndex) break
            dp[i + j] = Math.min(dp[i + j], dp[i] + Math.abs(heights[i] - heights[i + j]))
        }
    }

    val answer = dp[n - 1]

    println(answer)
}


Measured memory_bytes: 52000
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#define INF 1000000
#define MAX_N 10000 
#define MAX_M 20000

struct road{
	int to,length,cost;
};

std::vector<road> G[MAX_N];
int minimum_distance[MAX_N];
int N,M;

typedef std::pair<int, int> P;

void calc_length(){
	std::priority_queue<P, std::vector<P>, std::greater<P> > que;
	std::fill_n(minimum_distance,MAX_N,INF);
	const int s=0;
	minimum_distance[s]=0;
	que.push(P(0,s));

	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v=p.second;
		if(minimum_distance[v]< p.first) continue;
		for(int i=0;i<G[v].size();i++){
			road r=G[v][i];
			if(minimum_distance[r.to] > minimum_distance[v]+r.length){
				minimum_distance[r.to]=minimum_distance[v]+r.length;
				que.push(P(minimum_distance[r.to],r.to));
			}
		}
	}
	return;
}

void calc_cost(){
	int	total=0;
	for(int i=1;i<N;i++){
		int c=INF;
		for(int j=0;j<G[i].size();j++){
			road r=G[i][j];
			if(minimum_distance[i]==minimum_distance[r.to]+r.length){
				if(c>r.cost) c=r.cost;
			}
		}
		total+=c;
	}
	std::printf("%d\n",total);
	return;
}

int main(){
	while(std::scanf("%d %d",&N,&M),N|M){
		for(int i=0;i<MAX_N;i++) G[i].clear();
		for(int i=0;i<M;i++){
			int u,v,d,c;
			std::scanf("%d %d %d %d",&u,&v,&d,&c);
			u--;
			v--;
			road r1= {u,d,c};
			road r2= {v,d,c};
			G[v].push_back(r1);
			G[u].push_back(r2);
		}
		calc_length();
		calc_cost();
	}
	return 0;
}

Measured memory_bytes: 3112
#%%
machi = [0, 0, 0, 0]
for _ in range(3):
    a, b = map(int, input().split())
    machi[a-1] += 1
    machi[b-1] += 1

for m in machi:
    if m == 3:
        import sys
        print('NO')
        sys.exit()

print('YES')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

#define MOD 1000000007

int main()
{
    int N; cin >>N;
    vector<int> A(N+1);
    vector<int> pos(N, -1);
    int l, r;
    rep(i, N+1) {
        cin >> A[i];
        A[i]--;
        if (pos[A[i]] == -1) {
            pos[A[i]] = i;
        } else {
            l = pos[A[i]];
            r = i;
        }
    }

    vector<ll> fact(N+1+1);
    vector<ll> finv(fact.size());
    vector<ll> inv(fact.size());
    
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[0] = 0; inv[1] = 1;
    for (int i = 2; i < fact.size(); i++) {
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

    auto C = [&](int n, int r) { return fact[n] * finv[n-r] % MOD * finv[r] % MOD; };

    cout << N+1-1 << endl;
    for (int k = 2; k < N+1+1; k++) {
        ll a = C(N+1, k);
        ll b = l + N+1-(r+1) >= k - 1 ? C(l + N+1-(r+1), k-1) : 0;
        ll s = (a - b) % MOD;
        while (s < 0) s += MOD;
        cout << s << endl;
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <utility>

using namespace std;



int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(2, vector<int>(n));
	for (int i = 0; i < n; i++) {
		cin >> a.at(0).at(i);
	}
	for (int i = 0; i < n; i++) {
		cin >> a.at(1).at(i);
	}

	int ans = 0;

	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j <= i; j++) {
			sum += a.at(0).at(j);
		}
		for (int k = i; k < n; k++) {
			sum += a.at(1).at(k);
		}
		ans = max(ans, sum);
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }

  long long int ans1 = 0;
  long long int total1 = 0;
  for(int i=0;i<n;i++) {
    total1 += a[i];
    if(i % 2 == 0) {
      if(total1 <= 0) {
        ans1 += 1 - total1;
        total1 = 1;
      }
    }
    else {
      if(total1 >= 0) {
        ans1 += total1 + 1;
        total1 = -1;
      }
    }
  }

  long long int ans2 = 0;
  long long int total2 = 0;
  for(int i=0;i<n;i++) {
    total2 += a[i];
    if(i % 2 == 0) {
      if(total2 >= 0) {
        ans2 += total2 + 1;
        total2 = -1;
      }
    }
    else {
      if(total2 <= 0) {
        ans2 += 1 - total2;
        total2 = 1;
      }
    }
  }

  cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main(){
    int n;
    scanf("%d",&n);
    int ct[200005];
    int prev[n];
    memset(ct,-1,sizeof(ct));
    int a[n];
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
        prev[i] = ct[a[i]];
        ct[a[i]] = i;
    }
    int dp[n];
    dp[0] = 1;
    for (int i = 1; i < n; i++){
        dp[i] = dp[i-1];
        if (prev[i] != -1 && prev[i] != i-1){
            dp[i] += dp[prev[i]];
        }
        dp[i] %= mod;
    }
    //for (int i = 0; i <= n; i++) printf("%d\n",dp[i]);
    printf("%d",dp[n-1]);
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
  {
      string n;
      long long x,k=0;
      cin>>n;
      x=n.size();
      for(int i=0;i<x;i++)
      {
          if(n[i]=='7')
          {
             k++;
             break;
          }

      }
      if(k==1)
      {
           cout<<"Yes"<<endl;
      }
      else cout<<"No"<<endl;

  }


Measured memory_bytes: 3620
import sys
input = sys.stdin.readline
import numpy as np
N = int(input())
a = [int(x) for x in input().split()]
a = np.array(a)
ans = []
for i in range(-100, 101):
    b = np.array([i] * N)
    c = ((a - b) * (a - b)).sum()
    ans.append(c)
print(min(ans))


Measured memory_bytes: 12504
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
bl = True
if 'L' in S[0::2] or 'R' in S[1::2]:
    bl = False
print('Yes' if bl else 'No')


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

int main(){
    int a,b;cin >> a >> b;
    string res;
    if ((a+b) >= 10 ){
        cout << "error" << endl;
        return 0;
    }
    cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int main()
{
	IO_OP;
	
	string s;
	cin >> s;
	int a = 0, b = 0;
	for(char c:s) {
		if(c == '0')
			a++;
		else 
			b++;
	}
	cout << min(a, b) * 2 << endl;
}



Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, c, k;
  int result = 0;
  cin >> n >> c >> k;
  std::vector<int> t(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  std::sort(t.begin(), t.end());
  for (int i = 0; i < n;) {
    int limit     = t[i] + k;
    int passenger = 1;
    int target    = i + 1;
    while (passenger < c && target < n) {
      if (t[target] <= limit) {
        target++;
        passenger++;
      } else {
        break;
      }
    }
    i = target;
    result++;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair<int, int>P;

int N;


int main(){
  cin >> N;
  vector<P>res;
  string s = "";
  for(int i=0;i<N;i++){
    s += "0";
  }
  for(int i=0;i<N;i++){
    s[i] = '1';
    for(int j=i+1;j<N;j++){
      s[j] = '1';
      cout << "? " << s << endl;
      int d;  cin >> d;
      if(d){
	res.push_back(P(i, j));
      }
      s[j] = '0';
    }
    s[i] = '0';
  }

  cout << "!";
  for(auto &r: res){
    cout << " (" << r.first << "," <<  r.second << ")";
  }
  cout << endl;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  string S1, S2, S3;
  char second;
  string result = "A";
  
  cin >> S1 >> S2 >> S3;
  second = S2.at(0);
  
  result += second;
  result += "C";
  
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i, n) FOR(i,0,n)

using namespace std;
typedef long long ll;
const int INF = 1e9;

int x,y;

void solve(){
    int count = 0;
    while(1){
        if(x==y)break;
        if(-x <= y){
            if (y > 0 && x>=0 && y>x){
                ;
            }
            else {
                count++;
                x=-x;
                continue;
            }
        } else {
            if (y < x && x<0){
                count++;
                x=-x;
                continue;
            }
        }
        count++;
        x++;
        continue;
    }
    cout << count << "\n";
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x >> y;
    solve();
    return 0;
}

Measured memory_bytes: 256