akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main

{	
	public static void main(String args[]) throws IOException
	{
		FastScanner fs = new FastScanner();
			int n = fs.nextInt();
			System.out.println((1000-n%1000)%1000);
		
	}


}
class FastScanner
{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer str = new StringTokenizer("");
	
	String next() throws IOException
	{
		while(!str.hasMoreTokens())
			str = new StringTokenizer(br.readLine());
		
		return str.nextToken();
	}
	
	int nextInt() throws IOException
	{
		return Integer.parseInt(next());
	}
	
	float nextfloat() throws IOException
	{
		return Float.parseFloat(next());
	}
	
	double nextDouble() throws IOException
	{
		return Double.parseDouble(next());
	}
	long nextLong() throws IOException
	{
		return Long.parseLong(next());
	}
	int [] arrayIn(int n) throws IOException
	{
		int  arr[] = new int[n];
		arr[0] = 0;
		for(int i=1; i<n; i++)
		{
			arr[i] = nextInt();
		}
		return arr;
	}
}



	


Measured memory_bytes: 32796
N,M=map(int,input().split())
*A,=map(int,input().split())
from heapq import*
B=[]
for a in A:
    B.append(-a)
heapify(B)
for i in range(M):
    b=heappop(B)
    b=0--b//2
    heappush(B,b)
print(-sum(B))

Measured memory_bytes: 20060
# include <bits/stdc++.h>
# define int long long
# define endl "\n"
using namespace std;

void solve() {

	int x, y;
	cin >> x >> y;

	if ((4 * x - y) % 2 == 0 && 4 * x - y >= 0 && x - (4 * x - y) / 2 >= 0) {
		cout << "Yes" << endl;
		return;
	}
	cout << "No" << endl;
	return;
}

signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif

	// int t;
	// cin >> t;
	// while (t--)
	solve();

	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

///////////////////////////////////////////////////////////////////////////

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

	ll N;
	cin >> N;

	vector<pair<ll, ll>> H (N), T(N);

	rep (i, N) {
		H[i].first = 0;
		cin >> H[i].second;
	}

	for(ll i = 0; i < N - 1; ++i) {
		ll start = i;
		for(ll j = i+1; j < N; ++j){
			if (H[start].second < H[j].second) {
				break;
			}

			++H[i].first;
			++start;
		}
		i = start;
	}

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

	cout << H[N - 1].first << endl;
}



Measured memory_bytes: 3456
s=str(input())

def solve(s):
  if s.find("AA")!=-1:
    return False
  if s.find("KIH")==-1:
    return False
  t=s.replace('A','')
  return t=='KIHBR'

