akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int r; cin>>r;
    cout<<fixed<<setprecision(4);
    cout<<r*2*3.14159265<<endl;
}

Measured memory_bytes: 3784
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main()
{
		char A[1000];
		int i,k=0;
		cin >> A;
		for (i = 0; i < 5; i++)
		{
			if ((A[i] == 65) && (A[i+1] == 67))
			{
				k = 1;
				break;
			}
		}
		if (k == 1)
			printf("Yes");
		if (k == 0)
			printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

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

	long long cnt = 0;
	FOR(i, 0, n) {
		cin >> a[i];
	}
	FOR(i, 0, n) {
		if (i >= 1) {
			int add = min(a[i - 1], a[i]);
			a[i] -= add;
			cnt += add;
		}
		cnt += a[i] / 2;
		a[i] %= 2;
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15)+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;

template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}

int main(void){
	int n,i;cin>>n;
	llint dp,ep=-big,fp=-big;cin>>dp;
	bool mai=true;
	for(i=1;i<n;i++){
		char c;cin>>c;
		llint a;cin>>a;
		if(c=='-'){
			maxeq(fp,ep);
			maxeq(ep,dp);
			dp-=a;
			ep-=a;
			fp+=a;
		}else{
			dp+=a;
			ep-=a;
			fp+=a;
		}
	}
	maxeq(fp,dp);
	cout<<fp<<endl;
}

Measured memory_bytes: 256
n=int(input())
a=[0]+list(map(int,input().split()))+[0]

sumD=0
for i in range(1,len(a)):
    sumD+=abs(a[i]-a[i-1])

for g in range(n):
    print(sumD-abs(a[g+2]-a[g+1])-abs(a[g+1]-a[g])+abs(a[g+2]-a[g]))

Measured memory_bytes: 14048
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <bitset>

#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define rep1(i,n) for (int (i) = 1; (i) <= (n); i++)
typedef long long int llint;

using namespace std;

