akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner scan = new Scanner(System.in);

		while(true){
			int y = 0;
			int n = scan.nextInt();
			int x = scan.nextInt();
			if ((n==0) && (x==0)) break;
			for(int i=1; i<=n; i++){
				for(int i2=i+1; i2<=n; i2++){
					for(int i3=i2+1; i3<=n; i3++) {
						if ((x == (i + i2 + i3)) && (i!=i2) && (i!=i3) && (i2!=i3)) {
							y = y+1;
						}
					}
				}
			}
			System.out.println(y);
		}
		
	}

}

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

using namespace std;

bool d[81][81][13000];

int main() {
	int n, m;
	int t[81][81];
	cin>>n>>m;
	for (int i = 0; i <= n; i++)
	for (int j = 0; j <= m; j++)
	for (int k = 0; k < 13000; k++)
		d[i][j][k] = 0;
	int k;
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++)
		cin>>t[i][j];
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++) {
		cin>>k;
		t[i][j] = abs(t[i][j] - k);
	}
	d[1][1][t[1][1]] = 1;
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++)
	for (int k = 0; k <= 160*80; k++) {
		d[i][j][k] = d[i][j][k] || d[i][j - 1][abs(k - t[i][j])] || d[i][j - 1][abs(k + t[i][j])] || d[i - 1][j][abs(k - t[i][j])] || d[i - 1][j][abs(k + t[i][j])];
		//if (d[i][j][k]) cout<<i<<" "<<j<<" "<<k<<" "<<endl;	
	}
	int ind = -1;
	for (int k = 0; k <= 160*80; k++)
		if (d[n][m][k]) {
			ind = k;
			break;
		}
	cout<<ind<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int count=1;
  
   
  for(int i=0; i<N; i++)
    cin >> A.at(i);
  
  sort( A.begin(), A.end() );
  
  for(int i=0; i<N; i++){
   int j=i-1;
    
    if(i==0)
      continue;
    
    else if( A.at(i)==A.at(j) ){
      cout << "NO" << endl;
    break;
    }
    
    else
      count++;
  }
  
  if(count==N){
    cout << "YES" << endl;
  }
}
  

Measured memory_bytes: 1024
#define rep(i,n) for (int i=0;i<(n);i++)
#include<iostream>
using namespace std;

bool turn(int n,int m,string (*a),string (*b)){
	bool exist = false;
	rep(i,n){
		rep(j,n){
				bool match = true;
				if(i+m-1>n or j+m-1>n) continue;//超えたら止まる
				for(int y=0;y<m;y++){
					for(int x=0;x<m;x++){
						if(a[i+y][j+x]!=b[y][x]) match=false;
						continue;
					}
				}
				if(match) exist=true;
		}
	}
	return exist;
}

int main(){
	int m,n;
	string a[51],b[51];
	cin >> n >> m;
	rep(i,n) cin >>a[i];
	rep(i,m) cin >>b[i];

	cout << ((turn(n,m,a,b)) ? "Yes\n":"No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
typedef long long ll;
ll nums[N];
ll cnts[N];
int n;
ll sum;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i ++ ) {
        cin >> nums[i];
        cnts[nums[i]] ++;
    }
    for(int i = 1; i <= n; i ++) {
        sum += cnts[i]*(cnts[i] - 1)/2;
    }
    //cout << sum << endl;
    for(int i = 1; i <= n; i ++) {
        cout << sum - cnts[nums[i]] + 1 << endl;
    }
    return 0;
}    

Measured memory_bytes: 4736
class UnionFind:
    def __init__(self, num):
        self.table = [-1 for _ in range(num)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)

        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False
N,M = map(int,input().split())
u = UnionFind(N)
p = list(map(int,input().split()))
for _ in range(M):
    x,y = map(int,input().split())
    u.union(p[x-1]-1,p[y-1]-1)

ans = 0
for i in range(N):
    if u.find(i) == u.find(p[i]-1):
        ans += 1

print(ans)

Measured memory_bytes: 14640
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main(int argc, char** argv) {
	long double a,b,h,m;
	cin >> a >> b >> h >> m;
	h+=m/60.0;
	h/=6.0;
	m/=30.0;
	h*=acos(-1);
	m*=acos(-1);
	h-=m;
	//if(h<0) h+=2*acos(-1);
//	while(h<0) h+=2*acos(-1);
//	if(h>acos(-1)) h=acos(-1)*2-h;
	printf("%.100Lf",sqrt(a*a+b*b-2*a*b*cos(h)));
	return 0;
}

