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

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int[][] graph = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                graph[i][j] = scanner.nextInt();
            }
        }

        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (graph[i][j] > graph[i][k] + graph[k][j]) {
                        System.out.println(-1);
                        return;
                    }
                }
            }
        }

        final int[][] distances = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                boolean flag = true;
                for (int k = 0; k < n; k++) {
                    if (k == i || k == j) {
                        continue;
                    }
                    if (graph[i][j] == graph[i][k] + graph[k][j]) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    distances[i][j] = graph[i][j];
                }
            }
        }

        long sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                sum += distances[i][j];
            }
        }

        System.out.println(sum);
    }
}


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

#define ldb long double

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ldb l;
    cin >> l;
    
    ldb length = l / 3.0;
    l -= length;
    
    ldb breadth = l / 2.0;
    
    ldb height = l - breadth;
    
    ldb maxArea = length * breadth * height;
    
    cout << fixed << setprecision(12) << maxArea;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll a,ac,wa,tle,re;cin>>a;ac=0;wa=0;tle=0;re=0;
  string s[a];
  for(int i=0;i<a;i++){
    cin>>s[i];
    if(s[i]=="AC")ac++;
    else if(s[i]=="WA")wa++;
    else if(s[i]=="TLE")tle++;
    else if(s[i]=="RE")re++;
  }
  cout<<"AC x "<<ac<<endl<<"WA x "<<wa<<endl<<"TLE x "<<tle<<endl<<"RE x "<<re<<endl;
}


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

typedef long long int ll;

int main () {


	ll n;
	cin >> n;

	string s, t;
	cin >> s >> t;

	for (ll i=0 ; i<n ; i++) {
		cout << s[i] << t[i];
	}
	cout << endl;
}

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



int main(){
  int q,i,len;
  char x[MAX],y[MAX];

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s",x);
    scanf("%s",y);
    len = LCSLen(x,y);
    printf("%d\n",len);
  }
}


int LCSLen(char *x,char *y){
  int i,j,m,n,c[MAX][MAX];
  m=strlen(x);
  n=strlen(y);
  for(i=1;i<=m;i++){
    c[i][0]=0;
  }
  for(j=1;j<=n;j++){
    c[0][j]=0;
  }
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i-1]==y[j-1]){
	c[i][j]=c[i-1][j-1]+1;
      }else if(c[i-1][j]>=c[i][j-1]){
	c[i][j]=c[i-1][j];
      }else{
	c[i][j]=c[i][j-1];
      }
    }
  }
  return c[m][n];
}
  
  



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