if solve(s):
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
//2019.8.24 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
const int N=500+10;
const int kcz=1e9+7;
namespace MAIN{
    int n;
    inline void add(res &x,const res &y){
        x+=y,x>=kcz?x-=kcz:1;
    }
    inline int mul(const res &x,const res &y){
        return int(1LL*x*y%kcz);
    }
    inline int Add(const res &x,const res &y){
        return x+y>=kcz?x+y-kcz:x+y;
    }
    int a[N][N];
    inline void solve(res x,res y,res tot){
        if(x==y)return;
        res p=(x+y+1)/2;
        for(res i=x;i<p;i++)
            for(res j=p;j<=y;j++)
                a[i][j]=tot;
        solve(x,p-1,tot+1),solve(p,y,tot+1);
    }
    inline void MAIN(){
        n=read(),solve(1,n,1);
        for(res i=1;i<=n;i++){
            for(res j=i+1;j<=n;j++)
                printf("%d ",a[i][j]);
            puts("");
        }
    }
}
int main(){
//    srand(19260817);
//    freopen("signin.in","r",stdin);
//    freopen("signin.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
#include <cstring>


int main() {
    int n, k; std::cin >> n >> k;
    std::vector<int> a(n + 1), b(n + 1);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    for (int t = 0; t < k; t++) {
        std::fill(b.begin(), b.end(), 0);
        for (int i = 0; i < n; i++) {
            b[std::max(0, i - a[i])]++;
            b[std::min(n - 1, i + a[i]) + 1]--;
        }
        for (int i = 0; i < n; i++) {
            b[i + 1] += b[i];
        }
        std::swap(a, b);
        bool check = true;
        for (int i = 0; i < n; i++) check &= a[i] == n;
        if (check) break;
    }
    for (int i = 0; i < n; i++) std::cout << a[i] << " \n"[i == n - 1];
    return 0;
}

Measured memory_bytes: 4844
#include <cstdio>
#include <algorithm>

typedef long long ll;

const int N = (int)1e5+5;

int n, num[3][N];
ll ans;

inline int re()
{
	int x = 0; char ch=getchar(); bool f = 0;
	for(; ch>'9'||ch<'0'; ch=getchar()) if(ch=='-') f = 1;
	for(; ch>='0'&&ch<='9'; ch=getchar()) x = (x<<1)+(x<<3)+ch-48;
	if(f) return -x;
	return x;
}

inline void prework(int k)
{
	for(int i=1;i<=n;++i) num[k][i] = re();
	std::sort(&num[k][1],&num[k][n]+1);
/*	num[k][0] = 1;
	for(int i=2;i<=n;++i)
		if(num[k][i]!=num[k][i-1])
			num[k][++num[k][0]] = num[k][i];*/
}

int main()
{
	n = re();
	for(int i=0;i<=2;++i) prework(i);

	for(int i=1,l=0,r=1;i<=n;++i)
	{
		while(l+1<=n&&num[0][l+1]<num[1][i]) ++l;
		while(r<=n&&num[2][r]<=num[1][i]) ++r;
		ans += (ll)l*(n-r+1);
	}

	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int N = cin.nextint % 500;
        int A = cin.nextint;
        if (N <= A)
        {
            WriteLine("Yes");
        }
        else
        {
            WriteLine("No");
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string n;
    cin >> n;
    int len = n.size();
    vector<ll> tmp(2);
    vector<vector<ll>> bill(len, tmp);
    bill[0][0] = n[len-1] - '0';
    bill[0][1] = 10 - (n[len-1] - '0');
    rep2(i, 1, len){
      int x = n[len - 1 - i] - '0';
      bill[i][0] = min(bill[i - 1][0] + x, bill[i-1][1] + x + 1);
      bill[i][1] = min(bill[i-1][0] + 10 - x, bill[i-1][1] + 9 - x);
    }
    cout << min(bill[len-1][0], bill[len-1][1]+1) << endl;
    return 0;
}

Measured memory_bytes: 58888
#include<bits/stdc++.h>
using namespace std;
string s[105];
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>s[i];
	for(int i=2;i<=n;i++)
		if(s[i][0]!=s[i-1][s[i-1].size()-1])
		{
			cout<<"No";
			return 0;
		}
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
			if(s[i]==s[j]) 
			{
				cout<<"No";
				return 0;
			}
	cout<<"Yes";
	return 0;	 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<queue>
#include<cstring>
#include<new>
#include<cmath>
#include<sstream>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define sz size()
#define em empty()
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define sett(a,b) memset(a,b,sizeof(a))
#define copy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
int n,a[202020];
map<int,int> m;
int main(){
	cin>>n;
	fo(i,0,n){
		cin>>a[i];
		m[a[i]]++;
	}
	sort(a,a+n);
	int ans=0;
	for(int i=n-1;i>=0;i--) if(m[a[i]]){
		m[a[i]]--;
		fo(j,1,32) if((1<<j)>a[i]){
			if(m[(1<<j)-a[i]]){
				ans++;
				m[(1<<j)-a[i]]--;
			}
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 19712
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
using namespace std;

int main()
{
	int n;
	cin >> n;
	char a[100];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool p = false, w = false, g = false, y = false;
	for (int i = 0; i < n; i++) {
		if (a[i] == 'P') {
			p = true;
		}
		else if (a[i] == 'W') {
			w = true;
		}
		else if (a[i] == 'G') {
			g = true;
		}
		else if (a[i] == 'Y') {
			y = true;
		}
	}
	int ans = 0;
	if (p) ans++;
	if (w) ans++;
	if (g) ans++;
	if (y) ans++;
	if (ans == 3) cout << "Three" << endl;
	else if (ans == 4) cout << "Four" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
string s,t;
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s >> t;
	t += s;
	cout << t << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> c(n);
  rep (i, n) cin >> a[i];
  rep (i, n) cin >> b[i];
  rep (i, n) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  ll sum = 0;
  for (int j = 0; j < n; ++j) {
    sum += (distance(a.begin(), lower_bound(a.begin(), a.end(), b[j]))) * (distance(upper_bound(c.begin(), c.end(), b[j]), c.end()));
  }
  cout << sum << '\n';
}



Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=200010;
int n,A[N],d[N];
ll f[N];
vector<int>G[N];
void ERROR(){puts("NO");exit(0);}
void dfs(int u,int ff)
{
	ll s=0,mx=0;
	for(int v:G[u])
	{
		if(v==ff)continue;
		dfs(v,u);s+=f[v];mx=max(mx,f[v]);
	}
	if(d[u]==1){f[u]=A[u];return;}
	f[u]=2ll*A[u]-s;
	if(f[u]<0||f[u]>A[u])ERROR();
	if(mx>A[u])ERROR();
}
int main()
{
	n=gi();
	for(int i=1;i<=n;i++)A[i]=gi();
	if(n==2)return puts(A[1]==A[2]?"YES":"NO"),0;
	for(int i=1;i<n;i++)
	{
		int u=gi(),v=gi();d[u]++;d[v]++;
		G[u].push_back(v);G[v].push_back(u);
	}
	int rt=1;
	for(int i=1;i<=n;i++)
		if(d[i]!=1){dfs(rt=i,i);break;}
	puts(f[rt]?"NO":"YES");
	return 0;
}


Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i)
#define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9;
const int MOD=1e9+7;
const int MAXN=1e6+7;

int ans=0;
int n,m,k,q;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>k;
    if(n==0){
        cout<<1<<"\n";
        return 0;
    }
    while(n>0){
        n/=k;
        ++ans;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
line = gets.chomp.split
N = line[0].to_i
M = line[1].to_i
Q = line[2].to_i

students = Array.new N do |i|
  i
end

array_a = gets.chomp.split
array_a.map! do |a|
  a.to_i
end
baton = 0

array_a.each do |a|
  if a.even?
  baton += a
  else
    baton -= a
  end

  size = students.size

  baton = (baton + size) % size
  students.delete_at baton
end

gets.chomp.split.each do |q|
  if students.include? q.to_i
    puts 1
  else
    puts 0
  end
end

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

int main() {

    string s;
    cin >> s;

    int value = 700;
    for (int i = 0; i < 3; ++i) {
        if (s.at(i) == 'o') {
            value += 100;
        }
    }

    cout << value << endl;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    ve<string> fi(h);
    rep(i,h) cin >> fi[i];
    ve<ve<bool>> ng(h,ve<bool>(w,false));
    rep(i,h){
        bool fl = true;
        rep(j,w){
            if(fi[i][j] == '#'){
                fl = false;
                break;
            }
        }
        if(fl){
            rep(j,w) ng[i][j] = true;
        }
    }
    rep(j,w){
        bool fl = true;
        rep(i,h){
            if(fi[i][j] == '#'){
                fl = false;
                break;
            }
        }
        if(fl){
            rep(i,h) ng[i][j] = true;
        }
    }
    rep(i,h){
        bool fl = false;
        rep(j,w){
            if(!ng[i][j]){
                cout << fi[i][j];
                fl = true;
            }
        }
        if(fl) cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>

int main(int argc, char *argv[]){
  int a, b;
  scanf("%d %d", &a, &b);
  if (a == b) {
    printf("a == b\n");
  } else if (a > b) {
    printf("a > b\n");
  } else {
    printf("a < b\n");
  }
  return 0;
}


Measured memory_bytes: 2088
import math
n, k = map(int, input().split())
 
step_list = list(map(int, input().split()))
 
dp = [math.inf] * (n)
dp[0] = 0
 
for i in range(1, n):
    min_from = max(0, i - k)
    dp[i] = min(dp[j] + abs(step_list[i] - step_list[j]) for j in range(min_from, i))
 
print(dp[n-1])

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

using namespace std;

int main() {
#ifdef _DEBUG
	freopen("_in" , "r", stdin );
	freopen("_out", "w", stdout);
#endif
	int n; cin >> n;
	cout << fixed << setprecision(10);
	if (n % 2 == 0) cout << "0.5000000000\n";
	else cout << (n / 2 + 1) / double(n) << '\n';
}


Measured memory_bytes: 3744
while(1):
    w, h = map(int, input().split())
    if not h+w:
        break
    h = 2*h-1
    w = 2*w-1
    m = [[1] * (w+2) for i in range(h+2)]
    for j in range(1, h+1):
        a = [int(i) for i in input().split()] #適宜変える
        if j%2:
            m[j][1:w+1] = [0] * w
            for k in range(w//2):
                m[j][2*k+2] = a[k]
        else:
            for k in range(w-w//2):
                m[j][2*k+1] = a[k]

    dx = [0, 0, -1, 1]
    dy = [-1, 1, 0, 0]

    s = [1, 1]
    d = [[-1 for k in range(w+2)] for j in range(h+2)]
    todo = [s]
    d[s[0]][s[1]] = 0
    while(todo != []):
        v = todo.pop(0)
        for k in range(4):
            if m[v[0]+dx[k]][v[1]+dy[k]] != 1 and d[v[0]+dx[k]][v[1]+dy[k]] == -1:
                d[v[0]+dx[k]][v[1]+dy[k]] = d[v[0]][v[1]]+1
                todo.append([v[0]+dx[k], v[1]+dy[k]])
    print(d[-2][-2]//2+1 if d[-2][-2] != -1 else 0)


Measured memory_bytes: 5672
from bisect import bisect_left

MOD = 10 ** 9 + 7

N, M = map(int, input().split())

a = list(map(int, input().split()))
a = sorted(a)
la = len(a)
sa = set(a)
lsa = len(sa)
if la != lsa:
    print(0)
    exit()

b = list(map(int, input().split()))
b = sorted(b)
lb = len(b)
sb = set(b)
lsb = len(sb)
if lb != lsb:
    print(0)
    exit()

ans = 1
ai = 0
bi = 0
k = N * M
d = 0
while k > 0:
    ai = bisect_left(a, k)
    bi = bisect_left(b, k)
    
    if ai == la or bi == lb:
        print(0)
        exit()
        
    if a[ai] == k:
        ta = 1
        if b[bi] == k:
            tb = 1
            t = ta * tb
        else:
            tb = (lb - bi)
            t = ta * tb
    else:
        ta = (la - ai)
        if b[bi] == k:
            tb = 1
            t = ta * tb
        else:
            tb = (lb - bi)
            t = ta * tb - d

    # print(ta, tb)
    ans *= t

    ans %= MOD
    # print(ans)
    k -= 1
    d += 1

print(ans)


Measured memory_bytes: 44396
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,number;
    cin>>N;
    int A[N],ans[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
        ans[A[i]-1]=i;
    }
    for(int i=0;i<N;i++){
        cout<<ans[i]+1<<" ";
    }
}


Measured memory_bytes: 1664
#include<stdio.h>
int main(){
  int i,a,b,d=0,n=0;
  scanf("%d %d",&a,&b);
  if(a>b){
    n=a;
    a=b;
    b=n;
  }
  d+=b;
  b--;
    if(a>b){
    n=a;
    a=b;
    b=n;
  }
  d+=b;
  printf("%d",d);
  return 0; 
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,ans=0;
void dfs(long long x){
  if(n<x) return;
  string s=to_string(x);
  if(count(s.begin(),s.end(),'3') && count(s.begin(),s.end(),'5') && count(s.begin(),s.end(),'7')){
    ans ++;
  }
  dfs(10*x+3);
  dfs(10*x+5);
  dfs(10*x+7);
  return;
}

int main(){
  cin >> n;
  dfs(0);
  cout << ans << endl;
}


Measured memory_bytes: 256
import itertools
n,m=map(int,input().split())
sw_list=[]
for i in range(m):
    num,*sw=map(int,input().split())
    sw_list.append(sw)
p_list=[int(i) for i in input().split()]

count=0

for pat in itertools.product(range(2), repeat=n):
    blnOK=True
    for i in range(m):
        sump=0
        for sw in sw_list[i]:
            if pat[sw-1]==1:
                sump+=1
        if sump%2!=p_list[i]:
            blnOK=False
    if blnOK:
        count+=1  

print(count)

Measured memory_bytes: 3064
def chess(h, w):
  if (h+w) % 2 == 0:
    return '#'
  return '.'

while True:
  H, W = map(int, input(). split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    for j in range(W):
      print(chess(i, j), end='')
    print()
  print()


Measured memory_bytes: 7008
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
int N;
string S;
 
string ans = "";
 
void solve(){
	ans = S;
	int numof_left = 0;//相方が存在しない(の数
	int numof_right = 0;//相方が存在しない)の数
	for(int i=0;i<N;i++){
		if(S[i]=='(') numof_left++;
		if(S[i]==')') numof_left = max(0,numof_left-1);
	}
	for(int i=N-1;i>=0;i--){
		if(S[i]==')') numof_right++;
		if(S[i]=='(') numof_right = max(0,numof_right-1);
	}
	for(int i=0;i<numof_left;i++) ans = ans + ")";
	for(int i=0;i<numof_right;i++) ans = "(" + ans;
}
 
int main(){
    cin >> N;
    cin >> S;
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int dice[2][6];
  int vector[3][4]={{0,2,5,3},{0,1,5,4},{1,2,4,3}};
  int i,j,k,l,m,c;
  for(i=0;i<2;i++)
  {
    for(j=0;j<6;j++)
    {
      scanf("%d",&dice[i][j]);
    }
  }
  for(i=0;i<2;i++)
  {
    for(j=0;j<4;j++)
    {
      int temp = dice[1][vector[i][0]];
      for(k=0;k<3;k++)
      {
	dice[1][vector[i][k]] = dice[1][vector[i][k+1]];
      }
      dice[1][vector[i][3]] = temp;
      c = 0;
      for(k=0;k<6;k++)
      {
	if(dice[0][k]==dice[1][k])c++;
      }
      if(c==6)break;
      for(m=0;m<3;m++){
	for(k=0;k<4;k++)
	{
	  int temp = dice[1][vector[m][0]];
	  for(l=0;l<3;l++)
	  {
	    dice[1][vector[m][l]] = dice[1][vector[m][l+1]];
	  }
	  dice[1][vector[m][3]] = temp;
	  c=0;
	  for(l=0;l<6;l++)
	  {
	    if(dice[0][l]==dice[1][l])c++;
	  }
	  if(c==6)break;
	}
	if(c==6)break;
      }
      if(c==6)break;
    }
    if(c==6)break;
  }
  if(c==6)printf("Yes\n");
  else printf("No\n");
  return 0;
}



Measured memory_bytes: 2104
x = list(map(int, input().split()))
x.sort()
n = (x[2] - x[1]) // 2
x[0] += 2 * n
x[1] += 2 * n
ans = 2 * n
n = (x[2] - x[0]) // 2
x[0] += 2 * n
ans += n
x.sort()
if x[1] == x[2]:
    if x[0] == x[1]:
        print(ans)
    else:
        print(ans + 2)
else:
    print(ans + 1)

Measured memory_bytes: 3064
package main

import "fmt"

var weather = [...]string{"Sunny", "Cloudy", "Rainy"}

func tomorrow(s string) string {
	for i, v := range weather {
		if s == v {
			return weather[(i+1)%3]
		}
	}
	return ""
}

func main() {
	var s string
	fmt.Scanln(&s)
	fmt.Println(tomorrow(s))
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h> 
#include <vector>
#include <algorithm>
#include <iomanip>      // std::setprecision
#include <map>


using namespace std;
namespace
{
	std::pair<int,int> get_key(int val)
	{
		int right = val % 10;
		while (val / 10 > 0)
		{
			val /= 10;
		}
		int left = val;
		return std::make_pair<int, int>(left + (right * 10), right + (left * 10));
	}
}
int main()
{
	map<int, int> pair_map;
	int N;
	int key, flipped_key;
	int solution = 0;
	std::cin >> N;
	for (int i = 1; i <= N; ++i)
	{
		std::tie(key, flipped_key) = get_key(i);
		if (key >= 10)
		{
			if (key == flipped_key)
				solution++; //symetric
			solution += pair_map[flipped_key] * 2; //by 2 because could swap positions
			pair_map[key]++;
		}
	}
	std::cout << solution;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let c: Vec<usize> = (0..n).map(|_| read()).collect();
    let mo = 10_usize.pow(9) + 7;

    let mut vec: Vec<usize> = vec![n; 200001];
    let mut dp: Vec<usize> = vec![0; n+1];
    dp[0] = 1;
    for i in 0..n {
        let po = c[i] - 1;
        if vec[po] < n && i > 0 && c[i-1] != c[i] {
            dp[i+1] = (dp[i] + dp[vec[po]+1]) % mo;
        } else {
            dp[i+1] = dp[i];
        }
        vec[po] = i;
    }
    println!("{}", dp[n]);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 10492
#include<stdio.h>

int main()
{
    int a,cal;
    scanf("%d",&a);
    if(a>=1 && a<=10)
    {
      cal=a+a*a+a*a*a;
      printf("%d\n",cal);
    }
    else
    {
      printf("Enter N between 1 to 10\n");
    }
    return 0;
}

Measured memory_bytes: 1652
#include <cstdio>
#include <algorithm>

using namespace std;
int A[1000000];
int main() {
    int N=0;
    scanf("%d", &N);
    for(int i=0; i<N; i++){
        scanf("%d", &A[i]);
        A[i]=A[i]-(i+1);
    }
    sort(A,A+N);
    int p=A[N/2];

    long long int sum=0;
    for(int i=0; i<N; i++){
        sum=sum + abs(A[i]-p);
    }
    printf("%lld",sum);
}

Measured memory_bytes: 896
n=int(input())
alist = list(map(int, input().split()))
ame=int(sum(alist))
#print(ame)
sabun=ame
for i in range(int((n-1)/2)):
    ban=i*2+1
    sabun-=(alist[ban]*2)

#print(sabun)
ylist=[]
ylist.append(sabun)
for i in range(n-1):
    ylist.append(alist[i]*2-ylist[i])

#print(ylist)
print(' '.join(map(str, ylist)))

Measured memory_bytes: 19144
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>
#include <cmath>

using namespace std;



int main() {
	int A, B;
	cin >> A >> B;
	cout << (A * B) << endl;
	return 0;
}

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

int main() {
  char a, b, c;
  cin >> a >> b >> c;
  if(b == 'S') {
    if(a == 'R' || c == 'R') cout << 1 << endl;
    else cout << 0 << endl;
  } else {
    if(a == 'R' && c == 'R') cout << 3 << endl;
    else if(a != 'R' && c != 'R') cout << 1 << endl;
    else cout << 2 << endl;
  }
}

Measured memory_bytes: 3592
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    int64_t A, B, K;
    std::cin >> A >> B >> K;

    for (int64_t i = A; i <= B; ++i) {
        if (i < A + K  || B - K < i) {
            std::cout << i << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	ll A, B;
	cin >> A >> B;

	ll cnt = 0;
	ll tA = 10001;
	for ( int i = 0; tA <= B; i++, tA += 10001 )
	{
		ll tB = tA;
		for ( int j = 0; ( tB <= B ) && ( j <= 9 ); j++, tB += 1010 )
		{
			ll tC = tB;
			for ( int k = 0; ( tC <= B ) && ( k <= 9 ); k++, tC += 100 )
			{
				if ( ( tC <= B ) && ( tC >= A ) )
				{
					++cnt;
				}
			}
		}
	}

	cout << cnt << endl;

	return ( 0 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int r=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R')r++;
  }
  int kotae=0;
  for(int i=r;i<n;i++){
    if(s[i]=='R')kotae++;
  }
  cout<<kotae<<endl;
  return 0;
}
  

Measured memory_bytes: 3716
S = str(input())
P = str(input())

is_ok = False

for i in range(len(S)):
    FLG = True
    for k in range(len(P)):
        if S[(i+k)%(len(S))] != P[k]:
            FLG = False
            break

    if FLG == True:
        is_ok = True
        break

if is_ok == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5564
#include <bits/stdc++.h>  
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define REP(i, a, n, op) for(int i=a; i<(int)(n); i ## op ## op)
#define cout(val) cout << val << endl

using namespace std;

bool filled(vector<int> &data){
    for(int n: data){
        if(n == -1){
            return false;
        }
    }
    return true;
}

int main(){
    int n, m, a, b;
    cin >> n >> m;
    vector<vector<int>> data(n, vector<int>());

    rep(i, m){
        cin >> a >> b;
        data[a - 1].push_back(b - 1);
        data[b - 1].push_back(a - 1);
    }
    vector<int> result(n, -1);
    vector<int> times(n, -1);
    queue<int> que;
    times.at(0) = 0;
    que.push(0);
    int f;
    while(!que.empty()){
        f = que.front();
        que.pop();

        for(int n : data[f]){
            if(result[n] != -1) continue;

            result[n] = f + 1;
            times[n] = times[f] + 1;
            que.push(n);
        }
    }

    if(filled(result)){
        cout("Yes");
        for(int i=1; i<n; i++){
            cout(result[i]);
        }
    }else{
        cout("No");
    }
}

Measured memory_bytes: 10636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;
const int MAX = 1e5 + 2;

ll modpow(ll a,ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

vector<vector<ll>> f(2, vector<ll>(MAX));

ll nCr(int n, int r) {
  if (r < 0) return 0;
  if (n < r) return 0;
  ll res = f[0][n];
  res = (res * f[1][r]) % mod;
  res = (res * f[1][n - r]) % mod;
  return res;
}


int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  rep(i, n + 1) cin >> a[i];

  vector<int> idx(n, -1);
  ll c;
  rep(i, n + 1) {
    if (idx[a[i] - 1] == -1) idx[a[i] - 1] = i;
    else {
      c = idx[a[i] - 1] + n - i;
      break;
    }
  }

  ll res = 1;
  rep(i, n + 2) {
    if (i) res = (res * i) % mod;
    f[0][i] = res;
  }
  res = modpow(res, mod - 2);
  repr(i, n + 1) {
    f[1][i] = res;
    res = (res * i) % mod;
  }

  FOR(i, 1, n + 2) {
    cout << (nCr(n + 1, i) + mod - nCr(c, i - 1)) % mod << endl;
  }

  


  
  return 0;
}


Measured memory_bytes: 3568
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

f k p = (k-1) `mod` p + 1

stime (h,m)
  | m<10 = show h ++ (':' : '0' : show m)
  | otherwise = show h ++ (':' : show m)

main = unwords . map (stime . head) . group . sort . concat . map (map (apply2 (,)) . splitRec 2 . tail) <$> replicateM 2 getInts >>= putStrLn


Measured memory_bytes: 4136
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = line[0];
            int B = line[1];
            Console.WriteLine(B % A == 0 ? A + B : B - A);
        }
    }
}

Measured memory_bytes: 13140
using System;
public class test
{
  public static void Main(){
    var input = Console.ReadLine();
    
    var count = 0;
    if(input.Length % 2 == 0)
    {
      for(var i = 0 ; i < input.Length/2 ; i++)
      { 
        if(input[i] != input[input.Length-1-i])
        {
          count++;
        }
      }
    }
    else
    {
      for(var i = 0 ; i < (input.Length)/2+1 ; i++)
      { 
        if(input[i] != input[input.Length-1-i])
        {
          count++;
        }
      }
    }
    Console.WriteLine(count);
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll A,B,C; cin >> A >> B >> C;

  if ((A==B && B!=C) || (B==C && A!=B) || (A==C && B!=C)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int x,y;
int main(){
	cin>>x>>y;
	cout<<(x*(x-1)/2)+(y*(y-1)/2)<<endl;
	return 0;
}


Measured memory_bytes: 256
a = [int(i) for i in input().split()] 
b = [int(i) for i in input().split()] 
c = [int(i) for i in input().split()] 

a.sort()
b.sort()
c.sort()

X = []

X.append(a[0])
X.append(a[1])
X.append(b[0])
X.append(b[1])
X.append(c[0])
X.append(c[1])

X.sort()
Y = set(X)
Z = set([1,2,3,4])
if Y != Z:
    print("NO")

w = [i for i in set(X) if X.count(i) > 1]

if w == a:
    print("YES")
elif w == b:
    print("YES")
elif w == c:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main()
{
  int n;
  cin>>n;
  int sum=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=n;j++)
        {
          for(int k=1;k<=n;k++)
          {
            sum=sum+gcd(i,gcd(j,k));
          }
        }
        }
        cout<<sum;
        }

Measured memory_bytes: 3600
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
  	int m = int.Parse(input[1]);
    List<long>[] switchList = new List<long>[m];
    for(int i = 0; i < m; i++)
    {
      switchList[i] = new List<long>();
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      for(int j = 0; j < nums[0]; j++)
      {
        switchList[i].Add(nums[j+1]);
      }
    }
    long[] aims = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
		long answer = 0;

    for(long i = 0; i < (Math.Pow(2,n)); i++)//２進数で全通り試す
      {
        long ii = i;
        int[] lightMemo = new int[m];
        for(int k = 0; k < m; k++) lightMemo[k] = 0;
        
        for(long j = 0; j < n; j++)//全ての桁
        {
          if(ii%2==0)
          {
          for(int k = 0; k < m; k++)
          {
            for(int l = 0; l < switchList[k].Count(); l++)
            {
              //Console.WriteLine(switchList[k][l]);
              if(switchList[k][l] == j+1)
              {
                lightMemo[k]++;
                lightMemo[k] %= 2;
                break;
              }
            }
          }
          }
          
          ii /= 2;
        }

        for(int k = 0; k < m; k++)
        {
          //Console.WriteLine(lightMemo[k]);
          if(lightMemo[k] != aims[k]) break;
          if(k == m-1) answer++;
        }
        
      }
    
		Console.WriteLine(answer);
	}
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const double PI = 3.14159265358979;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

void solve()
{
  ll n, k, l, r;
  cin >> n >> k;
  vector<P> input(k);
  vector<mint> dp(2 * n + 1, 0);
  dp[0] = 1;
  for(int i = 0; i < k; ++i)
  {
    cin >> l >> r;
    input[i] = P(l, r);
  }

  mint sum = 0;
  for(int i = 0; i < n; ++i)
  {
    sum += dp[i];
    for(int j = 0; j < k; ++j)
    {
      dp[i + input[j].first] += sum;
      dp[i + input[j].second + 1] -= sum;
      // for(const auto& v : dp) cout << v << " ";
      // cout << endl;
    }
  }

  /*
  vector<int> dist{1,3,4};
  for(int i = 0; i < n; ++i)
  for(const auto& d : dist)
  {
    if (i + d >= n) break;
    dp[i + d] += dp[i];
    // cout << i + d << " " << dp[i + d] << endl;
    for(const auto& v : dp) cout << v << " ";
    cout << endl;
  }
  //*/
  cout << dp[n - 1];
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 6364
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;



namespace Free
{
    class Node
    {
        public char value;
        public List<Node> child = new List<Node>();
        public Node(char _value)
        {
            value = _value;
        }
    }

    class Dic
    {
        Node root= new Node('x');

        public void Insert(string s)
        {
            s += "@";
            Node p = root;
            int len = s.Length;

            foreach(var c in s)
            {
                bool isFound = false;
                foreach(var child in p.child)
                {
                    if (child.value == c)
                    {
                        isFound = true;
                        p = child;
                    }
                }
                if (!isFound)
                {
                    Node node = new Node(c);
                    p.child.Add(node);
                    p = node;              
                }
            }
        }

        public bool Find(string s)
        {
            s += "@";
            Node p = root;
            foreach(var c in s)
            {
                bool isFound = false;

                foreach (var child in p.child)
                {
                    if (child.value == c)
                    {
                        isFound = true;
                        p = child;
                    }
                }
                if (!isFound)
                {
                    return false;
                }
            }
            return true;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Dic dic = new Dic();

            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string[] values = Console.ReadLine().Split(' ');
                if (values[0] == "insert") dic.Insert(values[1]);
                else
                {
                    if (dic.Find(values[1])) Console.WriteLine("yes");
                    else Console.WriteLine("no");
                }                
            }
        }
    }
}



Measured memory_bytes: 87400