akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int sign(int A){
	return (A>0)-(A<0);
}
int main(){
	int N,A[100001];
	int ans=1;
	int jotai=0;
	int lastnum;
	scan(N);
	rep(i,N){
		scan(A[i]);
		if(i!=0){
			if(jotai*sign(A[i]-lastnum)>=0){
				jotai=(abs(jotai)>abs(sign(A[i]-lastnum)) ? jotai : sign(A[i]-lastnum));
			}
			else{
				ans++;
				jotai=0;
			}
		}
		lastnum=A[i];
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 640
import math
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
kai=[math.factorial(i) for i in range(n)]
pl=[i for i in range (1,n+1)]
ql=[i for i in range (1,n+1)]
pc=0
qc=0
countp=0
countq=countp
for i in range(n):
    if p[i]!=pl[0]:
        countp+=pl.index(p[i])*kai[n-i-1]
        del pl[pl.index(p[i])]
    else:
        del pl[0]
for i in range(n):
    if q[i]!=ql[0]:
        countq+=ql.index(q[i])*kai[n-i-1]
        del ql[ql.index(q[i])]
    else:
        del ql[0]
print(abs(countp-countq))

Measured memory_bytes: 3064
/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/
#include<bits/stdc++.h>
#define mod 1000000007
#define modc 998244353
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define deb(x) cout << #x << " " << x << endl;
#define deb2(x,y) cout << #x << " " << x << " " <<  #y << " " << y << endl
#define deb3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " "  << z << endl;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define nl cout << "\n"
using namespace std;
template <class T>
string to_binary(T n)
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void print(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
void solve()
{
	int i,j;
	ll sum = 0,prod = 1;
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	if(k <= a)
	{
		cout << k << endl;
		return;
	}
	k-=a;
	sum+=a;
	if(k <= b)
	{
		cout << sum << endl;
		return;
	}
	k-=b;
	if(k == c)
	{
		cout << sum-c << endl;
		return;
	}
	cout << sum-k << endl;
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


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

#define N 100

int main() {
	static char s[N + 1];
	int n;
	
	scanf("%s", s);
	n = strlen(s);
	printf("%c%d%c\n", s[0], n - 2, s[n - 1]);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

int main(){

    int a,b;
    cin >> a >> b;

    cout << (a - 1) * (b - 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int len=t.length();
	int len2=s.length();
	int change=len;
	for(int i=0;i<=len2-len;i++){
		string substr=s.substr(i,len);
		int count=0;
		for(int i=0;i<len;i++){
			if(t[i]==substr[i]) count++;
		}
		change=min(change,len-count);
	}
	cout<<change<<'\n';
    return 0;
}



Measured memory_bytes: 3628
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define LL long long
#define PII pair<int, int>
#define Pque priority_queue 
#define loop(c, a, b) for(int c = a; c <= b; ++c)
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const double EPS = 1e-8;

char s[maxn];


int main(){
		scanf("%s", s + 1);
		if(s[2] == 'B') s[2] = 'R';
		else s[2] = 'B';
		printf("%s\n", s + 1);
	return 0;
}

Measured memory_bytes: 3716
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	k := nextInt()
	n := nextInt()

	first := nextInt()
	prev := first
	max := 0

	for i := 1; i < n; i++ {
		position := nextInt()
		temp := position - prev
		if max < temp {
			max = temp
		}

		prev = position
	}

	last := k - prev + first
	if max < last {
		max = last
	}

	fmt.Println(k - max)

}


Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		String s=sc.next();
		int sento=Integer.parseInt(s.substring(0, 2));
		int usiro=Integer.parseInt(s.substring(2, 4));
		//pl(sento+" "+usiro);
		if(sento==0){
			//YYMMのとき
			if(usiro>0 &&usiro<=12) {
				pl("YYMM");
			}
			else {
				pl("NA");
			}
		}
		else if(sento>0 && sento<=12) {
			if(usiro>0 && usiro<=12) {
				pl("AMBIGUOUS");
			}
			else {
				pl("MMYY");
			}
		}
		else {
			if(usiro>0 &&  usiro<=12) {
				pl("YYMM");
			}
			else {
				pl("NA");
			}
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r,a[2],b[2],s=LLONG_MIN;
    cin>>a[0]>>a[1]>>b[0]>>b[1];
    for(i=0;i<2;i++)
    {
        for(j=0;j<2;j++)
        {
            s=max(s,a[i]*b[j]);
        }
    }
    cout<<s<<"\n";
    return 0;
}



Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long lli;

lli n;

int main() {
  while(cin >> n && n) {
    vector<lli> v;
    for(lli x = 1; x < n; ++x) {
      v.push_back(x*x%n);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    vector<lli> ans(n, 0LL);
    for(int i = 0; i < v.size(); ++i) {
      for(int j = 0; j < v.size(); ++j) {
        if(i == j) continue;
        lli x = v[i] - v[j];
        if(x < 0) x += n;
        if(x > (n-1)/2) x = n - x;
        ++ans[x];
      }
    }
    for(int i = 1; i <= (n-1)/2; ++i) {
      cout << ans[i] << endl;
    }
  }
  return 0;
}

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

ll val[200010];
ll res[200010];

vector<vector<ll>> edge;

void saiki(int now, int v){
    res[now] = v + val[now];
    for (auto e : edge[now]) {
        saiki(e, v + val[now]);
    }
}

int main() {
    ll n,q;
    std::cin >> n>>q;
    for (int i = 0; i < n; i++) {
        val[i] = 0;
        res[i] = 0;
        edge.push_back({});
    }
    
    for (int i = 0; i < n-1; i++) {
        ll a,b;
        std::cin >> a>>b;
        a--;b--;
        edge[a].push_back(b);
    }
    for (int i = 0; i < q; i++) {
        ll p,x;
        std::cin >> p>>x;
        p--;
        val[p] += x;
    }
    saiki(0,0);
    for (int i = 0; i < n-1; i++) {
        std::cout << res[i]<<" ";
    }
    std::cout << res[n-1] << std::endl;
}


Measured memory_bytes: 26860
while True: 
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    else:
        s=0
    
        for i in range(1,n+1):
            for j in range(i+1,n+1):
                for k in range(j+1,n+1):
                    if i+j+k==x:
                        s+=1
    print(s)


Measured memory_bytes: 5596
import functools
import math

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


a  = sorted(inl())
print(a[0] + a[1] +a[2]*10)


Measured memory_bytes: 3572
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}
int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}
/*
 
 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
int a=0, b=0, c = 0;

int main(void) {
	Rapid;
	int n;
	cin >> n;
	vint h(n);
	vcin(h, n);
	int cnt = 0;
	int ans = 0;

	rep(i, n) {
		if (i != 0) {
			if (h[i - 1] >= h[i])cnt++;
			else cnt = 0;
		}
		ans = max(cnt, ans);
	}
	cout << ans << rt;

	please AC;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; s[i] != '\0'; i++){
        //cout << "i =================== " << i << endl;
        if(i > -1 && s[i] != s[i + 1] && s[i] != '\0' && s[i + 1] != '\0'){
            ans += 2;
            s.erase(s.begin() + i, s.begin() + i + 2);
            //cout << "i = " << i << ", ans = " << ans << endl;
            //cout << s << endl << endl;
            i -= 2;
        }/*else if(i > 0 && s[i - 1] != s[i]){
            ans += 2;
            s.erase(s.begin() + i - 1, s.begin() + i + 1);
            cout << "i - 1 = " << i - 1 << ", ans = " << ans << endl;
            cout << s << endl << endl;
            i -= 2;
        }*/
        if(i == -2) i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 101
char map[maxn][maxn];
int n,m,h[maxn],l[maxn],num[maxn][maxn];

signed main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%s",map[i]+1);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(map[i][j]=='.')  num[i][j]=0;
            if(map[i][j]=='#')  num[i][j]=1;
        }
    }
    for(int i=1;i<=n;i++){
        int bol=0;
        for(int j=1;j<=m;j++){
            if(num[i][j]==1){
                bol=1;break;
            }
        }
        if(bol==0)
            h[i]=1;
    }

    for(int i=1;i<=m;i++){
        int bol=0;
        for(int j=1;j<=n;j++){
            if(num[j][i]==1){
                bol=1;break;
            }
        }
        if(bol==0)
            l[i]=1;
    }

    for(int i=1;i<=n;i++){
        if(h[i])    continue;
        for(int j=1;j<=m;j++){
            if(l[j])    continue;
            if(num[i][j]==0)    printf(".");
            else                printf("#");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(true) {
            String s = scan.nextLine();
            if(s.equals("-"))break;
            int n = scan.nextInt();
            for (int i = 0; i < n; i++) {
                int h = scan.nextInt();
                //System.out.println(s);
                s = s.substring(h, s.length()) + s.substring(0, h);
                //System.out.println(s);
            }
            System.out.println(s);
            scan.nextLine();
        }
    }
}



Measured memory_bytes: 26308
#include <bits/stdc++.h>
#define Task "A"

using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy";
    if (s == "Cloudy") cout << "Rainy";
    if (s == "Rainy") cout << "Sunny";

    return 0;
}


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

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main(void) {
    
    string s;
    cin >> s;
    int d[4];

    string ans;

    rep(i,4){
        d[i] = ctoi(s[i]);
    }


    rep(i , 1 << 3){
        int sum = d[0];
        ans = to_string(d[0]);
        rep(j,3){
            if(i>>j&1){
                sum += d[j+1];
                ans += "+" + to_string(d[j+1]);
            }else{
                sum -= d[j+1];
                ans += "-" + to_string(d[j+1]);
            }
        }
        if(sum == 7){
            ans += "=7";
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

class UnionFind {
private:
  int *par, *rank;
public:
  UnionFind() {
    par = NULL;
    rank = NULL;
  }
  UnionFind(int n) {
    par = new int[n];
    rank = new int[n];
    while(n--) {
      par[n] = n;
      rank[n] = 0;
    }
  }
  int find(int x) {
    return par[x] == x ? x : par[x] = find(par[x]);
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x] == rank[y]) ++rank[x];
    }
  }
};

struct Edge {
  int a, b;
  double cost;
  bool operator < (const Edge &e) const {
    return cost < e.cost;
  }
};

const int MAXN = 101;
int n;
double x[MAXN], y[MAXN], z[MAXN], r[MAXN];

inline double dist(int i, int j) {
  return max(0.0, sqrt((x[i]-x[j])*(x[i]-x[j])+
                       (y[i]-y[j])*(y[i]-y[j])+
                       (z[i]-z[j])*(z[i]-z[j])) - (r[i]+r[j]));
}

int main() {
  while(cin >> n && n) {
    for(int i = 0; i < n; ++i) {
      cin >> x[i] >> y[i] >> z[i] >> r[i];
    }
    vector<Edge> v;
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j < n; ++j) {
        v.push_back((Edge){i,j,dist(i,j)});
      }
    }
    sort(v.begin(), v.end());
    UnionFind uf(n);
    double res = 0;
    for(int k = 0; k < v.size(); ++k) {
      if(!uf.same(v[k].a, v[k].b)) {
        uf.unite(v[k].a, v[k].b);
        res += v[k].cost;
      }
    }
    cout << fixed << setprecision(3) << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
 
template<typename T>
struct is_vector : false_type{};
 
template<typename T>
struct is_vector<vector<T>> : true_type{};
 
template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

void solve() {
  int n; cin >> n;
  vl arr(n);
  rep(i,n) cin >> arr[i];
  vl sum(n);
  sum[0] = arr[0];
  rep(i,n-1) sum[i+1] = sum[i] + arr[i+1];
  auto itr = upper_bound(all(sum), sum.back() / 2);
  ll ans = *itr * 2 - sum.back();
  --itr;
  ans = min(ans, sum.back() - *itr * 2);
  cout << ans << endl;
}

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


Measured memory_bytes: 3456
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {

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

    int[] a = new int[m];
    int[] b = new int[m];


    for (int i = 0; i < m; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }

    Set<Integer> s1 = new HashSet<Integer>();
    Set<Integer> s2 = new HashSet<Integer>();

    for (int i = 0; i < m; i++) {
      if (a[i] == 1) {
        s1.add(b[i]);
      }

      if (b[i] == n) {
        s2.add(a[i]);
      }
    }

    // for (Integer value : list2) {
    //   System.out.println(value);
    // }

  for (Integer i : s2) {
    if (s1.contains(i)) {
      System.out.println("POSSIBLE");
      return;
    }
  }

  System.out.println("IMPOSSIBLE");




  }

}