const long long int inf = 1 << 29 ;

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

	vector<int> l(n);
	rep(i, n) {
	  cin >> l[i];
	}

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


	int ans = 0;
	// i < j
	for(int j = 1; j < n - 1; j++) {
		rep(i, j) {
		  auto it = upper_bound(l.begin() + j, l.end(), l[i] + l[j] - 1);
			int k = distance(l.begin(), it);
			ans += k - j - 1;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef struct{
	char suit;
	int value;
}Card;

void print(Card[], int);

int main(){
	int N, i, j;
	cin >> N;

	Card C[N], Cb[N], Cs[N], tmp;
	for(i = 0; i < N; i++){
		cin >> (C[i].suit) >> (C[i].value);
		Cs[i] = C[i];
		Cb[i] = C[i];
	}

//	BubbleSort(C)
//	1 for i = 0 to C.length-1
//	2     for j = C.length-1 downto i+1
//	3         if C[j].value < C[j-1].value
//	4             swap C[j] and C[j-1]
	for(i = 0; i < N; i++){
		for(j = N-1; j > i; j--){
			if(Cb[j].value < Cb[j-1].value){
				tmp = Cb[j];
				Cb[j] = Cb[j-1];
				Cb[j-1] = tmp;
			}
		}
	}

//	SelectionSort(C)
//	1 for i = 0 to C.length-1
//	2     mini = i
//	3     for j = i to C.length-1
//	4         if C[j].value < C[mini].value
//	5             mini = j
//	6     swap C[i] and C[mini]
	int mini;
	for(i = 0; i < N; i++){
		mini = i;
		for(j = i; j < N; j++){
			if(Cs[j].value < Cs[mini].value){
				mini = j;
			}
		}
		if(i != mini){
			tmp = Cs[i];
			Cs[i] = Cs[mini];
			Cs[mini] = tmp;
		}
	}

	string bState = "Stable", sState = "Stable";
	int v, s[9] = {0}, sb[9] = {0}, ss[9] = {0};
	char origin[4][9];
	for(Card c : C){
		v = c.value - 1;
		origin[s[v]][v] = c.suit;
		s[v]++;
	}

	for(Card c : Cb){
		v = c.value - 1;
		if(origin[sb[v]][v] != c.suit){
			bState = "Not stable";
			break;
		}
		sb[v]++;
	}

	for(Card c : Cs){
		v = c.value - 1;
		if(origin[ss[v]][v] != c.suit){
			sState = "Not stable";
			break;
		}
		ss[v]++;
	}

	print(Cb, N);
	cout << bState << endl;
	print(Cs, N);
	cout << sState << endl;

	return 0;
}

void print(Card card){
	cout << card.suit << card.value;
}

void print(Card A[], int N){
	print(A[0]);
	for(int k = 1; k < N; k++){
		cout << ' ';
		print(A[k]);
	}
	cout << endl;
}


Measured memory_bytes: 3152
def main():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        count = 0
        for j in range(1,i+1,2):
            if i%j == 0:
                count += 1
        if count == 8:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

string Str;
string message = "Yes";

int main() {
  cin >> Str;
  if (Str[0] == Str[1] && Str[1] == Str[2]) {
    message = "No";
  }
  cout << message << endl;
  return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
h = list(map(int, input().split()))

ab = [0]*n
for i in range(m):
  a,b = map(int, input().split())
  ab[a-1] = max(ab[a-1], h[b-1])
  ab[b-1] = max(ab[b-1], h[a-1])

ans = 0
for i in range(n):
  if ab[i] < h[i]:
    ans += 1
print(ans)

Measured memory_bytes: 19956
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;
int t[100005], x[100005], y[100005];
int main()
{
	int N;
	cin >> N;
	t[0] = 0; x[0] = 0; y[0] = 0;
	FOR(i, N + 1, 1)
	{
		cin >> t[i] >> x[i] >> y[i];
	}
	FOR(i, N + 1, 1)
	{
		int time = t[i] - t[i - 1];
		int dx = x[i] - x[i - 1], dy = y[i] - y[i - 1];
		time -= (dx + dy);
		if (time < 0 || time % 2 == 1)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder.ABC
{
	class QuestionC
	{
		public static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var c = Console.ReadLine();

			var rightR = -1;
			var leftR = c.Length;
			var rightW = -1;
			var leftW = c.Length;

			var rCount = c.Count(x => x == 'R');
			var wCount = n - rCount;

			if(rCount == 0 || wCount == 0) {
				Console.WriteLine(0);
				return;
			}

			var count = c.Substring(c.Length - wCount, wCount).Count(x => x == 'W');
			count = wCount - count;

			Console.WriteLine(count);
			/*
			for(int i = 0; i < n; i++) {
				var cc = c[i];

				if (cc == 'R') {
					if (leftR == -1) {
						leftR = i;
					}

					if(rightR < i) {
						rightR = i;
					}
				} else {
					if (leftW == -1) {
						leftW = i;
					}

					if (rightW < i) {
						rightW = i;
					}
				}
			}

			var fCount = leftR - leftW;

			var result = c.Substring(leftW, fCount).Count(x => x == 'W');
			*/
		}
	}
}


Measured memory_bytes: 28892
#include <stdio.h>
#include <stdlib.h>
typedef unsigned int uint;
#define PARENT(i) ((i)>>1)
#define LEFT(i) ((i)<<1)
#define RIGHT(i) (((i)<<1)+1)
#define SWAP(x,y) (x^=y^=x^=y)
#define gc getchar
#define Mmax 300000
int s[Mmax],t[Mmax],c[Mmax],q[Mmax],qnum=0;

int scan(int*N)
{
	int c,n=0;
	for(c=gc();'0'<=c&&c<='9';c=gc())
	    n=(n*10)+(c&0xf);
	if(N!=NULL)*N=n;
	return n;
}

void func(int i)
{
	int l=LEFT(i),r=RIGHT(i),m=i;
	if(l<qnum&&q[l]>q[m])m=l;
	if(r<qnum&&q[r]>q[m])m=r;
	if(m!=i){SWAP(q[m],q[i]);func(m);}
}

uint pop(void)
{
	uint c=(uint)q[0];
	q[0]=q[--qnum];
	func(0);
	return c;
}

void push(int c)
{
	int i,p;
	q[i=qnum++]=c;
	for(i&&1;q[p=PARENT(i)]<q[i];i=p)
	    SWAP(q[p],q[i]);
}

int main()
{
	int N,M,T=0,i=0;
	uint a=0;
	scan(&N);
	while(i<N){s[i]=scan(&M),t[i++]=T;while(M--)c[T++]=scan(NULL);}
	for(i=N-1;i>=0;i--){M=s[i],T=t[i];while(M--)push(c[T++]);a+=pop();}
	printf("%u\n",a);
}

/*
#define DEBUG
#ifndef DEBUG
#define DEBUG if(0)
#endif



#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>

#define gc getchar
int scan(int*N)
{
	int c,n=0;
	for(c=gc();'0'<=c&&c<='9';c=gc())
	    n=(n*10)+(c&0xf);
	if(N!=NULL)*N=n;
	return n;
}

typedef struct
{
    int p; //得点
    int d; //深さ
	int w; //ノードの重さ
}S_dungeon;

typedef struct
{
    int s; //隣接部屋1
    int t; //隣接部屋2
}S_path;

#define N_MAX 100000
S_dungeon room[N_MAX];
S_path adjacency[N_MAX];

int comp( const void * a, const void * b )
{
	if( ((S_path *)a)->s == ((S_path *)b)->s ){
		return ((S_path *)a)->t - ((S_path *)b)->t;
	}
	return ((S_path *)a)->s > ((S_path *)b)->s;
}

void score_parent_node(int i)
{
	int n = i+1;
}

int cal_score(void)
{
	int i;
	for( i = 0; i < N; i++)
	{
		if( room[i].w > 2 ){
			score_parent_node(i);
		}
	}
	return 0;
}

int main()
{
	int i,N;
	
	scanf("%d", &N );
	for( i = 0; i < N; i++ ){
	    scanf("%d", &room[i].p );
	}
	rewind(stdin);
	for( i = 0; i < N-1; i++ ){
		room[ scan( &adjacency[i].s )-1 ].w++;
		room[ scan( &adjacency[i].t )-1 ].w++;
	}
	
	qsort( adjacency, N-1, sizeof(adjacency[0]), comp );
	
	
DEBUG{
	for( i = 0; i < N; i++ ){
		printf("[%d] p = %d, w = %d, s = %d, t = %d\n", i, room[i].p, room[i].w, adjacency[i].s, adjacency[i].t );
	}
}
	
	printf("%d", cal_score() );
	
	return 0;
}
*/

/* test data (copy and paset for input)
7
6
1
-1
4
3
3
1
1 2
2 3
3 4
3 5
5 6
5 7
*/




Measured memory_bytes: 5160
D = zip([-1,0,1,2,2,2,1,0,-1,-2,-2,-2],
        [-2,-2,-2,-1,0,1,2,2,2,1,0,-1])

def check(x,y):
    return 0<=x<=9 and 0<=y<=9

def pick(survivors,x,y):
    ret = []
    for (sx,sy) in survivors:
        if x-1<=sx<=x+1 and y-1<=sy<=y+1:
            ret.append((sx,sy))
    return ret

def move(survivors):
    tmp = []
    for (sx,sy) in survivors:
        for dx,dy in D:
            if check(sx+dx,sy+dy):
                tmp.append((sx+dx,sy+dy))
    return list(set(tmp))

while True:
    survivors = [map(int,raw_input().split())]
    if survivors == [[0,0]]:
        break
    n = input()
    pos = map(int,raw_input().split())
    for x,y in zip(pos[::2],pos[1::2]):
        survivors = pick(move(survivors),x,y)
        if len(survivors) == 0:
            print "NA"
            break
    else:
        print "OK"

Measured memory_bytes: 4288
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
// const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

const int INF=1e9;
vector<vector<int>> d; //d[from][to]:=2点間の最短距離
void Warshall_Floyd(int n){ //頂点数n
    rep(i,n){               //経由点i
        rep(j,n){           //始点j
            rep(k,n){       //終点k
                d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
            }
        }
	}
}
int main(){
	int n,m; cin>>n>>m;
    //n*nの盤面をINFで初期化
    d=vector<vector<int>>(n,vector<int>(n,INF));
    rep(i,n) d[i][i]=0;
    pair<pair<int,int>,int> edge[m];
    rep(i,m){
        int from,to,cost; cin>>from>>to>>cost;
        from--,to--;
        edge[i]={{from,to},cost};
        d[from][to]=cost;
        d[to][from]=cost;
    }
    Warshall_Floyd(n);
    bool used[m]={};
    rep(k,m){
        int from=edge[k].first.first,to=edge[k].first.second,cost=edge[k].second;
        rep(i,n)rep(j,n){
            if(d[i][from]+cost+d[to][j]==d[i][j]){
                used[k]=1;
            }
        }
    }
    int cnt=0;
    rep(i,m)if(!used[i])cnt++;
    cout<<cnt<<endl;
    return 0;
}


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

int main() {
	int n, num[10000];

	cin >> n;

	for (int i = 0; i < n; i++) cin >> num[i];

	int maxv = -2000000;
	int minv = num[0];
	long sum = 0;

	for (int i = 0; i < n; i++) {
		maxv = max(maxv, num[i]);
		minv = min(minv, num[i]);
		sum += num[i];
	}

	cout << minv << " " << maxv << " " << sum << endl;

	return 0;
}



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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  vector<pair<string, int>> list(N);
  FOR(i, N) cin >> list[i].first >> list[i].second;
  string X;
  cin >> X;
  int ans = 0;
  bool f = 0;
  int i;
  for (i = 0; i < N; ++i) {
    if (f) ans += list[i].second;
    if (list[i].first == X) {
      f = 1;
    }
  }
  print(ans);
  return 0;
}

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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define vi vector< int > 
#define pii pair< int, int >
#define mii map< int , int > 
#define F(start,stop) for(int i=start; i<stop; i++)
#define FRev(start,stop) for(int i=start; i>=stop; i--)
#define debugVector(v) for(int i = 0; it < v.size(); i++) cout << v[i] << " "; cout << endl;
#define debugArray(arr, n) for(int i=0; i<n; i++) cout << arr[i] << " "; cout << endl;
#define MOD1 1000000007
#define MOD2 998244353


int main()
{

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

	IOS

	ll a,b,c,k;
	cin >> a >> b >> c >> k;

	ll sum = 0;

	if(k > 0){
		sum += min(k,a);
		k -= a;
	}

	if(k > 0){
		k -= b;
	}

	if(k > 0){
		sum -= min(k,c);
	}

	cout << sum << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();

		int digit = 0;
		while (n >= k) {
			n = n / k;
			digit++;
		}

		if (n <= (k - 1)) {
			digit++;
		}

		System.out.println(digit);

		sc.close();
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define inf 10000000000000
#define vll vector<ll>
using namespace std;
const int N=100005;
ll a[N];
void solve()
{
	ll n,a[N],b[N],s=0,i;
	cin>>n;
	for(i=1;i<=n+1;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	for(i=1;i<=n;i++)
		cin>>b[i];
	for(i=1;i<=n;i++)
	{
		if(b[i]>=a[i])
			b[i]-=a[i],a[i]=0;
		else
			a[i]-=b[i],b[i]=0;
		if(b[i]>=a[i+1])
			a[i+1]=0;
		else
			a[i+1]-=b[i];
	}
	for(i=1;i<=n+1;i++)
		s-=a[i];
	cout<<s;
	
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int a[10][10],m,n,flag;
char kk[10];
void dfs(int x,int y){
	if(x==m-1&&y==n-1){
		for(int i=0;i<m;++i)for(int j=0;j<n;++j)if(a[i][j])return;
		flag = 1;    
        return;
    }
	if(flag==1)return;
    if(a[x+1][y]){
        a[x+1][y]=0;
        dfs(x+1,y);
        a[x+1][y]=1;
    }
    if(a[x][y+1]){
        a[x][y+1]=0;
        dfs(x,y+1);
        a[x][y+1]=1;
    }
    if(!a[x][y+1]&&!a[x+1][y])return;
}
int main(){
    scanf("%d%d",&m,&n);
    for(int i=1;i<=m;++i){
        cin>>kk;
        for(int j=0;j<n;++j)if(kk[j]=='#')a[i-1][j]=1;
    }
    if(a[0][0]){
        a[0][0]=0;
        dfs(0,0);
    }
    if(flag)printf("Possible\n");
    else printf("Impossible\n");
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");

ll dp[100010][13] = {};
int main(){
    string s;
    ll ans = 0;
    cin >> s;
    ll n = s.length();
    dp[0][0] = 1;

    rep(i, 0, n){
      int now;
      if(s[i] == '?') now = -1;
      else now = s[i] - '0';
      rep(j, 0, 10){
        if(now == -1 || now == j){
          rep(ki, 0, 13){
            dp[i+1][(ki * 10 + j) % 13] += dp[i][ki];
          }
        }
      }
      rep(j, 0, 13){
        //cout << dp[i+1][j] << " ";
        dp[i+1][j] %= INF;
      }
      //cout << "" << endl;
    }

    print(dp[n][5]);
   
  return 0;
}

Measured memory_bytes: 10624
use std::io::prelude::*;

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

fn main() {
    let n: usize = input();
    let s: Vec<String> = (0..n).map(|_| input()).collect();
    let m: usize = input();
    let t: Vec<String> = (0..m).map(|_| input()).collect();

    let mut ans = 0;
    for u in &s[..] {
        let a = s.iter().filter(|&s| *s == *u).count();
        let b = t.iter().filter(|&t| *t == *u).count();
        ans = std::cmp::max(ans, a as i64 - b as i64);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int n = str.length();
    char[] c = new char[n];
    for(int i = 0; i < n; i++) {
      c[i] = str.charAt(i);
    }
    int ans = 0;
    for(int j = 0; j < n / 2; j++) {
      if(j == n - 1 - j) break;
      if(c[j] != c[n-1-j]) ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 22868
alp=list('qawsedrftgyhujikoplmnbvcxz')
alp.sort()
# print(alp)
cnt=[]
for i in range(int(input())):
  tmp=[0 for _ in range(26)]
  for s in list(input()):
    tmp[alp.index(s)]+=1
  cnt.append(tmp)
  # print(tmp)
ans=''
for i in range(26):
  m=57
  for j in range(len(cnt)):
    m=min(m,cnt[j][i])
  ans+=alp[i]*m
print(ans)


Measured memory_bytes: 3064
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    x <- getInt
    let ans | x == 1 = 0
            | otherwise = 1
    print ans

Measured memory_bytes: 3764
#include<stdio.h>
#include<string.h>
int main(void)
{
	int n;
	int i,j,k;
	int flg,flg2;
	int cnt,len;
	char a[11],b[21];
	cnt=0;

	scanf("%s",a);
	len=strlen(a);
	scanf("%d",&n);

	for(k=0;k<n;k++){
		scanf("%s",b);
			
		for(i=0;i<10;i++){
			b[i+10]=b[i];
		}
		b[20]='\0';
		flg2=0;
		for(i=0;i<20;i++){
			flg=1;
			for(j=0;j<len;j++){			
				if(i+j>20){
					flg=0;
					break;
				}
				if(a[j]!=b[i+j]){
					flg=0;
				}
			}
			if(flg==1){
				flg2=1;
			}
		}
		if(flg2==1){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<queue>
using namespace std;
typedef long long ll;

const int N=1e5+15;
const ll inf=1e18;
int x,y,z,n;
ll sc;
ll pre[N],suf[N];
struct node{ll a,b,c;}p[N];
bool cmp(node A,node B) {return A.c<B.c;}
struct NODE{ll x;};
bool operator < (NODE a,NODE b) {return a.x>b.x;}
priority_queue <NODE> q;
inline ll read()
{
	char ch=getchar();
	ll s=0,f=1;
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') {s=(s<<3)+(s<<1)+ch-'0';ch=getchar();}
	return s*f;
}
int main()
{
	x=read();y=read();z=read();
	n=x+y+z;
	for (int i=1;i<=n;i++)
	{
		ll a=read(),b=read(),c=read();
		sc+=c;
		a-=c;b-=c;
		p[i]=(node){a,b,a-b};
	}
	sort(p+1,p+1+n,cmp);
	//for (int i=1;i<=n;i++) printf("%lld ",p[i].a-p[i].b);
	for (int k=1;k<=n;k++)
	{
		pre[k]=pre[k-1];
		if (k>y)
		{
			if (p[k].b>(q.top()).x)
			{
				pre[k]-=(q.top()).x;
				q.pop();
				pre[k]+=p[k].b;
				q.push((NODE){p[k].b});
			}
		}
		else pre[k]+=p[k].b,q.push((NODE){p[k].b});
	}
	while (!q.empty()) q.pop();
	for (int k=n;k>=1;k--)
	{
		suf[k]=suf[k+1];
		if (n-k>=x)
		{
			if (p[k].a>(q.top()).x)
			{
				suf[k]-=(q.top()).x;
				q.pop();
				suf[k]+=p[k].a;
				q.push((NODE){p[k].a});
			}
		}
		else suf[k]+=p[k].a,q.push((NODE){p[k].a});
	}
	ll re=-inf;
	for (int i=y;i<=n-x;i++) re=max(re,pre[i]+suf[i+1]);
	re+=sc;
	printf("%lld\n",re);
 	return 0;
}

Measured memory_bytes: 4984
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
	string S, T;
	cin >> S;
	cin >> T;

	int _s = S.size(), _t = T.size();
	int res = _t;
	for (int i = 0; i <= _s - _t; i++) {
		int d = 0;
		for (int j = 0; j < _t; j++) d += S[i + j] != T[j];
		res = min(res, d);
	}
	cout << res;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>

using namespace std;
using lint = long long;
#define pii = pair<int, int>;
#define vec = vector<int>;
#define pq priority_queue<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define mp(x, y) make_pair((x), (y))

constexpr lint MOD = 1e9 + 7;
// int A, B, C, F, H, I, J, K, L, M, N, S, T, U, W, X, Y;
// lint A, B, F, H, I, J, K, L, M, N, S, T, U, W, X, Y;
// int ans = 0;
// string ans;
int N, K, same, diff;
string S;

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

	cin >> N >> K >> S;
    rep(i, N - 1) {
        if (S[i] == S[i+1]) same++;
		else diff++;
    }

	cout << same + min(diff, K*2) << endl;
	return 0;
}

Measured memory_bytes: 512
// 1_m-solutions2019_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n - 2) * 180 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

ll pow5(ll n) {
	return n * n * n * n * n;
}

int main() {
	fast_io;
	ll x;
	cin >> x;
	for (ll i = -400;i <= 400;i++)
		for (ll j = -400;j <= 400;j++)
			if (pow5(i) - pow5(j) == x) {
				cout << i << ' ' << j << '\n';
				return 0;
			}
}


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

int main(){
string a,b;
cin >> a >> b;
int la = a.size();
int lb = b.size();
 //int A = atoi(a[0]);
//int B = atoi(b[0]);

if(la != lb){
	if(la > lb){
		cout << "GREATER" <<endl;
		return 0;
	}
	else if(la < lb){
		cout << "LESS" <<endl;
		return 0;
	}
	/*else{
		cout << "EQUAL" <<endl;
		return 0;
	}*/
}
  else{
int i = 0;
while(i != la){
	int AA = a[i] - '0';
	int BB = b[i] - '0';
if(AA > BB){
	cout << "GREATER" <<endl;
	return 0;
}
else if(AA==BB){
	i++;
	continue;
}
else{
	cout << "LESS" <<endl;
	return 0;
}

}
cout << "EQUAL" <<endl;
}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a % b == 0) System.out.println(a / b);
        else System.out.println(a / b + 1);
    }
}

Measured memory_bytes: 21588
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,ans,i,j;
    cin>>a;
    int fig[a];
    int answer[a];
    for(i=0;i<a;i++)
    cin>>fig[i];
    c=0;
    for(i=a;i>0;i--){
        b=fig[i-1];
        for(j=1;j<a/i;j++){
            b=b+answer[(j+1)*i-1];
        }
        b=b%2;
        answer[i-1]=b;
        if(b)
        c++;
    }
    int frag=0;
    cout<<c<<endl;
    for(i=0;i<a;i++){
        if(answer[i]){
            cout<<i+1;
            frag++;
            if(frag<c)
            cout<<" ";
        }
    }
    cout<<endl;
    
    
}


Measured memory_bytes: 2432
class SegmentTree(object):
 
    def __init__(self, size, op=min, init=float("inf")):
        self.size = 1
        self.op = op
        self.init = init
        while self.size < size:
            self.size *= 2
        self.data = [init] * (self.size*2+2)
 
    def update(self, idx, value):
        k = idx + self.size - 1
        self.data[k] = value
        while k > 0:
            k = (k - 1) // 2
            self.data[k] = self.op(self.data[k*2+1], self.data[k*2+2])
 
    def find(self, start, end):
        def query(k, left, right):
            if right <= start or end <= left:
                return self.init
            if start <= left and right <= end:
                return self.data[k]
            vl = query(k*2+1, left, (left+right)//2)
            vr = query(k*2+2, (left+right)//2, right)
            return self.op(vl, vr)
        return query(0, 0, self.size)
 

if __name__ == "__main__":
    n, q = list(map(int, input().split()))
    tree = SegmentTree(n, init=(1<<31)-1)
    for _ in range(q):
        com, x, y = list(map(int, input().split()))
        if com == 0:
            tree.update(x, y)
        else:
            print(tree.find(x, y+1))

Measured memory_bytes: 11028
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
#include<set>
using namespace std;

int main(){
  int a,c[6]={1,5,10,50,100,500},ans=0;;
  for(int i=0;i<6;i++){
    cin >> a;
    ans+=c[i]*a;
  }
  if(ans/1000!=0){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
}




Measured memory_bytes: 3112
#include<stdio.h>
#include<string.h>
typedef struct i{char f[21];int s,w;} i;
i g[10];
int n,t[10],f[10],ans[10],max;
void rec(int d)
{
	int i,w=0,G=0;
	if(d==n)
	{
		for(i=0;i<n;i++)
		{
			if(w>g[t[i]].s)
				return;
			w+=g[t[i]].w;
			G+=g[t[i]].w*(i+1);
		}
		if(max<G)
		{
			max=G;
			memcpy(ans,t,40);
		}
	}
	else
	{
		for(i=0;i<n;i++)
		{
			if(!f[i])
			{
				f[i]=1;
				t[d]=i;
				rec(d+1);
				f[i]=0;
			}
		}
	}
}

int main()
{
	int i;
	for(;;)
	{
		memset(ans,0,40);
		memset(f,0,40);
		max=0;
		scanf("%d",&n);
		if(!n)
			return 0;
		for(i=0;i<n;i++)
			scanf("%s %d%d",g[i].f,&g[i].w,&g[i].s);
		rec(0);
		while(-- n>=0)
			puts(g[ans[n]].f);
	}
	return 0;
}

Measured memory_bytes: 584
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int a,b;
int main(){
	cin>>a>>b;
	if((a+b)%2){
		puts("IMPOSSIBLE");
	}else{
		cout<<(a+b)/2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  
  long long i, n, a, sum=0, max=-1000000, min=1000000;
  
  scanf("%lld", &n);
  
  for (i = 0; i < n; i++){
    scanf("%lld", &a);
    sum = sum + a;
    if (a >= max){
      max = a;
	}
    if (a <= min){
      min = a;
    }
  }
    printf ("%lld %lld %lld\n",min, max, sum);
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

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

	if (S.size() == 2) {
		cout << 0 << endl;
	}

	for (int i = S.size() - 3; i >= 0; i -= 2) {
		string s = S.substr(0, (i + 1) / 2);
		string t = S.substr((i + 1) / 2, (i + 1) / 2);
		if (s == t) {
			cout << i + 1 << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  int n, m;
  cin >> n >> m;
  int total = 0;
  int count = 0;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    total += a[i];
  }
  
  
  for(int i = 0; i < n; i++){
    if(a[i] * 4 * m >= total) count++;
  }
  
  if(count >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
  
} 

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    char a, b; cin >> a >> b;
    if (a == 'H') cout << b << endl;
    else {
        if (b == 'H') cout << 'D' << endl;
        else cout << 'H' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    static int mod = 1000000007;
    static int k;
    static boolean[] visited;
    static List<Set<Integer>> edge;
    public static void main(String[]$) {
        int n = scanner.nextInt();
        k = scanner.nextInt();
        visited = new boolean[n];
        edge = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            edge.add(new HashSet<>());
        }

        for (int i = 1; i < n; i++) {
            int a = scanner.nextInt() - 1;
            int b = scanner.nextInt() - 1;
            edge.get(a).add(b);
            edge.get(b).add(a);
        }

        System.out.println(dfs(0, 0, 0));
    }

    static long dfs(int v, int c2, int c1) {
        visited[v] = true;
        long x = k - c2 - c1;
        int index = 0;
        for (int i : edge.get(v)) {
            if (!visited[i]) {
                x = x * dfs(i, c1 + index, 1) % mod;
                index++;
            }
        }
        return x;
    }
}

Measured memory_bytes: 121848
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int n;cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++){int t;cin>>t;a[i]=(t-i);}
	sort(a.begin(),a.end());
//  	for(auto&& w:a)cout<<w<<" ";cout<<endl;
	int m=(n-1)/2;
	int ans=0;
	for(int i=0;i<=m;i++){ans+=abs(a[n-1-i]-a[i]);}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N, K; cin >> N >> K;
    int A[100100];
    rep(i, N) cin >> A[i];
    int g = A[0];
    rep1(i, N - 1) {
        g = gcd(g, A[i]);
    }
    rep(i, N) {
        if(K > A[i]) continue;
        else if(K == A[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        } else {
            if((A[i] - K) % g == 0) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
	return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, a[3];
  cin >> n >> a[0] >> a[1] >> a[2];
  vector<string> s(n);
  for (auto&& e : s) {
    cin >> e;
  }
  string res;
  for (int t = 0; t < n; ++t) {
    int i = s[t][0] - 'A', j = s[t][1] - 'A';
    if (a[i] == 0 and a[j] == 0) {
      cout << "No\n";
      exit(0);
    }
    if (a[i] == 0) {
      ++a[i], --a[j];
      res += 'A' + i;
    } else if (a[j] == 0) {
      --a[i], ++a[j];
      res += 'A' + j;
    } else if (a[i] == 1 and a[3 ^ i ^ j] == 0 and (t + 1 < n and s[t + 1].find('A' + j) == string::npos)) {
      ++a[i], --a[j];
      res += 'A' + i;
    } else {
      --a[i], ++a[j];
      res += 'A' + j;
    }
  }
  cout << "Yes\n";
  for (auto e : res) {
    cout << e << '\n';
  }
}


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


int main(){
  int N;
  cin >> N;
  vector<int> DP(N);
  vector<int> hs(N);
  for(int i=0; i<N; i++){
    cin >> hs[i];
  }
  DP[0] = 0;
  DP[1] = abs(hs[0]-hs[1]);
  for(int i=2; i<N; i++){
    DP[i] = min(abs(hs[i]-hs[i-1])+DP[i-1], abs(hs[i]-hs[i-2])+DP[i-2]);
  }
  cout << DP[N-1] << endl;
}

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

int main()
{
    int r;
    cin >> r;
    double ans = 2 * r * M_PI;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3784
fun main(args: Array<String>) {
    val inStr = readLine()
    val n = inStr?.toInt() ?: return
    call(n)
}

fun call(n:Int) {
    for (i:Int in 1..n) {
        var x:Int = i
        if ( (x % 3) == 0) {
            print(" ${i}")
        } else{
            do {
                if ((x % 10) == 3) {
                    print(" ${i}")
                    break;
                }
                x /= 10
            } while ((x != 0))
        }
    }

    println()
}



Measured memory_bytes: 27996
#include <iostream>
#include <string>
#include <set>
#include <algorithm>

#define INF 1e9
using namespace std;


void solve()
{
	int W, a, b;
	cin >> W >> a >> b;
	if ((a <= b && b <= a + W) || (a <= b + W && b + W <= a + W))
	{
		cout << 0 << endl;
	}
	else
	{
		int left = INF;
		int right = INF;
		if (b > a + W)
		{
			left = b - a - W;
		}
		if (b + W < a)
		{
			right = a - b - W;
		}
		cout << min(left, right) << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,m;
  cin >> n >> k;
  if(k > ((n-1)*(n-2))/2)cout << -1 << endl;
  else{
    int num;
    vector<vector<int>> path(n+1,vector<int>(n+1,0));
    for(int i = 2;i <= n;i++){
      path[1][i] = 1;
    }
    m = n-1;
    int l = ((n-1)*(n-2))/2;
    for(int i = 2;i <= n;i++){
      for(int j = i+1;j <= n;j++){
        if(l == k)break;
        path[i][j] = 1;
        l--;
        m++;
      }
      if(l == k)break;
    }
    cout << m << endl;
    for(int i = 1;i <= n;i++){
      for(int j = i+1;j <= n;j++){
        if(path[i][j] == 1)cout << i << " " << j << endl;
      }
    }
  }
}


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

using ll = long long;
using P = pair<ll, ll>;
const double EPS = 1e-12;
const ll INF = numeric_limits<ll>::max() / 2;
const ll MOD = 1e9 + 7;

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

    string s;cin>>s;
    vector<int> cnt(26,0);
    for(int i=0;i<(int)s.length();i++){
        cnt[s[i]-'a']++;
    }
    if(s.length()<26){
        for(int i=0;i<26;i++){
            if(cnt[i]==0){
                char c='a'+i;
                cout<<s+c<<endl;
                return 0;
            }
        }
    }
    else{
        if(s=="zyxwvutsrqponmlkjihgfedcba") cout<<-1<<endl;
        else{
            vector<string> v;
            vector<int> used(26,0);
            for(int i=0;i<26;i++){
                string tmp=s.substr(0,i);
                used[s[i]-'a']=1;
                int idx=s[i]-'a';
                for(int j=idx+1;j<26;j++){
                    if(!used[j]){
                        char c='a'+j;
                        tmp+=c;
                        v.push_back(tmp);
                        //cout<<tmp<<endl;
                        break;
                    }
                }
            }
            sort(v.begin(),v.end());
            cout<<v[0]<<endl;
        }
    }
}


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

int main(){
	int n, t, dum, unsorted, flag;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i != n; i++) cin >> a[i];

	unsorted = 0;
	flag = 1;
	t = 0;
	while(flag){
		flag = 0;
		for (int j = n - 1; j != unsorted; j--){
			if (a[j - 1] > a[j]){
				dum = a[j - 1];
				a[j - 1] = a[j];
				a[j] = dum;
				flag = 1;
				t++;
			}
		}
		unsorted++;
	}

	for (int i = 0; i != n; i++) cout << (i == 0 ? "" : " ") << a[i];
	cout << endl << t << endl;
}


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

int main(){
    ll h, n;
    cin >> h >> n;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        sum += a;
    }
    if(sum >= h) cout << "Yes";
    else cout << "No";
}

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

long long n;
long long memo[5001][10001];
bool tag[5001][10001];
const long long mod = 1000000007;
const long long invtwo = 500000004;
long long dp(long long i, long long j)//i=押したキー回数　j=現在のカーソル位置
{
	if (i < j)return 0;
	if (i == 0)
	{
		if (j == 0)return 1;
		return 0;
	}
	if (tag[i][j])return memo[i][j];
	long long ret = 0;
	if (j == 0)
	{
		ret += dp(i - 1, j);
		ret += dp(i - 1, j + 1);
	}
	else
	{
		ret += dp(i - 1, j + 1);
		ret += dp(i - 1, j - 1) * 2;
	}
	ret %= mod;
	tag[i][j] = true;
	return memo[i][j] = ret;
}

int main(void)
{
	cin >> n;
	string s;
	cin >> s;
	memset(tag, false, sizeof(tag));
	long long ans = dp((long long)n, s.size());
	for (long long i = 0; i < s.size(); ++i)
	{
		ans *= invtwo;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 134528
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long temp [] = new long[2001];
		long ans[] = new long[4001];
		for(int i = 0; i < 1001; i++){
			for(int j = 0; j < 1001; j++){
				temp[i + j]++;
			}
		}
		for(int i = 0; i < 2001; i++){
			for(int j = 0; j < 2001; j++){
				ans[i + j] += temp[i] * temp[j];
			}
		}
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			System.out.println(ans[n]);
		}
		
	}
}

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

int main() {
  
  int N, Ans=1, cnt=0, max=0;
  cin >> N;
  for(int i=1; i<=N; i++){
    cnt=0;
    if(i%2!=0) continue;
    else if(i%2==0){
      int j=i;
      while(j%2==0){
        cnt++;
        j/=2;
      }
      if(max<cnt){
        max=cnt;
        Ans=i;
      }
    }
  }
  cout << Ans << endl;
}

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

using namespace std;

int n, a[105], ans;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    ans=n;
    sort(a+1,a+n+1);
    if (n==1) cout << 1;
    else
    {
        for (int i = 2; i <= n; i++)
            if (a[i-1]==a[i]) ans--;
        cout << ans;
    }
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

const MOD = 1000000007

func main() {
	sc.Split(bufio.ScanWords)

	N, M := nextInt(), nextInt()

	if abs(N-M) > 1 {
		fmt.Println(0)
		return
	}

	n := N
	for i := n - 1; i >= 1; i-- {
		n = n * i % MOD
	}

	m := M
	for i := m - 1; i >= 1; i-- {
		m = m * i % MOD
	}

	if n == m {
		fmt.Println(n * m * 2 % MOD)
	} else {
		fmt.Println(n * m % MOD)
	}

}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	}
	return a
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double counter = 0;
        for (int i=1; i<=N; i++) {
            if (i%2==1) {
                counter++;
            }
        }
        System.out.println(counter/N);
    }
}



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

using lint = long long;
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

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

  bool can = false;
  for (lint i = 0; i < s.size(); i++) {
    string ss;
    ss = s.substr(s.size() - i, i) + s.substr(0, s.size() - i);
    if (ss == t) {
      can = true;
    }
  }

  if (can) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256