Measured memory_bytes: 3552
def resolve():
    H, W = list(map(int, input().split()))
    S = [input() for i in range(H)]
    A = []
    for i in range(H):
        line = ""
        for j in range(W):
            if S[i][j] == "#":
                line += "#"
                continue
            cnt = 0
            if i-1 >= 0:
                cnt += 1 if j-1 >= 0 and S[i-1][j-1] == "#" else 0
                cnt += 1 if S[i-1][j] == "#" else 0
                cnt += 1 if j+1 < W and S[i-1][j+1] == "#" else 0

            cnt += 1 if j-1 >= 0 and S[i][j-1] == "#" else 0
            cnt += 1 if S[i][j] == "#" else 0
            cnt += 1 if j+1 < W and S[i][j+1] == "#" else 0

            if i+1 < H:
                cnt += 1 if j-1 >= 0 and S[i+1][j-1] == "#" else 0
                cnt += 1 if S[i+1][j] == "#" else 0
                cnt += 1 if j+1 < W and S[i+1][j+1] == "#" else 0
            
            line += str(cnt)
        A.append(line)
    
    [print(l) for l in A]

            

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 39664
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int N = 1e6 + 100;

int Cnt[N];

int main()
{
	int n;	cin >> n;
	vector <int> v;
	map <int, int> c;
	for (int i = 0; i < n; i++) {
		int x;	cin >> x;
		c[x]++;
		v.push_back(x);
	}

	sort(v.begin(), v.end());

	int Ans = 0;
	for (int i = 0; i < n; i++) {
		if (Cnt[v[i]] == 0) {
			if (c[v[i]] == 1)
				Ans++;
			for (int j = v[i]; j < N; j += v[i])
				Cnt[j]++;
		}
	}

	cout << Ans << '\n';
	return 0;
}


Measured memory_bytes: 17364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005;
struct node
{
	int to;
	ll v;
	node(int a=0,int b=0){to=a;v=b;}
};
vector<node> path[N];
bool use[N];
ll d[N];
bool dfs(int o)
{
	use[o]=true;
	for(int i=path[o].size()-1;i>=0;i--)
	{
		node e=path[o][i];
		if(d[e.to]>d[o]+e.v)
		{
			if(use[e.to]) return true;
			d[e.to]=d[o]+e.v;
			if(dfs(e.to)) return true;
		}
	}
	use[o]=false;
	return false;
}
int main()
{
	int n,m,a,b;
	ll dd;
	scanf("%d%d",&n,&m);
	while(m--)
	{
		scanf("%d%d%lld",&a,&b,&dd);
		path[a].push_back(node(b,dd));
		path[b].push_back(node(a,-dd));
	}
	for(int i=1;i<=n;i++) 
	{
		d[i]=LLONG_MAX;
		path[0].push_back(node(i,0));
	}
	if(dfs(0)) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 18292
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define ls rt<<1
#define rs rt<<1|1
#define pb push_back
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(false)
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 5e4+5;
const ll MOD = 1e9+7;

int c[25], dp[MAXN];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    rep(i, 1, m){
        scanf("%d", &c[i]);
    }
    sort(c+1, c+m+1);
    rep(i, 1, n){
        dp[i] = dp[i-1]+1;
    }
    rep(i, 2, m){
        rep(j, c[i], n){
            dp[j] = min(dp[j], dp[j-c[i]] + 1);
        }
    }
    printf("%d\n", dp[n]);

    return 0;
}



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

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

  const int nmmax = 50;
  int a[nmmax], b[nmmax];

  for (int i = 0; i < M; ++i)
  {
    cin >> a[i] >> b[i];
  }

  int road[nmmax];
  for (int i = 0; i < N; ++i)
  {
    road[i] = 0;
  }

  for (int i = 0; i < M; ++i)
  {
    road[a[i] - 1] += 1;
    road[b[i] - 1] += 1;
  }

  for (int i = 0; i < N; ++i)
  {
    cout << road[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim().chars().collect::<Vec<char>>();
	let mut ret:i32 = 0;
	for i in s {
		if i == '+' {
			ret += 1;
		}else{
			ret -= 1;
		}
	}
	println!("{}", ret);
}

Measured memory_bytes: 4352
import java.util.BitSet;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;


public class Main {
	public static int[] dx = {1, 0, -1, 0};
	public static int[] dy = {0, 1, 0, -1};
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int h = in.nextInt();
			int w = in.nextInt();
			int c = in.nextInt();
			if(h==0) break;
			int[][] p = new int[h][w];
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					p[i][j] = in.nextInt();
				}
			}
			if(h*w <= 5){
				System.out.println(h*w);
				continue;
			}
			init(p[0][0], c);
			Deque<Integer> qu;
			BitSet conb = new BitSet(h*w);
			BitSet next = new BitSet(h*w);
			BitSet inqu = new BitSet(h*w);
			int res = 0;
			do{
				qu = new LinkedList<Integer>();
				qu.add(0);
				int idx = 0;
				conb.clear();
				next.clear();
				inqu.clear();
				inqu.set(0);
				while(!qu.isEmpty()){
					int panel = qu.poll();
					inqu.clear(panel);
					int x = panel % w;
					int y = panel / w;
					if(p[y][x] != counter[idx]){
						if(next.get(panel)){
							if(idx == 5) break;
							idx++;
							next.clear();
							qu.add(panel);
							inqu.set(panel);
							continue;
						}
						inqu.set(panel);
						next.set(panel);
						qu.add(panel);
						continue;
					}
					conb.set(panel);
					for(int i=0; i<4; i++){
						int nx = x+dx[i];
						int ny = y+dy[i];
						if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
						int np = ny*w+nx;
						if(inqu.get(np) || conb.get(np)) continue;
						qu.push(np);
						inqu.set(np);
					}
				}
//				if(conb.cardinality() == 15){
//					for(int i=0; i<h; i++){
//						for(int j=0; j<w; j++){
//							System.out.print(conb.get(i*w+j)?1:0);
//						}
//						System.out.println();
//					}
//					System.out.println();
//				}
				res = Math.max(res, conb.cardinality());
			}while(!incCount());
			System.out.println(res);
		}
	}

	public static int[] debug = {1,6,3,4,2,5};
	public static boolean debug(){
		for(int i=0; i<6; i++){
			if(debug[i] != counter[i]) return false;
		}
		return true;
	}

	public static void init(int begin, int end){
		counter = new int[6];
		counter[0] = begin;
		counter[5] = end;
	}

	public static int[] counter;
	public static boolean incCount(){
		for(int i=1; i<5; i++){
			counter[i]++;
			if(counter[i] <= 6) break;
			counter[i] = 0;
			if(i==4) return true;
		}
		return false;
	}
}

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