Measured memory_bytes: 107988
n = int(input())
a_list = list(map(int, input().split()))

c = 0
a = 0

for i in range(0, n-1):
    for j in range(n-1, i, -1):
        if a_list[j] < a_list[j-1]:
            a = a_list[j]
            a_list[j] = a_list[j-1]
            a_list[j-1] = a
            c += 1

print(' '.join(map(str, a_list)))
print(c)



Measured memory_bytes: 5596
# coding: utf-8
# Your code here!

L = input()
if L == "1 0 0":
    print("Close")
elif L == "0 1 0":
    print("Close")
elif L == "1 1 0":
    print("Open")
elif L == "0 0 1":
    print("Open")
elif L == "0 0 0":
    print("Close")



Measured memory_bytes: 5560
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

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

  vector<int> *v[3];
  for (auto &p: v) { p = new vector<int>(0); }

  for (auto i = 0; i != n; ++i) {
    switch (str[i]) {
      case 'R':
        v[0]->push_back(i);
        break;
      case 'G':
        v[1]->push_back(i);
        break;
      case 'B':
        v[2]->push_back(i);
        break;
    }
  }

  sort(begin(v),end(v),
       [](auto p1, auto p2){
         return p1->size() < p2->size();
       });
  
  ll cnt{0};
  for(auto i: *v[0]) {
    for(auto j: *v[1]) {
      cnt += v[2]->size();
      if(binary_search(begin(*v[2]),end(*v[2]),2*i-j)) --cnt;
      if(binary_search(begin(*v[2]),end(*v[2]),2*j-i)) --cnt;
      if((i+j)%2 == 0 && binary_search(begin(*v[2]),end(*v[2]),(i+j)/2)) --cnt;
    }
  }

  cout << cnt << endl;
  for (auto &p: v) { delete p; }
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>