int main(){
    long long A;
    string B;
    cin >> A >> B;
    long long B100 = (B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0');
    cout << A * B100 / 100 << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;

int main(){

  string s, t;
  cin >> s >> t;
  s += t;
  int x = stoi(s);
  for(int i=0; i<10000; i++){
    if( i*i == x ){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;


  return 0;
}





//


Measured memory_bytes: 256
#include <stdio.h>

int A[2000000],B[2000001];

int main(int argc, char *argv[]){
    int n,k=0;
    int i,j;
    
    int C[10000]={0};
    
    scanf("%d",&n);
    
    
    
    if(1>n || n>2000000)return 0;
    
    
  //  int B[n];
    
    /* incert */
    for(i=1;i<=n;i++){
        scanf("%d",&A[i]);
        if(A[i]>=k)k=A[i];
    }
    
    for(i=0;i<k;i++){
        C[i]=0;
    }
    
    for(j=1;j<=n;j++){
        C[A[j]]++;
    }
    
    for(i=1;i<=k;i++){
        C[i]=C[i]+C[i-1];
    }
    
    for(j=n;j>=1;j--){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    
    for(i=1;i<n;i++){
        printf("%d ",B[i]);
    }
    printf("%d\n",B[n]);
    /**/
    return 0;
}// End main

Measured memory_bytes: 16272
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  string s;
  cin>>s;
  int n=s.size();
  int ans=0;
  rep(i,n) {
    int c=0;
    repeat(j,i,n) {
      if(s[j]!='A'&&s[j]!='C'&&s[j]!='G'&&s[j]!='T')
        break;
      c++;
    }
    ans=max(ans,c);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// @author: hzy
//#pragma G++ optimize("O3")

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <list>
#include <forward_list>
#include <stack>
#include <unordered_set>
#include <vector>
#include <limits.h>

#define DISPLAY_A 0

using namespace std;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    unsigned long long A, ans = 0;
    char c1, c2, c3, c;
    cin >> A;
    cin >> c1;
    ans += A * (c1 - '0');
    cin >> c;
    cin >> c2;
    ans += A / 10 * (c2 - '0');
    cin >> c3;
    ans += A / 100 * (c3 - '0');
    ans += ((A % 10) * (c2 - '0') * 10 + (A % 100) * (c3 - '0')) / 100;
    cout << ans << endl;
    return 0;
}


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

ll nC2(ll n) {
    return n * (n-1) / 2;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> num(n+1, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        num[a[i]]++;
    }
    
/*     for (int i = 0; i < n+1; i++)
        cout << i << " : " << num[i] << endl; */
    
    ll total = 0;
    for (int i = 0; i < n+1; i++) {
        total += nC2(num[i]);
    }
/*     cout << "total : " << total << endl; */
    
    for (int k = 0; k < n; k++) {
        cout << (total - nC2(num[a[k]]) + nC2(num[a[k]]-1)) << endl;;        
    }
    
    
    return 0;
}


Measured memory_bytes: 4096
import sys
input = sys.stdin.readline
import math

N,K=map(int,input().split())
ANS=max(0,N-K+1)


#print(ANS)

for i in range(1,30):
    ANS+=max(0,(N-math.ceil(K*pow(1/2,i))+1))*pow(1/2,i)-max(0,(N-math.ceil(K*pow(1/2,i-1))+1))*pow(1/2,i)

print(ANS/N)

    

Measured memory_bytes: 3060
n,a,b=map(int,input().split())
s=input()

cnta=0
cntb=0

for i in range(n):
    if s[i]=="a":
        if cnta+cntb<a+b:
            print("Yes")
            cnta+=1
        else:
            print("No")
    elif s[i]=="b":
        if cntb<b and cnta+cntb<a+b:
            print("Yes")
            cntb+=1
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 53208
import collections
from collections import Counter
N= int(input())
S = []
for _ in range(N):
    S.append(input())
SS = Counter(S)    
Svalues = list(Counter(S).values())
SSS = max(Svalues)

keys = [k for k, v in SS.items() if v == SSS]
keys.sort()
X = len(keys)
for i in range (X):
   print(keys[i])


Measured memory_bytes: 53872
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int W = sc.nextInt();
		int w[] = new int[n];
		int v[] = new int[n];
		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		long DP[][] = new long[n][W + 1];
		DP[0][w[0]] = v[0];
		for (int i = 1; i < n; i++) {
			for (int j = 0; j <= W; j++) {
				DP[i][j] = DP[i - 1][j];
				if (j >= w[i]) DP[i][j] = Math.max(DP[i - 1][j - w[i]] + v[i],DP[i][j]);
			}
		}
		long Res = 0;
		for (int i = 0; i <= W; i++) Res = Math.max(Res, DP[n - 1][i]);
		System.out.print(Res);
	}

}


Measured memory_bytes: 127444
#include<bits/stdc++.h>
using namespace std;
const int N=4e5+10;
typedef long long ll;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,cnt[N];
char s[N];
ll ans=0;
int main() {
    scanf("%s",s+1),n=strlen(s+1);
    for(int i=1;i<=n;i++) ++cnt[s[i]-'a'];
    ans=1ll*n*(n+1)/2;
    for(int i=0;i<26;i++) ans-=1ll*cnt[i]*(cnt[i]+1)/2;
    printf("%lld\n",ans+1);
    return 0;
}


Measured memory_bytes: 384
s = input()

#YYMM
if (int(s[:2]) >= 13 or int(s[:2]) == 0) and (int(s[2:]) >= 1 and int(s[2:]) <= 12):
      print("YYMM")
elif (int(s[2:]) >= 1 and int(s[2:]) <= 12) and (int(s[:2]) >= 1 and int(s[:2]) <= 12):
      print("AMBIGUOUS")
elif (int(s[:2]) >= 1 and int(s[:2]) <= 12) and ((int(s[2:]) >= 13 or int(s[2:]) == 0)):
      print("MMYY")
else:
      print("NA")

Measured memory_bytes: 3064
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    // #define te    
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100100;

    void solve() {
        ll n;
        cin >> n;
        ll a[n], sum = 0;
        rep(i, n-1) cin >> a[i];
        sum = a[0] + a[n-2];
        rep(i, n-2) sum+=min(a[i], a[i+1]);
        cout << sum << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      // ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    } 

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

int main() {
  int N,M;
  cin >> N >> M;
  cout << (N*(N-1)/2) + (M*(M-1)/2) << endl;
  
}


// int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));
 
  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
   // }
  //}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <tuple>
#include <functional>

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define int long long
const int INF = 1e9;

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

signed main() {
	int w, h, sx, sy, gx, gy, n;
	cin >> sx >> sy >> gx >> gy;
	cin >> n;
	vector<int> vx(n), vy(n);
	rep(i, n) {
		cin >> vx[i] >> vy[i];
	}
	cin >> w >> h;
	map<int, map<int, int>> mp;
	map<int, int> s;
	for (int y = -h; y <= h; y++) {
		s[y] = INF;
	}
	{
		typedef pair<int, map<int, int>> pm;
		queue<pm> q;
		q.push(make_pair(0, s));
		while (q.size()) {
			auto x = q.front().first;
			auto t = q.front().second;
			q.pop();
			if (mp.count(x))continue;
			mp[x] = t;
			if (abs(x)+1 > w)continue;
			q.push(make_pair(x + 1, t));
			q.push(make_pair(x - 1, t));
		}
	}
	auto v = mp;
	rep(i, n) {
		v[vx[i]][vy[i]] = 1;
	}
	auto check = [&](int x, int y) {
		if (abs(x) <= w && abs(y) <= h) {
			if (v[x][y] == 1)return false;
			return true;
		}
		return false;
	};
	vector<map<int, map<int, int>>> me(6, mp);
	typedef tuple<int, int, int, int> T;
	priority_queue<T, vector<T>,greater<T>> q;
	q.push(T(0, sx, sy, 0));
	me[0][sx][sy] = 0;
	while (q.size()) {
		int x = get<1>(q.top()),
			y = get<2>(q.top()),
			t = get<3>(q.top());
		q.pop();
		int d = abs(x % 2);
		int nt = (t + 1) % 6;
		{
			int j = abs(x * y * t) % 6;
			int tx = x + dx[d][j], ty = y + dy[d][j];
			if (check(tx, ty) && me[nt][tx][ty] > me[t][x][y]) {
				me[nt][tx][ty] = me[t][x][y];
				q.push(T(me[nt][tx][ty], tx, ty, nt));
			}
		}
		rep(j, 7) {
			int tx = x + dx[d][j], ty = y + dy[d][j];
			if (check(tx, ty) && me[nt][tx][ty] > me[t][x][y] + 1) {
				me[nt][tx][ty] = me[t][x][y] + 1;
				q.push(T(me[nt][tx][ty], tx, ty, nt));
			}
		}
	}
	int ans = INF;
	rep(t, 6) {
		ans = min(ans, me[t][gx][gy]);
	}
	if (ans == INF)ans = -1;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 23688
#include<bits/stdc++.h>
#define ll long long int
#define mi map<int,int>
#define mcr map<char,int>
using namespace std;

int main()
{
    ll a, ans = 0;
    cin >> a;
    ll b = a % 1000;
    if(b > 0){
        cout << 1000 - b << endl;
    }else{
        cout << b << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int x[100];
int main()
{
	int num, k;
	scanf("%d%d", &num, &k);
	for (int i = 0; i < num; i++)scanf("%d", &x[i]);
	sort(x, x + num);
	reverse(x, x + num);
	int r = 0;
	for (int i = 0; i < k; i++)r += x[i];
	cout << r << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        string s1 = Console.ReadLine();
        string s2 = Console.ReadLine();
        string ans = "";
        for(int i = 0;i  < Math.Max(s1.Length,s2.Length);i++){
            if(i == s1.Length)break;
            ans += s1[i];
            if(i == s2.Length)break;
            ans += s2[i];
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
  int a,b,k,ans;
  cin>>a>>b>>k;
  if(k==1)cout<<__gcd(a,b)<<endl;
  else{
	  int cnt=0;
	    for(int i=min(a,b);i>=1;i--){
		   if(a%i==0 and b%i==0){
			     cnt++; 
			  }
			if(cnt==k){
				ans=i;
				break;
			}
		}
		cout<<ans<<endl;
	 }
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
A, B = map(int, input().split())
nums = list(map(int, input().split()))
lis = [0, 0, 0]

for i in range(N):
    P = nums[i]
    if P <= A:
        lis[0] += 1
    elif P <= B:
        lis[1] += 1
    else:
        lis[2] += 1
        
print(min(lis[0], lis[1], lis[2]))


Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, s: "List[int]", c: "List[int]"):
    restriction = [-1 for i in range(N)]
    for i in range(M):
        rC = s[i]-1
        rV = c[i]
        if restriction[rC] != -1 and restriction[rC] != rV:
            print("-1")
            return
        else:
            restriction[rC] = rV
    number = ""
    for i in range(N):
        if i == 0 and restriction[i] == 0:
            if N == 1:
                print("0")
                return
            print("-1")
            return
        if restriction[i] != -1:
            number+=str(restriction[i])
        else:
            number+="1" if i == 0 and N > 1 else "0"
    print(number)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{

  long long int x;
  cin>>x;
  long long int p=x/500;
  long long int ans=p*1000;
  p=x%500;
  p=p/5;
  ans=ans+p*5;
  cout<<ans;

}


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

L,R=map(int, input().split())

ans = 2 * (10**9)

for i in range(L,min(R+1,L+2019)):
    for j in range(i+1,min(R+1,L+2019)):
        ans = min(ans, ((i%2019)*(j%2019)%2019))

print(ans)

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

const double EPS = 1e-10;
bool EQ(double a, double b){return fabs(a-b) < EPS;}
typedef complex<double> Point;
#define X real()
#define Y imag()
namespace std {
  bool operator == (const Point &a, const Point &b) {
    return EQ(a.X, b.X) && EQ(a.Y, b.Y);
  }
  bool operator < (const Point &a, const Point &b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}
struct Segment {
  Point p1, p2;
  Segment(){};
  Segment(Point p1, Point p2) : p1(p1), p2(p2) {};
};
typedef Segment Line;
double dot(Point a, Point b){return real(conj(a) * b);}
double cross(Point a, Point b){return imag(conj(a) * b);}

Point project(Segment s, Point p) {
  double r = dot(p - s.p1, s.p2 - s.p1) / norm(s.p2 - s.p1);
  return s.p1 + (s.p2 - s.p1) * r;
}

Point reflect(Segment s, Point p) {
  return p + (project(s, p) - p) * 2.0;
}

int main() {
  int x1,y1,x2,y2,q,xp,yp;
  cin>>x1>>y1>>x2>>y2>>q;
  Line l(Point(x1,y1), Point(x2,y2));
  for(int i=0;i<q;++i){
    cin>>xp>>yp;
    Point p(xp,yp);
    printf("%.10f %.10f\n", reflect(l,p).X, reflect(l,p).Y);
  }

  return 0;
}



Measured memory_bytes: 3288
#include <stdio.h>

int main(void)
{
  int x, y;
  scanf("%d %d", &x, &y);
  int a[7] = { 1, 3, 5, 7, 8, 10, 12};
  int b[4] = { 4, 6, 9, 11};
  int count = 1;
  for (int i = 0; i < 7; i++) {
    for (int j = i + 1; j < 7; j++) {
      if (x == a[i] && y == a[j]) {
	puts("Yes");
	count = 0;
	break;
      }
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = i + 1; j < 4; j++) {
      if (x == b[i] && y == b[j]) {
	puts("Yes");
	count = 0;
	break;
      } 
    }
  }
  if (count)
    puts("No");
}


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

class Program
{

    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var A = new long[N];
        var inputs = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++)
        {
            A[i] = long.Parse(inputs[i]);
        }

        var L = new long[N + 1];
        L[0] = 0;
        for (int i = 0; i < A.Length - 1; i++)
        {
            L[i + 1] = Gcd(L[i], A[i]);
        }

        var R = new long[N + 1];
        R[N] = A[N - 1];
        for (int i = A.Length; i >= 1; i--)
        {
            R[i - 1] = Gcd(R[i], A[i - 1]);
        }

        long max = 0;
        for (int i = 0; i < N; i++)
        {
            long m;
            if (i == 0)
            {
                m = R[i + 1];
            }
            else if (i == N - 1)
            {
                m = L[i];
            }
            else
            {
                m = Gcd(L[i], R[i + 1]);
            }

            max = Math.Max(max, m);
        }

        Console.WriteLine(max);
    }

    /**
     * ユークリッド互除法(最大公約数)
     * <see cref="https://qiita.com/gushwell/items/e9614b4ac2bea3fc6486"/>
     */
    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
}



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

using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

int main() {
    int n;
    cin >> n;
    while (true) {
        if (IsPrime(n)) break;
        n++;
    }
    cout << n << endl;
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int max = 0;
    int temp = 0;
    for(auto a:s){
        if(a=='R'){
            temp++;
            if(temp>max) max=temp;
        }
        if(a=='S'){
            temp=0;
        }
    }
    cout << max; 
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <cstdint>

using namespace std;

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

	int32_t n, a, b;
	cin >> n >> a >> b;

	string s;
	cin >> s;

	int32_t num_passed{ a + b };
	for (auto i{ 0 }; i < n; ++i) {
		if (s[i] == 'a' && num_passed > 0) {
			cout << "Yes\n" ;
			--num_passed;
		}else if (s[i] == 'b' && num_passed > 0 && b > 0) {
			cout << "Yes\n";
			--num_passed;
			--b;
		}else {
			cout << "No\n";
		}
	}
}


Measured memory_bytes: 848
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MD = 1e9 + 7;
map<pair<ll, ll>, int> ma;
set<pair<ll, ll>> vis;
int quick_pow(int x, int y) {
    int ans = 1;
    while(y) {
        if(y & 1) ans = 1LL * ans * x % MD;
        y >>= 1;
        x = 1LL * x * x % MD;
    }
    return ans;
}
int main() {
    int n, s = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        ll a, b;
        scanf("%lld%lld", &a, &b);
        ll d = __gcd(a, b);
        if(d == 0) {
            s++;
            continue;
        }
        a /= d, b /= d;
        if(a < 0) a = -a, b = -b;
        ma[{a, b}]++;
    }
    ll ans = 1;
    for(auto it : ma) {
        if(vis.find(it.first) != vis.end()) continue;
        ll a = it.first.first, b = it.first.second;
        ll d = quick_pow(2, ma[{a, b}]);
        b = -b;
        if(b < 0) a = -a, b = -b;
        if(ma.count({b, a})) {
            d = (d + quick_pow(2, ma[{b, a}]) - 1) % MD;
            vis.insert({b, a});
        }
        ans = ans * d % MD;
    }
    ans = (ans - 1 + s + MD) % MD;
    printf("%lld\n", ans);
    return 0;
}

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

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

    for (int i = 1; i <= 9; i++)
        if (n % i == 0 && n / i <= 9)
        {
            cout << "Yes" << endl;
            return 0;
        }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a*b%2==0) {
            System.out.println("Even");
        }
        else {
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

ll n;

template<typename T>
vector<T> divisor_list(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if (x%i==0) {
            res.push_back(i);
            if (i*i!=x) res.push_back(x/i);
        }
    }
    return res;
}


void solve(){
  cin >> n;
  vector<ll> div=divisor_list(n);
  vector<ll> div2=divisor_list(n-1);
  ll ans=div2.size()-1;
  //cout << ans << endl;
  for(ll k:div){
    if(k==1) continue;
    ll m=n;
    while(m%k==0){
      m/=k;
    }
    //cout << k << " " << m << endl;
    ans+=((m-(ll)1)%k==0);
  }
  cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 384
N = gets.strip.to_i
TREE = readlines.map {|line| line.split(' ').map(&:to_i)}

graph = Array.new(N+1){ [] }
TREE.each do |data|
  graph[data[0]] << [data[0], data[1], data[2]]
  graph[data[1]] << [data[1], data[0], data[2]]
end

color = Array.new(N+1)
q = [[1, 1, 0]]
until q.empty?
  from, to, weight = q.shift
  color[to] = weight
  graph[to].each do |(f, t, w)|
    next if t == from
    next if color[t]
    q << [f, t, w + weight]
  end
end

color[1..N].each do |weight|
  puts weight.odd? ? 1 : 0
end


Measured memory_bytes: 37996
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

ll d = 1e9 + 7;

int main(void){
    ll n; cin >> n;
    vector <ll> as;
    REP(i, n){
        ll a; cin >> a;
        as.push_back(a);
    }
    ll ans = 0;
    ll bai = 1;
    REP(i, 61){
        ll ones = 0;
        REP(j, n){
            ones += as[j] % 2;
            as[j] = as[j] / 2;
        }
        ll kake = ones * (n - ones) % d;
        ans += (bai * kake) % d;
        ans %= d;
        bai *= 2;
        bai %= d;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6384
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define sqr(x) (x) * (x)
#define cube(x) (z) * (z) * (x)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define itn int

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);
int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}
template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}

signed main() {
  int ans = 0;
  string S;
  cin >> S;
  int all = bpm(2, (signed)S.size() - 1);
  rep(i, S.size()) {
    int num_of_plus = S.size() - 1 - i;
    string S_i      = "";
    S_i += S[i];
    rep(j, num_of_plus + 1) {
      if (j == num_of_plus) {
        ans += stoi(S_i) * bpm(10, j) * bpm(2, i);
      } else {
        ans += stoi(S_i) * bpm(10, j) * (all / min(all, bpm(2, j + 1)));
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>

#define mod (1000000007)
using namespace std;
int main(void){
    long long n;
    cin >> n;
    
    long long a[n];
    long long sum[n+1];
    for(long long i = 0; i < n; i++){
        cin >> a[i];
        sum[i+1] = sum[i] + a[i];
    }
    
    long long ans = 0;
    for(long long i = 0; i < n; i++){
        long long tmp = (sum[n] - sum[i+1]) % mod;
        ans += a[i] * tmp;
        ans %= mod;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 6296
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val length = StdIn.readInt
    val array = StdIn.readLine().split(" ").map(_.toInt)

    val result = bubbleSort(array)
    println(array.mkString(" "))
    println(result)
  }

  def bubbleSort(array: Array[Int]): Int = {
    var sw = 0
    var flag = true
    var count = 1
    while (flag) {
      flag = false
      for (j <- array.length - 1 to count by -1) {
        if (array(j) < array(j - 1)) {
          val a = array(j)
          array(j) = array(j - 1)
          array(j - 1) = a
          flag = true
          sw += 1
        }
      }
      count += 1
    }
    sw
  }
}

Measured memory_bytes: 44028
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;

int main() {
    int n;
    cin >> n;
    int ans = n*800;
    while(n >=15) {
        n-=15;
        ans-=200;
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    vector<ll> a(n + 1);

    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j += i)a[j]++;
    }
    ll sum = 0;
    for(int i = 1; i <= n; i++)sum += i * a[i];
    cout << sum << endl; 
}

Measured memory_bytes: 81396
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  string s;
  cin >> s;
  if (s.size() == 2) cout << s << endl;
  else {
    cout << s[2] << s[1] << s[0] << endl;
  }

  return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Serval vs Monster
            var line = ReadLine();
            int H = line[0];
            int A = line[1];

            int count = 1;

            while (A * count < H)
            {
                count++;
            }

            Console.WriteLine(count);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    string s; cin>>s;
    ll res=0, x=0;
    rep(i,n){
        if(s[i]=='I') x++;
        else x--;
        chmax(res, x);
    }
    cout<<res<<endl;
    return 0;
}

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

int n;

int main(){
	cin>>n;
	int a=0;
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		if(A%2==1) a++;
	}
	if(a%2==1) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	string s;
	string s1, s2, s3;

	cin >> s;
	s.erase(s.begin() + 5);
	s.erase(s.begin() + 12);
	s.insert(s.begin() + 5,' ');
	s.insert(s.begin() + 13,' ');
	cout << s << endl;

	








	return 0;
}

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

typedef long long ll;

void solve() {
    string s; cin >> s;
    ll ans = 0; int sz = (int)s.size();
    vector<int> v(2019);
    for (int i = 0; i < sz; i++) {
        int d = s[i] - '0';
        vector<int> w(2019);
        for (int r = 0; r < 2019; r++) {
            int nr = (r * 10 + d) % 2019;
            w[nr] += v[r];
        }
        v = w; v[d]++;
        ans += v[0];
    }
    cout << ans << '\n';
}

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

    solve();
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;



int main() {
  int n;
  string s;
  cin >> n >> s;
  s+=s.at(0);
  rep(j,4){
    vector<int> a(n);
    a.at(0)=j/2;
    a.at(1)=j%2;
    int c;
    if (s.at(1)=='o') {c=(a.at(0)+a.at(1))%2;}
    else c=(a.at(0)+1-a.at(1))%2;
  for (int i=2;i<n-1;i++){
    a.at(i)=c;
    if (s.at(i)=='o') {c=(a.at(i-1)+a.at(i))%2;}
    else c=(a.at(i-1)+1-a.at(i))%2;
  }
  a.at(n-1)=c;
  if (s.at(n-1)=='o') {
    if ((a.at(n-2)+a.at(n-1))%2!=a.at(0)) continue;
  }
  else if ((a.at(n-2)+1-a.at(n-1))%2!=a.at(0)) continue;
  if (s.at(0)=='o') {
    if ((a.at(n-1)+a.at(0))%2!=a.at(1)) continue;
  }
  else if ((a.at(n-1)+1-a.at(0))%2!=a.at(1)) continue;
  string u;
  rep(i,n){
    if (a.at(i)==0) u.push_back('S');
    else u.push_back('W');
  }
  cout << u << endl;
  return 0;
  }
  cout << -1 << endl;
  }

Measured memory_bytes: 1052
#include<iostream>

using namespace std;

int dp[3];
int arr[3];

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

	int n; cin >> n;

	while(n--) {
		int a,b,c; cin >> a >> b >> c;

		arr[0] = max(dp[0],max(dp[1],dp[2]) + a);
		arr[1] = max(dp[1],max(dp[0],dp[2]) + b);
		arr[2] = max(dp[2],max(dp[0],dp[1]) + c);
		
		dp[0] = arr[0];
		dp[1] = arr[1];
		dp[2] = arr[2];
		
	}

	cout << max(dp[0],max(dp[1],dp[2])) << '\n';

	return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	ll n,x,m;cin>>n>>x>>m;
	map<ll,int>mp;
	map<ll,ll>mp_sum;
	ll a=x;
	int cnt=0;
	ll sum=0;
	while(1){
		cnt++;
		mp[a]=cnt;
		mp_sum[a]=sum;
		sum+=a;
		if(cnt==n){
			cout<<sum<<endl;
			return 0;
		}
		a=(a*a)%m;
		if(mp.count(a)){
			int s=(cnt+1)-mp[a];
			ll ans=mp_sum[a];
			n-=mp[a]-1;
			ll d=sum-mp_sum[a];
			ans+=(n/s)*d;
			n%=s;
			rep(i,n){
				ans+=a;
				a=(a*a)%m;
			}
			cout<<ans<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 9812
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int k = sc.nextInt();
    
    List<Integer> healths = new ArrayList<Integer>();
    for (int i=0; i<n; i++) {
      int h = sc.nextInt();
      healths.add(h);
    }
    
    Collections.sort(healths, Collections.reverseOrder());
    long result = 0;
    for (Integer health : healths) {
      if (k>0) {
        k --;
      }
      else {
        result += health;
      }
    }
    
    System.out.println(result);
    
  }
}

Measured memory_bytes: 94132
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k,max,other;
	cin>>a>>b>>c>>k;
	if(a>=b)
		if(a>=c)
		max=a;
		else
		max=c;
		else if(b>=a)
				if(b>=c)
				max=b;
				else
				max=c;
	other=a+b+c-max;
	for(int i=0;i<k;i++){
		max=max*2;
	}
	cout<<max+other;
	return 0;
}

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

using namespace std;

int main()
{
    int n,a[1010];
    cin >> n;
    for(int i = 0;i<n;i++)  cin >> a[i];
    bool ok = true;
    for(int i = 0;i<n;i++)  if(!(a[i] & 1))  ok&=(a[i] % 3 == 0 || a[i] % 5 == 0);
    cout << (ok ? "APPROVED" : "DENIED");
    return 0;
}



Measured memory_bytes: 256
//Bouquet

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int mod = 1000000007;

//n=元の数,p=乗数,m=mod
ll repsqr(ll n,ll p,ll m){
    if(p==0)return 1;
    if(p%2==0){
        ll t=repsqr(n,p/2,m);
        return t*t%m;
    }
    return n*repsqr(n,p-1,m)%m;
}

signed main (){
    int n,a,b;cin>>n>>a>>b;
    int ans = repsqr(2,n,mod)-1;
    int ax=1,bx=1,ay=1,by=1;
    rep(i,0,a){
        ax=ax*(n-i)%mod;
        ay=ay*(i+1)%mod;
    }
    rep(i,0,b){
        bx=bx*(n-i)%mod;
        by=by*(i+1)%mod;
    }
    ans=(ans-ax*repsqr(ay,mod-2,mod)-bx*repsqr(by,mod-2,mod))%mod;
    if(ans<0)ans=mod+ans;
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
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; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int a,b;cin>>a>>b;
    int ans=0;
    for(int i=a;i<=b;i++){
        string temp=to_string(i);
        if(temp[0]==temp.back()&&temp[1]==temp[temp.size()-2])
            ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
const ll maxSum = 50*50+1;
int main() {
    int N;
  cin>>N;
  int V[N];
  int somma = 0;
  for(int i = 0;i<N;i++)
  {
    cin>>V[i];
    somma+=V[i];
  }
  if(somma%10 != 0) cout<<somma<< endl;
  else
  {
    sort(V,V+N);
    int conta = 0;
    for(int i = 0;i<N;i++)
    {
      if(V[i] %10 != 0) {somma-=V[i];conta++;break;}
    }
    if(conta == 0) cout<<0;
    else cout<<somma<< endl;
  }
 

    return 0;
}

Measured memory_bytes: 3524
# -*- coding: utf-8 -*-
import sys
from collections import deque

SL = list(input())
Qn = int(input())


S = deque()
for s in SL:
    S.append(s)
    
even = 1
for i in range(Qn):
    t = list(map(str,input().split()))
    if len(t)==1:
        even = even^1
    else:
        if t[1]=='1':
            if even:
                S.appendleft(t[2])
            else:
                S.append(t[2])
        else:
            if even:
                S.append(t[2])
            else:
                S.appendleft(t[2])

if even == 0:
    S = reversed(S)

print(''.join(S))

Measured memory_bytes: 9716
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n):
    print(*a)
    t = a[i]
    j = i - 1
    while j >= 0 and a[j] > t:
        a[j + 1] = a[j]
        j -= 1
    a[j + 1] = t
print(*a)

Measured memory_bytes: 8092
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N, M;
    cin >> N >> M;

    vvi s;
    int k;
    REP(i,M){
        cin >> k;
        vi tmp_vec(k);
        REP(j,k) cin >> tmp_vec[j];
        s.emplace_back(tmp_vec);
    }

    vi p(M);
    REP(i,M) cin >> p[i];

    int n = N;
    ll ans = 0;

    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit)
    {
        /* bit で表される集合の処理を書く */


        /* きちんとできていることを確認してみる */
        // bit の表す集合を求める
        vector<bool> S(N,false);
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S[i] = true;
            }
        }

        int num_on; 
        int num_on_p = 0; 
        //全電球       
        REP(i,M){
            //電球につながるスイッチ
            num_on = 0;
            for (auto a : s[i]) if (S[a-1]) num_on++;
            if (num_on%2 == p[i]%2) num_on_p++;
        }
        if (num_on_p == M) ans ++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_Beginner_Contest_125_B_Resale
{
    class Program
    {
        static void Main(string[] args)
        {
            string StringNumberOfTimes = string.Empty;
            int numberOfTimes = 0;
            List<string> ReadData = new List<string>();
            StringNumberOfTimes = Console.ReadLine();
            numberOfTimes = int.Parse(StringNumberOfTimes);

            for (int i = 0; i < 2; i++)
            {
                ReadData.Add(Console.ReadLine());
            }

            string[] splitJewelryValue = new string[numberOfTimes];
            string[] splitJewelryCost = new string[numberOfTimes];
            int[] jewelryValue = new int[numberOfTimes];
            int[] jewelryCost = new int[numberOfTimes];

            splitJewelryValue = ReadData[0].Split(' ');
            for (int j = 0; j < numberOfTimes; j++)
            {
                jewelryValue[j] = int.Parse(splitJewelryValue[j]);
            }

            splitJewelryCost = ReadData[1].Split(' ');
            for (int k = 0; k < numberOfTimes; k++)
            {
                jewelryCost[k] = int.Parse(splitJewelryCost[k]);
            }

            int totalJewelryValue = 0;
            int[] difference = new int[numberOfTimes];
            for (int l = 0; l < numberOfTimes; l++)
            {
                difference[l] = jewelryValue[l] - jewelryCost[l];
                if(difference[l] > 0)
                {
                    totalJewelryValue += difference[l];
                }
            }
            Console.WriteLine(totalJewelryValue);
        }
    }
}

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

int main() {
    int x , y;
    int g1[8] = {1,3,5,7,8,10,12};
    int g2[5] = {4,6,9,11};
    int g3[2] = {2};
    cin >> x >> y;
    int cnt = 0;
    for(int i = 0 ; i < 8 ; i++) {
        if(x == g1[i]) cnt++;
        if(y == g1[i]) cnt++;
    }
    if(cnt == 2) {cout << "Yes" << endl;return 0;}
    cnt = 0;
    for(int i = 0 ; i < 4 ; i++) {
        if(x == g2[i]) cnt++;
        if(y == g2[i]) cnt++;
    }
    if(cnt == 2) {cout << "Yes" << endl;return 0;}
    cnt = 0;
    for(int i = 0 ; i < 1 ; i++) {
        if(x == g3[i]) cnt++;
        if(y == g3[i]) cnt++;
    }
    if(cnt == 2) {cout << "Yes" << endl;return 0;}
    cout << "No" << endl;return 0;
}


Measured memory_bytes: 256