using namespace std;

#define TAX_RATE 0.08

int solve(int N) {
    double value = N / (TAX_RATE + 1);
    if ((int)((int)value * (1 + TAX_RATE)) == N) {
        return (int)value;
    } else if ((int)(((int)value + 1) * (1 + TAX_RATE)) == N) {
        return ((int)value + 1);
    } else {
        return -1;
    }

}

int main(void) {
    int N;
    cin >> N;
    int ret = solve(N);
    if (ret >= 0) {
        cout << ret << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,c,k;
  cin>>n>>c>>k;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  ll cnt=1,knt=a[0],count=1;
  for(int i=1;i<n;i++){
    if(a[i]-knt<=k&&cnt<c){
      cnt++;
    }else{
      count++;
      knt=a[i];
      cnt=1;
    }
  }
  cout<<count;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int INF = 1e9;
int x;
int dp[1003];
int main(){
  cin>>x;
  dp[1]=1;
  for(int i=2;i<x;i++){
    int a=i*i;
    while(a<=x){
      dp[a]=1;a*=i;
    }
  }
  for(int i=x;i>=1;i--){
    if(dp[i]==1){cout<<i<<endl;break;}
  }
  
  return 0;
}



Measured memory_bytes: 256
from collections import defaultdict


def main():
    s = input()
    for i in range(len(s) - 1):
        if s[i] == s[i + 1]:
            print(i + 1, i + 2)
            return
    for i in range(len(s) - 2):
        if s[i] == s[i + 2]:
            print(i + 1, i + 3)
            return
    print(-1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}

int main(){
  LL H,N,i,j,a=0,n=0,ans=INF;
  scanf("%lld%lld",&H,&N);
  LL A[N],B[N],dp[H+1];
  FOR(i,0,N)scanf("%lld%lld",&A[i],&B[i]);
  dp[0]=0;
  FOR(i,1,H+1)dp[i]=INF;
  FOR(i,0,N)FOR(j,0,H)dp[MIN(H,j+A[i])]=MIN(dp[MIN(H,j+A[i])],dp[j]+B[i]);

  printf("%lld\n",dp[H]);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void)
{
    int i;
    int max, n, count;
    int num[100];
   
    memset(num,'0',sizeof(num));

    count = 0;
    max = 0;

    while(scanf("%d", &n) != EOF){
        num[n - 1]++;
        count++;
    }

    for (i = 0;i < count;i++){
        if (max < num[i]){
            max = num[i];
        }
    }

    for (i = 0;i < count;i++){
        if (max == num[i]){
            printf("%d\n", i + 1);
            fflush(stdout);
        }
    }

    return 0;
}

Measured memory_bytes: 0
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    string s;
    cin >> s;
    int L=s.length();
    int num=0;
    char tmp;
    int kyori=0;
    int ans=100000;
    int pos=0;
for(char c = 'a'; c <='z';++c){
    int cnt=0,max_cnt=0;
    for(int i=0;i<L;++i){
        if(s[i]==c){
            max_cnt=max(max_cnt,cnt);
            cnt=0;
        }
        else if(i==L-1)max_cnt=max(max_cnt,cnt+1);
        else cnt++;
    }
    ans=min(ans,max_cnt);
}
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a[4]; char s[4];
	for(int i=0;i<4;i++){
		cin>>s[i];
        a[i]=s[i]-'0';
		s[i]='+';
	}
	if(a[0]+a[1]+a[2]-a[3]==7) s[2]='-';
	else if(a[0]+a[1]-a[2]+a[3]==7) s[1]='-';
	else if(a[0]+a[1]-a[2]-a[3]==7){
      s[1]='-'; 
      s[2]='-';
    }
	else if(a[0]-a[1]+a[2]+a[3]==7) s[0]='-';
	else if(a[0]-a[1]+a[2]-a[3]==7){
      s[0]='-';
      s[2]='-';
    }
	else if(a[0]-a[1]-a[2]+a[3]==7){
      s[0]='-';
      s[1]='-';
    }
	else if(a[0]-a[1]-a[2]-a[3]==7){
      s[0]='-'; 
      s[1]='-'; 
      s[2]='-';
    }

	cout<<a[0]<<s[0]<<a[1]<<s[1]<<a[2]<<s[2]<<a[3]<<"=7"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
 		Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	String T = sc.next();
    	int count = 0;
    if(S == T){
     	System.out.println("0"); 
    }else{
     	for(int i=0;i<S.length();i++){
          	if(S.charAt(i) != T.charAt(i)){
              	count++;
            }
        }
    }
    	System.out.println(count);
  }
}