using namespace std;

int f(int x, int y) {
  if (x > y) return 2e9+50;
  return y - x;
}

int main() {
  int x, y;
  cin >> x >> y;
  cout << min({f(x,y),1+f(x,-y),1+f(-x,y),2+f(-x,-y)}) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    ls = []
    for i in range(1, n + 1):
        ls.append(i % k)
    h = 0
    j = 0
    for v in ls:
        if v == 0:
            j += 1
        if v * 2 == k:
            h += 1
    print(j ** 3 + h ** 3)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 52208
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define MAX_V 100

using namespace std;

typedef long long ll;

vector<int> G[MAX_V];

bool cycle_exists = false;
bool activated[MAX_V];
bool checked[MAX_V];

void dfs(int i) {
    if (activated[i]) {
        cycle_exists = true;
    } else {
        activated[i] = true;
        for (int j = 0; j < G[i].size(); ++j)
            if (!checked[G[i][j]])
                dfs(G[i][j]);
        activated[i] = false;
    }
    checked[i] = true;
}

int main() {
    fill(activated, activated + MAX_V, false);
    fill(checked, checked + MAX_V, false);
    
    int V, E;
    cin >> V >> E;
    for (int i = 0; i < E; ++i) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
    }
    
    for (int i = 0; i < V; ++i)
        if (!checked[i])
            dfs(i);

    
    if (cycle_exists)
        cout << 1;
    else
        cout << 0;
    cout << endl;
    
    
    return 0;
}



Measured memory_bytes: 3140
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();
        for(int i=1;i<=3;i++){
            if(!(a==i||b==i))
                System.out.println(i);
        }
    }
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {1,1,1,1};
const int dx[] = {-1,0,1,0};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,y;
  while(cin >> x >> y&&x&&y){
    vector<vector<ll>> grid(x+1,vector<ll>(y+1,0));
    vector<vector<ll>> dp(x+3,vector<ll>(y+3,0));
    rep(i,y){
      rep(j,x){
        cin >> grid[j][i];
      }
    }
    rep(i,x){
      dp[i][0] = grid[i][0] == 0;
    }
    rep(i,y){
      rep(j,x){
        if(grid[j][i] == 0){
          rep(k,3){
            int nx = j+dx[k],ny = i+dy[k];
            if(value(j+dx[k],i+dy[k],x,y)){
              if(grid[nx][ny] == 0){
                dp[nx][ny] += dp[j][i];
              }
              else if(grid[nx][ny] == 2 && k == 1){
                dp[nx][ny] += dp[j][i];
              }
            }
          }
        }
        else if(grid[j][i] == 2 && grid[j][i+2] != 1){
          dp[j][i+2] += dp[j][i];
        }
      }
    }
    ll ans = 0;
    rep(i,x){
      ans += dp[i][y]+dp[i][y-1];
    }
//     cout << endl;
//     rep(j,y+1){
//       rep(i,x){
// //         ans += dp[i][y];
//         cout << dp[i][j]<< " ";
//       }
//       cout << endl;
//     }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3208
import numpy as np
N, M = map(int, input().split())
A = np.array([list(input()) for i in range(N)])
B = np.array([list(input()) for i in range(M)])

for k in range(N-M+1):
  for l in range(N-M+1):
    C = A[k:k+M,l:l+M]
    if (B==C).all():
      print('Yes')
      exit()
print('No')
      


Measured memory_bytes: 12428
import java.util.Scanner;

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

		int n = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		
		double minDiff = 1000000.000;
		int ans = 0;
		
		for(int i = 0;i < n;i++){
			int h = sc.nextInt();
			double nowT = t - h*0.006;
			
			if(minDiff > Math.abs(nowT-a)){
				minDiff = Math.abs(nowT-a);
				ans = i+1;
			}
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}

Measured memory_bytes: 23508
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

initial_num = 1
initial_list = []
permutation_list = []

for i in range(N):
    initial_list.append(initial_num + i)

for i in itertools.permutations(initial_list):
    permutation_list.append(list(i))

permutation_list.sort()
dictionary_P = permutation_list.index(P)
dictionary_Q = permutation_list.index(Q)

print(abs(dictionary_P - dictionary_Q))

Measured memory_bytes: 10228
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <map>
#include <array>
#include <bitset>

using namespace std;

const int maxn=105;

int dp[maxn][maxn];
bool l[maxn][maxn];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	string s;
	for(int i=0; i<n; i++){
		cin >> s;
		for(int j=0; j<m; j++){
			if(s[j]=='.'){
				l[i][j]=0;
			}
			else{
				l[i][j]=1;
			}
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			if(!i && !j){
				dp[i][j]=l[i][j];
			}
			else if(!i){
				if(l[i][j] && !l[i][j-1]){
					dp[i][j]=dp[i][j-1]+1;
				}
				else{
					dp[i][j]=dp[i][j-1];
				}
			}
			else if(!j){
				if(l[i][j] && !l[i-1][j]){
					dp[i][j]=dp[i-1][j]+1;
				}
				else{
					dp[i][j]=dp[i-1][j];
				}
			}
			else{
				if(l[i][j] && !l[i-1][j]){
					dp[i][j]=dp[i-1][j]+1;
				}
				else{
					dp[i][j]=dp[i-1][j];
				}
				if(l[i][j] && !l[i][j-1]){
					dp[i][j]=min(dp[i][j], dp[i][j-1]+1);
				}
				else{
					dp[i][j]=min(dp[i][j-1], dp[i][j]);
				}
			}
//			cout << dp[i][j] << " ";
		}
//		cout << '\n';
	}
	cout << dp[n-1][m-1] << '\n';
	return 0;
}