Measured memory_bytes: 41084
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;


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

	int cnt = 1;

	for (int i = 0; i < N; ++i)
	{
		int a; cin >> a;
		if (a == cnt)
		{
			cnt++;
		}
	}
	if (cnt == 1)
	{
		cout << -1 << endl;
		return 0;
	}
	cout << N - cnt + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int MOD = 1000000007;

int main()
{
	int a, b = 0;
	cin >> a >> b;

	int ans = 0;
	ans = (b % a == 0) ? a + b : b - a;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
s=input()
cnt=0
for i in  range(0,len(s)):
            if i%2==0:
                        if s[i]=='L':
                                    cnt+=1
            else:
                        if s[i]=='R':
                                    cnt+=1
if cnt==0:
            print('Yes')
else:
            print('No')
            


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    cout<<s.substr(0,s.size()-8)<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int a[100010];
int b[100010];

int main(void){
    int n=in(),W=in(),H=in(),i,x,y,w,f=1;
    rep(i,n){
        x=in(),y=in(),w=in();
        if(x-w>0)a[x-w]++;
        else a[0]++;
        if(x+w<W)a[x+w]--;
        else a[W+1]--;
        if(y-w>0)b[y-w]++;
        else b[0]++;
        if(y+w<H)b[y+w]--;
        else b[H+1]--;
    }
    for(i=1;i<=W;i++)a[i]+=a[i-1];
    for(i=1;i<=H;i++)b[i]+=b[i-1];
    for(i=0;i<=W;i++)if(!a[i])f=0;
    for(i=0;i<=H;i++)if(!b[i]&&!f){puts("No");return 0;}
    puts("Yes");
    return 0;
}


Measured memory_bytes: 2512
#include <iostream>
using namespace std;
int main()
{
  int n,x,y,h,w,s;
  for(;;){
    cin >> n;
    if(n==0)break;
    s = 0;
    while(n--){
      cin >> x >> y >> h >> w;
      x = x + y + h;
      if(x <= 60 && w <= 2) s += 600;
      else if(x <= 80 && w <= 5) s += 800;
      else if(x <= 100 && w <= 10) s += 1000;
      else if(x <= 120 && w <= 15) s += 1200;
      else if(x <= 140 && w <= 20) s += 1400;
      else if(x <= 160 && w <= 25) s += 1600;
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 0
main = interact $ unlines.solve.map read.words

solve :: [Int] -> [String]
solve []     = []
solve (n:ns) = (show.length $ anslist):solve ns
    where anslist = [(a,b,c,d) | a <- [0..9], b <- [0..9], c <- [0..9], d <- [0..9], a+b+c+d == n] 

Measured memory_bytes: 4132
h , w = map(int,input().split())
p = []
for i in range(h+2):
    kar = []
    if i == 0 or i == h+1:
        p.append(["!" for j in range(w+2)])
    else:
        kar = list(input())
        kar.insert(0,"!")
        kar.append("!")
        p.append(kar)
for i in range(1,h+1):
    for j in range(1,w+1):
        cou = 0
        if p[i][j] == "#":
            print("#",end="")
        elif p[i][j] ==".":
            for k in range(-1,2):
                for l in range(-1,2):
                    if p[i+k][j+l] == "#":
                        cou += 1
            print(cou,end="")
    print("")

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

int main()
{
    ll n,l;
    cin>>n>>l;
    ll minab=l+1000;
    ll ans;
    rep(0,i,n){
        ll sum=0;
        ll x;
        rep(0,j,n){
            if(i==j){
                x=l+j;
                minab=min(minab,abs(x));
                //cout<<minab<<endl;
                continue;
            }
            sum+=l+j;
        }
        //cout<<sum<<endl;
        if(minab==abs(x))ans=sum;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  ll N, M, X;

  cin >> N >> M >> X;

  ll cost0 = 0;
  ll costN = 0;

  for (int i = 0; i < M; i++) {
    int tmp;
    cin >> tmp;
    if (tmp < X)
      cost0++;
    else
      costN++;
  }

  cout << min(cost0, costN) << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
isMinus = False
for i in range(N):
    if A[i] < 0:
        isMinus = not isMinus
        A[i] = A[i]*-1

if isMinus:
    print(sum(A)-min(A)*2)
else:
    print(sum(A))


Measured memory_bytes: 85404
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), a = fs.nextInt(), b = fs.nextInt();
		long v[] = fs.nextLongArray(n);
		rsort(v);
		double ave = 0;
		for(int i=0;i<a;i++) {
			ave += v[i];
		}
		ave /= a;
		long t = v[a-1];
		int cnt = 0;
		for(int i=0;i<n;i++) {
			if(v[i]==t)cnt++;
		}
		int cnt1 = 0;
		for(int i=0;i<a;i++) {
			if(v[i]==t)cnt1++;
		}
		
		//パスカルの三角形により求める
		long c[][] = new long[62][62];
		c[0][0]=1;
		for(int i=0;i<60;i++) {
			for(int j=0;j<60;j++) {
				c[i+1][j] += c[i][j];
				c[i+1][j+1] += c[i][j];
			}
		}
		
		long pat = 0;
		
		if(v[0]==v[a-1]) {
			int max = Math.min(b, cnt);
			for(int i=a;i<=max;i++) {
				pat += c[cnt][i];
			}
		}
		else {
			pat = c[cnt][cnt1];
		}
		
		System.out.println(ave);
		System.out.println(pat);
	}
	
	
	
	//reverseOrderSort : O(NlogN)
	static void rsort(int[] ar) {
		Arrays.sort(ar);
		int len = ar.length;
		for (int i = 0; i < len / 2; i++) {
			int tmp = ar[i];
			ar[i] = ar[len - 1 - i];
			ar[len - 1 - i] = tmp;
		}
	}

	static void rsort(long[] ar) {
		Arrays.sort(ar);
		int len = ar.length;
		for (int i = 0; i < len / 2; i++) {
			long tmp = ar[i];
			ar[i] = ar[len - 1 - i];
			ar[len - 1 - i] = tmp;
		}
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

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

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

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

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

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

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

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;

const int max_n=500005;
char s[max_n];
int n,a[max_n];
int l[max_n],r[max_n];
int main(){
    scanf(" %s",s+1);
    int n=strlen(s+1)+1;
    for(int i=1;i<n;i++){
        if(s[i]=='>')l[i]=i;
        else l[i]=l[i-1];
    }
    r[n]=n;
    for(int i=n-1;i>=1;i--){
        if(s[i]=='<')r[i]=i;
        else r[i]=r[i+1];
    }
    for(int i=1;i<=n;i++){
        a[i]=max(i-1-l[i-1],r[i]-i);
    }
    ll sum=0;
    for(int i=1;i<=n;i++)sum+=a[i];
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 6528
N = int(input())
a = list(map(int,input().split()))
A = []
B = []
d = []
for i in a:
    add = i // 400
    if add < 8:
        A.append(add)
    else:
        B.append(add)
    if add not in d and add < 8:
        d.append(add)
ans_min = len(d)
if len(d) == 0 and len(B) > 0:
    ans_min = 1
ans_max = len(d) + len(B)
print(ans_min)
print(ans_max)

Measured memory_bytes: 3064
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    long a, b, ab, x, y;
    scan(a, b, ab, x, y);
    long cost1, cost2, cost3, cost4;
    cost1 = a * x + b * y;
    cost2 = ab * 2 * max(x, y);

    long tmp;
    tmp = ab * min(x, y) * 2;
    // writeln("tmp", tmp);
    if (x > y)
    {
        cost3 = tmp + a * (max(x, y) - min(x, y));

    }
    else
    {
        cost4 = tmp + b * (max(x, y) - min(x, y));
    }
    // writeln(cost1);
    // writeln(cost2);
    // writeln(cost3);
    // writeln(cost4);

    if (cost3 == 0)
    {
        writeln(min(cost1, cost2, cost4));
    }
    if (cost4 == 0)
    {
        writeln(min(cost1, cost2, cost3));
    }

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 3644
n, k = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
p = 10 ** 9 + 7

DP = [[0] * (k + 1) for i in range(n + 1)]
for i in range(n + 1):
    DP[i][0] = 1

for i in range(n):
    for j in range(k):
        DP[i+1][j+1] = DP[i + 1][j]
        DP[i+1][j+1] += DP[i][j+1]
        if j - A[i] >= 0: DP[i+1][j+1] -= DP[i][j - A[i]]
        DP[i+1][j+1] %= p
    
print(DP[n][k])

Measured memory_bytes: 119660
a, b, k = map(int, input().split())

ans = 0

lista = list(range(a+1))
aa = lista.pop(0)

listb = list(range(b+1))
bb = listb.pop(0)

if (a < b):
    li = [i for i in lista if a % i == 0 and b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]
else:
    li = [i for i in listb if a % i == 0 and b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n,k;cin >> n >> k;
    vector<int> snuke(n);
    rep(i,k) {
        int d;cin >> d;
        rep(j,d){
            int a;
            cin >> a;
            a--;
             snuke[a]++;
        }
    }
    ll ans = 0;
    rep(i,n){
        if(snuke[i]==0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top = 0, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop(void) {
  top--;
  return S[top+1];
}

int main(void) {
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}


Measured memory_bytes: 2144
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
template <class... T> void printArr(T&&...){ }
#endif

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll mini = a * (n - 1) + b,
        maxi = a + b * (n - 1);
    cout << max(0ll, maxi - mini + 1) << '\n';
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

string max(string a, string b){
	int x;
	for (x = 0; x < min(a.length(), b.length()); x ++) if (a[x] != b[x]) return a[x] > b[x] ? a : b;
	return a.length() > b.length() ? a : b;
}

string func(string S, string T){
	int n = S.length() >> 1, x;
	vector <int> A, B;
	for (x = 0; x < n << 1; x ++) {
		if (S[x] == 'a') A.pb(x);
		if (S[x] == 'b') B.pb(x);
	}
	if (S[0] == 'b') {
		int i, j;
		string r = T;
		for (x = 0; x < n; x ++) {
			string u;
			i = j = x;
			while (i < n && j < n) A[i] < B[j] ? (++i, u += 'a') : (++j, u += 'b');
			while (i < n) u += 'a', ++i;
			while (j < n) u += 'b', ++j;
			r = max(r, u + T);
		}
		return r;
	} else {
		int y = 0, c = 0;
		string r = T, u = "";
		for (x = 0; x < n; x ++) if (A[x] >= y) ++c, y = B[x] + 1;
		for (x = 0; x < c; x ++) u += "ab", r = max(r, u + T);
		return r;
	}
}

string solve(string S){
	string res = "";
	int x, y = S.length(), z, c = 0;
	for (x = y - 1; x >= 0; x --) {
		c += S[x] == 'a' ? 1 : -1;
		if (c == 0) {
			string T = "";
			for (z = x; z < y; z ++) T += S[z];
			res = func(T, res);
			y = x;
		}
	}
	return res;
}

int main(){
	string S;
	scanf("%*d"), cin >> S;
	cout << solve(S) << "\n";
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>

int main () {
    
    char a[11], b[11], c[11];
    scanf("%s%s%s", a, b, c);
    printf("%c%c%c", a[0] - 'a' + 'A', b[0] - 'a' + 'A', c[0] - 'a' + 'A');
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOD 1000000007
 
using namespace std;
 
int main() {
    ll H,W; cin >> H >> W;
    if(H == 1 or W == 1){
        cout << 1 << endl;
    }
    else if(H%2 == 0){
        cout << H/2 * W << endl;
    }else if(W%2 == 0){
        cout << W/2 * H << endl;
    }
    else{
        cout << H*W/2+1 << endl;
    }
}

Measured memory_bytes: 256
//Author: Pakhomovee 
#include <iostream> 
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <deque>
#include <assert.h>

using namespace std;
using namespace std::chrono;

void solve()
{
	vector<int> x(5);
	for (int i = 0; i < 5; ++i)
	{
		cin >> x[i];
	}
	for (int i = 0; i < 5; ++i)
	{
		if (x[i] == 0)
		{
			cout << i + 1;
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	auto start = system_clock::now();

	solve();

	auto end = system_clock::now();
	cerr << "Time: " << duration_cast<milliseconds> (end - start).count() << "ms" << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);

	int A,B;
	cin >>A >>B;
	for(int i = 1; i <= 100000; i++) {
		int a = i * 0.08;
		int b = i * 0.1;
		if(a == A and b == B){
			cout << i << endl;
			return 0;
		}
	}
	dame
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int k = int.Parse(input[1]);
        int q = int.Parse(input[2]);

        int[] d = new int[n];
        for (int i = 0; i < n; i++)
        {
            d[i] = 0;
        }

        for (int i = 0; i < q; i++)
        {
            d[int.Parse(Console.ReadLine())-1]++;
        }

        int line = q - k + 1;
        int cnt = 0;
        for (int i = 0; i < n; i++)
        {
            if(d[i] >= line)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }

}

Measured memory_bytes: 17600
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  int N, cnt = 0;
  cin >> N;
  int d1, d2;
  for (int i = 0; i < N; i++) {
    cin >> d1 >> d2;
    if (d1 == d2) {
      cnt++;
    } else {
      cnt = 0;
    }
    if (cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3124
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

output:
0 0
1 2
2 2
3 1
4 3
"""

import sys
import heapq as hp

WHITE, GRAY, BLACK = 0, 1, 2


def generate_adj_table(v_table):
    for each in v_table:
        v_index, v_adj_length, *v_adj_list = map(int, each)
        # assert len(v_adj_list) == v_adj_length * 2
        for pair in zip(v_adj_list[::2], v_adj_list[1::2]):
            init_adj_table[v_index][pair[0]] = pair[1]

    return init_adj_table


def dijkstra_path_heap():
    # path search init
    distance[init_vertex] = 0
    path_heap = []
    # heapq: rank by tuple[0], at here it's d[u]
    hp.heappush(path_heap, (0, init_vertex))

    while path_heap:
        current = hp.heappop(path_heap)[1]

        color[current] = BLACK

        for adj, cost in adj_table[current].items():
            if color[adj] is not BLACK:
                # alt: d[u] + w[u,v]
                alt_path = distance[current] + cost
                if alt_path < distance[adj]:
                    # update path_list
                    distance[adj] = alt_path
                    # update heap
                    hp.heappush(path_heap, (alt_path, adj))
                    color[adj] = GRAY
                    parents[adj] = current

    return distance


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices = int(_input[0])
    v_info = map(lambda x: x.split(), _input[1:])
    # assert len(init_vertices_table) == vertices_num

    distance = [float('inf')] * vertices
    parents = [-1] * vertices
    color = [WHITE] * vertices
    init_adj_table = tuple(dict() for _ in range(vertices))
    init_vertex = 0

    adj_table = generate_adj_table(v_info)
    ans = dijkstra_path_heap()
    for i, v in enumerate(ans):
        print(i, v)

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 17;

const int inf = 1e15;

int n, a[N][N], dp[(1 << N)], sum[(1 << N)];

bool checkBit(int x, int pos) {
    if((x & (1 << pos)))
        return 1;
    else
        return 0;
}

int setBit(int x, int pos) {
    return (x | (1 << pos));
}

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++)
            cin >> a[i][j];
    }
    for(int mask = 0; mask < (1 << N); mask++)
        dp[mask] = -inf;
    for(int mask = 0; mask < (1 << n); mask++) {
        int people = 0, total = 0;
        for(int j = 0; j < n; j++) {
            if(checkBit(mask, j) == 0) {
                total = 0;
                for(int k = 0; k < n; k++) {
                    if(checkBit(mask, k))
                        total += a[k][j];
                }
                sum[setBit(mask, j)] = total + sum[mask];
            }
        }
        //cout << sum[mask] << " " << mask << "\n";
    }
    dp[0] = 0;
    for(int mask = 1; mask < (1 << n); mask++) {
        dp[mask] = sum[mask];
        for(int submask = mask; submask; submask = (submask - 1) & mask)
            dp[mask] = max(dp[mask], dp[submask] + sum[mask ^ submask]);
    }
    cout << dp[(1 << n) - 1];
}


Measured memory_bytes: 1920
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		// n日間
		int n = scan.nextInt();

		// 宿題の数
		
		int m = scan.nextInt();

		ArrayList list = new ArrayList();

		for(int i = 0; i < m; i++) {
			list.add(scan.nextInt());
		}

		int s = 0;
		for(int i = 0; i < m; i++) {
			s += (int)list.get(i);
		}

		// 休みより宿題が多い
		if(s > n) {
			// 宿題を終わらせることができない
			System.out.println(-1);
		}else {
			System.out.println(n - s);
		}

	}
}

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

const int INF = 1 << 28;
int N, M;
int adj[110][110];

int calc(vector<int> &vec) {
    int S = vec.size(), res = 0;
    if(vec.size() < 2) return 0;
    for(int i=0; i<S; i++) {
        int cost = INF;
        for(int j=0; j<S; j++) {
            if(i == j) continue;
            cost = min(cost, adj[ vec[i] ][ vec[j] ]);
        }
        res += cost;
    }
    return res;
}

void dfs(int cur, int &ans, vector<int> vec = vector<int>()) {
    if(cur == N) return;
    
    // 取る
    int min_cost = INF;
    for(auto e : vec) min_cost = min(min_cost, adj[cur][e]);

    if(min_cost > 0) {
        vector<int> nvec = vec;
        nvec.push_back(cur);
        ans = max(ans, calc(nvec));
        dfs(cur+1, ans, nvec);
    }

    // 取らない
    dfs(cur+1, ans, vec);
}

int main() {
    cin >> N >> M;
    for(int i=0; i<M; i++) {
        int u, v, c; cin >> u >> v >> c;
        u--; v--;
        adj[u][v] = adj[v][u] = c;
    }

    int ans = 0;
    dfs(0, ans);
    cout << ans << endl;
    return 0;
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()
#define mod 1e9+7

using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using P = pair<int,int>;

main()
{
        int a; cin>>a;
        string s; cin>>s;
        cout<<(a>=3200?s:"red")<<endl;
}

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

int ct, k, n, ans[300005];
int main()
{
	scanf("%d%d", &k, &n);
	if (!(k & 1))
	{
		ans[1] = k / 2;
		for (int i = 2; i <= n; i++)
			ans[i] = k;
		for (int i = 1; i <= n; i++)
			printf("%d ", ans[i]);
	}
	else
	{
		int pnt = n;
		for (int i = 1; i <= n; i++)
			ans[i] = (k + 1) / 2;
		for (int i = 1; i <= n / 2; i++)
			while (true)
			{
				ans[pnt]--;
				if (ans[pnt] == -1)
					ans[pnt] = 0, pnt--;
				else
				{
					if (!ans[pnt]) pnt--;
					else while (pnt != n)
						ans[++pnt] = k;
					break;
				}
			}
		for (int i = 1; i <= n; i++)
			if (ans[i]) printf("%d ", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 4964
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        MaxMinSums solver = new MaxMinSums();
        solver.solve(1, in, out);
        out.close();
    }

    static class MaxMinSums {
        public static int MOD = 1000000007;
        static long[] fac;
        static long[] finv;
        static long[] inv;

        static void comInit(int max) {
            fac = new long[max + 1];
            finv = new long[max + 1];
            inv = new long[max + 1];

            // 階乗
            fac[0] = fac[1] = 1;
            // 逆元の階乗
            finv[0] = finv[1] = 1;
            // 逆元
            inv[1] = 1;

            for (int i = 2; i <= max; i++) {
                fac[i] = fac[i - 1] * i % MOD;
                inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
                finv[i] = finv[i - 1] * inv[i] % MOD;
            }
        }

        static long com(int n, int k) {
            if (n < k) {
                return 0;
            }
            return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            List<Long> list = new ArrayList<>();

            comInit(n);

            for (int i = 0; i < n; i++) {
                list.add(in.nextLong());
            }

            list.sort(Comparator.naturalOrder());

            long ans = 0;
            for (int i = 0; i < list.size(); i++) {
                if (n - i - 1 >= k - 1) {
                    ans -= com(n - i - 1, k - 1) * list.get(i);
                }
                if (i >= k - 1) {
                    ans += com(i, k - 1) * list.get(i);
                }
                ans %= MOD;
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 65324
#include <iostream>
#include <math.h>

using namespace std;

int main(void){
    
    int n,k;
    cin>>n>>k;
    int i,x[100];
    for(i=0;i<n;++i) cin >> x[i];
    
    int ans=0;
    
    for(i=0;i<n;++i){
        ans+=min( abs(x[i]-k),x[i] );
    }
    
    cout << ans*2;
    
}


Measured memory_bytes: 256