Measured memory_bytes: 888
/*
    B - Five Dishes
    https://atcoder.jp/contests/abc123/tasks/abc123_b
*/
#include <bits/stdc++.h>
using namespace std;

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

    vector<int> time(5);
    for (int i = 0; i < 5; i++) {
        cin >> time[i];
    }

    int sum = 0;
    int diff_max = 0;
    for (int i = 0; i < 5; i++) {
        sum += time[i];

        int diff = (10 - time[i] % 10);
        if (diff % 10 != 0)
            sum += diff;

        if (diff_max < diff && diff % 10 != 0)
            diff_max = diff;
    }
    cout << (sum - diff_max) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl
using namespace std;

bool sosuu(const int x)
{
	if (x == 2)return true;
	if (x < 2 || x % 2 == 0)return false;
	for (int i = 3; i * i <= x; i += 2)
		if (x % i == 0)return false;
	return true;
}
int gcd(int a, int b)
{
	if (a % b == 0) { return b; }
	else { return gcd(b, a % b); }
}
int ketawa(int a)
{
	if (a < 10)return a;
	else return a % 10 + ketawa(a / 10);
}
bool kaibun(string s)
{
	
	for(int i=0;i< sz(s);i++)
	{
		if (s[i] != s[sz(s) - i - 1])
			return false;
	}
	return true;
}

typedef long long ll;

string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

ll a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;


int main()
{
	cin >> s;
	rep(i, 6)
	{
		if (s[i] == '1')
			a++;
	}
	cout << a << endl;

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n<1200){
    cout << "ABC" << endl;
  }else if(n>=1200 && n<2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}

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

ans = [['.']*100 for _ in range(50)] + [['#']*100 for _ in range(50)]

if b != 1:
    B = 0
    for i in range(49):
        for j in range(100):
            flag = True
            for di, dj in (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1):
                ni, nj = i+di, j+dj
                if 0 <= ni < 50 and 0 <= nj < 100:
                    if ans[ni][nj] == '#':
                        flag = False
                        break
            if flag:
                ans[i][j] = '#'
                B += 1
            if B == b-1:
                break
        else:
            continue
        break

if a != 1:
    A = 0
    for i in range(51, 100):
        for j in range(100):
            flag = True
            for di, dj in (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1):
                ni, nj = i+di, j+dj
                if 50 <= ni < 100 and 0 <= nj < 100:
                    if ans[ni][nj] == '.':
                        flag = False
                        break
            if flag:
                ans[i][j] = '.'
                A += 1
            if A == a-1:
                break
        else:
            continue
        break

print(100, 100)
for i in range(100):
    print(''.join(ans[i]))


Measured memory_bytes: 9320
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,t,v,w,x,y,a[200040];
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	for(cin>>t;t--;)
	{
		cin>>s;
		if(s=="AC")v++;
		if(s=="WA")w++;
		if(s=="TLE")x++;
		if(s=="RE")y++;
	}
	cout<<"AC x "<<v<<endl;
	cout<<"WA x "<<w<<endl;
	cout<<"TLE x "<<x<<endl;
	cout<<"RE x "<<y<<endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;


string s;


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int n,ans,d[505][505],p[505*505],dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
bool b[505][505];
void gao(int x,int y){
	b[x][y]=false;
	queue<pair<int,int> > q;
	q.push(make_pair(x,y));
	while(q.size()){
		pair<int,int> p=q.front();
		q.pop();
		for(int k=0;k<4;k++){
			int z=d[p.first][p.second]+(b[p.first][p.second]);
			int nx=p.first+dx[k],ny=p.second+dy[k];
			if(nx>0 and nx<=n and ny>0 and ny<=n and d[nx][ny]>z){
				d[nx][ny]=z;
				q.push(make_pair(nx,ny));
			}
		}
	}
}
int main(){
	n=read();
	for(int i=1;i<=n*n;i++)
		p[i]=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			d[i][j]=min(min(i-1,n-i),min(j-1,n-j));
			b[i][j]=true;
		}
	for(int i=1;i<=n*n;i++){
		int x=(p[i]-1)/n+1,y=(p[i]-1)%n+1;
		ans+=d[x][y];
		gao(x,y);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5916
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define MOD 1000000007

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

vector<pair<int,int>> solve(ll N){
    vector<pair<int,int>> v;
    ll sqrt = pow(N, 0.5);
    for(int i = 2; i <= sqrt; i++){
        int cnt = 0;
        while(true){
            if(N % i == 0){
                cnt++;
                N /= i;
            }
            else break;
        }
        if(cnt != 0) v.push_back({i, cnt});
    }
    if(N != 1) v.push_back({N, 1});
    return v;
}

ll cal(vector<pair<int,int>> &v){
    int ans = 0;
    for(auto s:v){
        ll n = s.second;
        ll i = 1;
        while(n >= i){
            ans++;
            n -= i;
            i++;
        }
    }
    return ans;
}
int main(){
    ll N;
    cin >> N;
    auto v = solve(N);
    int ans = cal(v);
    cout << ans << endl;
}


Measured memory_bytes: 4000
import collections
import math
n=int(input())
s=[]
for i in range(n):
    sl=list(input())
    sl.sort()
    s.append("".join(sl))

l=list(collections.Counter(s).values())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

c=0
for i in range(len(l)):
    k=int(l[i])
    if k!=1:c+=combinations_count(k,2)
print(c)

Measured memory_bytes: 19728
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int par[N], rnk[N], sz[N];
int findroot(int node) {
	if (par[node] == node)
		return node;
	else {
		par[node] = findroot(par[node]);
		return par[node];
	}
}
void dounion(int x, int y) {
	if (rnk[x] > rnk[y]) {
		par[y] = x;
		sz[x] += sz[y];
	}
	else if (rnk[x] < rnk[y]) {
		par[x] = y;
		sz[y] += sz[x];
	}
	else {
		par[x] = y;
		sz[y] += sz[x];
		rnk[y]++;
	}
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		sz[i] = 1;
		par[i] = i;
	}
	vector<pair<int, int> > edg(m);
	for (int i = 0; i < m; i++) {
		cin >> edg[i].first >> edg[i].second;
		edg[i].first--;
		edg[i].second--;
	}
	long long ans[m], cnt = (n - 1LL) * n / 2;
	for (int i = m - 1; i >= 0; i--) {
		ans[i] = cnt;
		int x = findroot(edg[i].first);
		int y = findroot(edg[i].second);
		if (x != y) {
			cnt -= sz[x] * sz[y];
			dounion(x, y);
		}
	}
	for (int i = 0; i < m; i++) {
		cout << ans[i] << ' ';
	}
	return 0;
}


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

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  map<long long, int> mp;
  vector<vector<long long> > C(51, vector<long long>(51));
  for (int i=0; i<51; i++){
    for (int j=0; j<=i; j++){
      if ((j==0) || (j==i)) C[i][j] = 1;
      else C[i][j] = C[i-1][j-1] + C[i-1][j];
    }
  }
  vector<long long> val;
  for (int i=0; i<N; i++){
    long long v;
    cin >> v;
    mp[v]++;
    if (mp[v] == 1) val.push_back(v);
  }
  sort(val.begin(),val.end());
  reverse(val.begin(),val.end());
  int atleast = A;
  double ansmean = 0;
  long long anspattern = 0;
  for (long long i: val){
    if (mp[i] < atleast){
      atleast -= mp[i];
      ansmean += mp[i]*i/(double)A;
    } else {
      long long count;
      mp[i] < B ? (count=mp[i]) :(count=B);
      ansmean += atleast*i/(double)A;
      if (ansmean == i){
        for (int j=atleast; j<=count; j++) anspattern += C[mp[i]][j];
      } else anspattern += C[mp[i]][atleast];
      break;
    }
  }
  cout << fixed << setprecision(10);
  cout << ansmean << endl;
  cout << anspattern << endl;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n; cin >> n;
	vector<int> A(n, 0);
	vector<bool> check(n, true);
	for (int i=0; i<n; i++) cin >> A[i];
	map<int, int> count;
	int maxA = 0;
	for (int i=0; i<n; i++) {
		maxA = max(maxA, A[i]);
		count[A[i]]++;
	}

	sort(A.begin(), A.end());
	for (int i=0; i<n; i++) {
		int a = A[i];
		if (!check[i]) continue;
		for (int i=2; i*a<=maxA; i++) {
			if (binary_search(A.begin(), A.end(), i*a)){
				auto itr = lower_bound(A.begin(), A.end(), i*a);
				int dist = itr - A.begin();
				check[dist] = false;
			}
		}
		if (count[a]>1) {
			check[i] = false;
			continue;
		}
	}
	int ret = 0;
	for (int i=0; i<n; i++) ret += check[i];
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 13544
#include <bits/stdc++.h>
using namespace std;
//cin.ignore();	// better to use 2 times getline(cin,s);
// g++ iterator.cpp -std=c++17
//cout << (A + B == C ? "YES" : "NO") << endl;
//__gcd(a,b)
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	ll n,a,b;
	cin>>n>>a>>b;
	cout<<(a*(n/(a+b)))+(min(n%(a+b),a))<<endl;
}

Measured memory_bytes: 256
X, Y = map(int, input().split())

a = 1/2 * (4 * X - Y)
b = 1/2 * (-2 * X + Y)

if a >= 0 and b >= 0 and (a - int(a)) == 0 and (b - int(b)) == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    REP(i, a) cin >> p[i];
    REP(i, b) cin >> q[i];
    REP(i, c) cin >> r[i];
    sort(ALL(p), greater<>());
    sort(ALL(q), greater<>());
    sort(ALL(r), greater<>());

    ll idxp = x-1, idxq = y-1, idxr = -1;
    while((0 <= idxp || 0 <= idxq) && idxr+1 < c) {
        if(idxq < 0 || (idxp >= 0 && p[idxp] < q[idxq])) {
            if(r[idxr+1] >= p[idxp]) {
                idxp--;
                idxr++;
            } else {
                break;
            }
        } else {
            if(r[idxr+1] >= q[idxq]) {
                idxq--;
                idxr++;
            } else {
                break;
            }
        }
    }

    ll ans = 0;
    REP(i, idxp+1) ans += p[i];
    REP(i, idxq+1) ans += q[i];
    REP(i, idxr+1) ans += r[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
from collections import Counter


def main():
    N = int(input())
    D = input().split()
    M = int(input())
    T = input().split()

    d = Counter(D)
    t = Counter(T)
    for key, value in t.items():
        if d[key] < value:
            print('NO')
            exit()
    else:
        print('YES')


if __name__ == '__main__':
    main()

Measured memory_bytes: 69216
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] num= new int[2];

		while(true) {
			num[0] = scan.nextInt();
			num[1] = scan.nextInt();
			if(num[0] == 0) break;
			for(int i1 = 0; i1 < num[0];i1++) {
				for(int i2 = 0;i2 < num[1];i2++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
		
	}
}

Measured memory_bytes: 26820
s = input()
g_cnt, p_cnt = 0, 0
ans = 0
for c in s:
    if c == 'g':
        if g_cnt > p_cnt:
            ans   += 1
            p_cnt += 1
        else:
            g_cnt += 1
    else:
        if g_cnt > p_cnt:
            p_cnt += 1
        else:
            ans   -= 1
            g_cnt += 1
print(ans)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vector<P> r(n), b(n);
  set<P, greater<P>> st;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    st.insert(P(b, a));
  }
  rep(i, n) cin >> b[i].first >> b[i].second;
  sort(all(b));
  ll ans = 0;
  rep(i, n) {
    ll c = b[i].first;
    ll d = b[i].second;
    for(auto p : st) {
      ll a = p.second;
      ll b = p.first;
      if(a >= c || b >= d) continue;
      ans++;
      st.erase(p);
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N, A, B, C = gets.split.map(&:to_i)
LS = []
N.times do
  LS << gets.to_i
end

INF = 10 ** 9

def rec(cur, a, b, c)
  if N == cur
    return ([a, b, c].min > 0) ? (A-a).abs + (B-b).abs + (C-c).abs - 30 : INF
  else
    ret0 = rec(cur+1, a, b, c)
    ret1 = rec(cur+1, a+LS[cur], b, c) + 10
    ret2 = rec(cur+1, a, b+LS[cur], c) + 10
    ret3 = rec(cur+1, a, b, c+LS[cur]) + 10
    return [ret0, ret1, ret2, ret3].min
  end
end

puts rec(0, 0, 0, 0)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define fastIO  std::ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long int
#define vi vector<int>
#define pi pair<int,int>
#define ff first
#define ss second
#define MOD 1000000007
#define MMOD  998244353
#define pb push_back


signed main(void)
{
    fastIO;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while(t--)
    {
        int n,W;
        cin>>n>>W;
        vector<int>v(n),w(n);
        for(int i=0;i<n;i++)
        {
            cin>>w[i]>>v[i];
        }
        vector<vector<int> >dp(n,vector<int>(W+1));
        for(int i=0;i<=W;i++)
        {
            if(i>=w[0])
                dp[0][i]=v[0];
        }
        for(int i=1;i<n;i++)
        {
            for(int j=0;j<=W;j++)
            {
                if(j-w[i]>=0)
                    dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
                else
                    dp[i][j]=dp[i-1][j];
            }
        }
        cout<<dp[n-1][W]<<endl;
    }  

 
}

Measured memory_bytes: 82200
#include <stdio.h>
#include<string.h>
int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！

    
   int a,b;
   int count =0;
   int max = 0;
   char str[100][100];
   char str1[100][100];

    scanf("%d",&a);
    for(int i=0;i<a;i++){
        scanf("%s",str[i]);
    }
    scanf("%d",&b);
    for(int i=0;i<b;i++){
        scanf("%s",str1[i]);
    }

    for(int i=0;i<a;i++){
        count=0;
        for(int j=i;j<a;j++){
            if(strcmp(str[i],str[j]) == 0){
                count++;
            }
        }
        for(int q=0;q<b;q++){
            if(strcmp(str[i],str1[q]) == 0){
                count--;
            }
        }
        if(count>max){
            max=count;
            
        }
    }
    printf("%d\n",max);
    
    return 0;
}

Measured memory_bytes: 1704
/*
文字列中の文字を昇順に並び替える×
並び替えた文字列の文字をSetに入れることで重複なしにできる
・・・
*/
//setはStringクラスでなくともchar型をCharacterとして使える

import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      //String s = sc.nextLine();
      //何文字の文字列か分かってないときに便利。
      char[] S = sc.next().toCharArray();
      //Set<String> d = new HashSet<String>();
      Set<Character> d = new HashSet<Character>();


      for(char c : S){d.add(c);}
      //Set<String> d = new HashSet<String>();
      /*for(int i = 0; i < s.length(); i++){
        //char型からStringクラスへの変換
        d.add(valueOf(s[i]));
      }*/
      for(char i = 'a'; i <= 'z'; i++){
        if(!d.contains(i)){
          System.out.println(i);
          return;
        }
      }

      System.out.println("None");

      /*println(c+1)とすると, 数値で優先？されて98(=b)が出る
      char c = 'a';
      c += 1;
      System.out.println(c);
      */
      /*if(d.size() == 26)
        System.out.println("None");
      else{

      }
      */
    }
  }


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

using namespace std;

int main()
{
  int N, X;

  cin >> N >> X;

  vector<int> L(N);

  for(int i = 0;
      i < N;
      ++i)
    {
      cin >> L[i];
    }

  int D = 0;
  int ans = 1;

  for(ans = 0;
      D <= X && ans < N;
      ++ans)
    {
      D += L[ans];
    }

  if(D <= X)
    {
      ++ans;
    }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int a, b; cin >> a >> b;

    int mais, menos, multiplicacao;

    mais = a + b;
    menos = a - b;
    multiplicacao = a * b;

    if(mais > menos and mais > multiplicacao)
        cout << mais << endl;
    else if (menos > mais and menos > multiplicacao)
        cout << menos << endl;
    else if (multiplicacao > mais and multiplicacao > menos)
        cout << multiplicacao << endl;

    else
        cout << mais << endl;
    
    return 0;
}

Measured memory_bytes: 256