akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N, K;
  cin >> N >> K;
  vi32 P(N);
  cin >> P;
  int ans = 0;
  vi32 nochange(N);
  {
    vi32 acc(N);
    rep(i, N - 1) {
      if (P[i] < P[i + 1]) {
        acc[i + 1] = acc[i] + 1;
      } else {
        acc[i + 1] = acc[i] - 1;
      }
    }
    for (int i = 0; i + K <= N; i++) {
      if (acc[i + K - 1] - acc[i] == K - 1) {
        nochange[i] = 1;
        if (ans == 0) ans = 1;
      }
    }
  }
  set<int> sasc;
  set<int, greater<int>> sdsc;
  for (int i = 0; i < N; i++) {
    sasc.insert(P[i]);
    sdsc.insert(P[i]);
    if (sasc.size() == K && nochange[i - K + 1] == 0) {
      ans++;
    }
    if (sasc.size() > K) {
      if ((*sasc.begin() == P[i - K]) && (*sdsc.begin() == P[i])) {
      } else if (nochange[i - K + 1]) {
      } else {
        ans++;
      }
      sasc.erase(P[i - K]);
      sdsc.erase(P[i - K]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 20592
import java.util.*;
public class Main {
    public static int howManyTwos(int a) {
        int res = 0;
        while (a % 2 == 0) {
            a /= 2;
            res++;
        }
        return res;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int twos = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            twos += howManyTwos(a);
        }
        System.out.println(twos);
    }
}

Measured memory_bytes: 34632
import sys
input=sys.stdin.readline
n=int(input())
H=list(map(int,input().split()))
DP=[0]*n
DP[1]=abs(H[1]-H[0])
for i in range(2,n):
    DP[i]=min(DP[i-1]+abs(H[i]-H[i-1]),DP[i-2]+abs(H[i]-H[i-2]))
print(DP[-1])

Measured memory_bytes: 50288
import java.util.*;
public class Main{
    public static void main(String args[]) {
        Scanner cin = new Scanner(System.in);
        while(cin.hasNext()){
        	String a = cin.next();       	
        	System.out.println(getResult(a));
        }
    }
    public static long getResult(String s){
    	long[] f = f(s.length());
    	long result=0;
    	int len = s.length();
    	for(int l=1;l<=len;l++){
    		for(int p=0;p<len+1-l;p++){
        		result += f[p]*f[len-l-p]*Long.parseLong(s.substring(p, p+l));
        	}
    	}
    	return result;
    }
    public static long[]  f(int n){
    	long[] f = new long[n+1];
    	f[0] = 1;
    	for(int i=1;i<=n;i++) f[i] = (long)Math.pow(2.0, (double)(i-1));
    	return f;
    }
}

Measured memory_bytes: 9684
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int h,w,c,ans;
int t[10][10];

void check(){
  int cnt=0,flg[10][10];
  for(int i=0;i<10;i++)for(int j=0;j<10;j++)flg[i][j]=false;
  queue<int> qy,qx;
  qy.push(0);qx.push(0);
  while(!qy.empty()){
    int y=qy.front();qy.pop();
    int x=qx.front();qx.pop();
    if(y<0||x<0)continue;
    if(y>=h||x>=w)continue;
    if(flg[y][x])continue;
    if(t[y][x]!=c)continue;
    cnt++;
    flg[y][x]=true;
    for(int i=0;i<4;i++)qy.push(y+dy[i]),qx.push(x+dx[i]);
  }
  ans=max(ans,cnt);
}

void solve(int depth){
  if(depth==5)check();
  else{

    int flg[10][10];
    for(int i=0;i<10;i++)for(int j=0;j<10;j++)flg[i][j]=0;
    queue<int> qy,qx;
    qy.push(0);qx.push(0);
    while(!qy.empty()){
      int y=qy.front();qy.pop();
      int x=qx.front();qx.pop();
      if(y<0||x<0)continue;
      if(y>=h||x>=w)continue;
      if(flg[y][x]!=0)continue;
      if(t[y][x]!=t[0][0])continue;
      flg[y][x]=t[y][x];
      for(int i=0;i<4;i++)qy.push(y+dy[i]),qx.push(x+dx[i]);
    }
    for(int I=1;I<=6;I++){
      if(I==flg[0][0])continue;
      for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	  if(flg[i][j]!=0)t[i][j]=I;
      solve(depth+1);
    }
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(flg[i][j]!=0)t[i][j]=flg[i][j];
  }
}
int main(){
  while(1){
    cin>>h>>w>>c;
    if(h==0&&w==0&&c==0)break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	cin>>t[i][j];
    ans=0;
    solve(0);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	char c;
	cin >> c;
	printf("%c", c+1);
	return 0;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())
x //= 50
ans=0
for i in range(a+1):
    if 10*i<=x:
        for j in range(b+1):
            if 10*i+2*j<=x:
                if 10*i+2*j+c>=x: ans +=1
print(ans)

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    double w, h, x, y;
    cin >> w >> h >> x >> y;
    printf("%.10f %d\n", w * h / 2, (w == 2 * x && h == 2 * y ? 1 : 0));

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    string s;
	int a=0;
    cin>>s;
    for(int i=0;s[i]!='\0';++i){
    	if(s[i]=='C'){
    		a=1;
		}
		if(a==1){
			if(s[i]=='F'){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    long long res=0;
	char ch=getchar();
    while(!isdigit(ch))
	ch=getchar();
    while(isdigit(ch))
	res=(res<<3)+(res<<1)+ch-'0',ch=getchar();
    return res;
}
void print(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x<10)
    putchar(x+'0');
    else
    {
        print(x/10);
        putchar(x%10+'0');
    }
}
string reverse(string x)
{
	string ans;
	for(int k=x.length()-1;k>=0;k--)
	{
		ans+=x[k];
	}
	return ans;
}
string hhh(string x)
{
	string ans;
	for(int k=0;k<x.length();k++)
	{
		switch(x[k])
		{
			case 'b':
			{
				ans+='d';
				break;
			}
			case 'd':
			{
				ans+='b';
				break;
			}
			case 'p':
			{
				ans+='q';
				break;
			}
			case 'q':
			{
				ans+='p';
				break;
			}
		}
	}
	return ans;
}
int main()
{
	string s;
	cin>>s;
	if(s==hhh(reverse(s)))
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 768
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <vector>
#include <iostream>
#include <ctime>
#include <unistd.h>

using namespace std;

#define TRACE(x) cerr << #x <<  " = " << x << endl
#define _ << " " <<
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

#define X first
#define Y second

typedef pair<int, int> P;
typedef long long ll;

const int MAX = 1<<18;

double PI = acos(-1);
P poc, kraj;
vector <P> V;
int dp[MAX];

int unutra(P tmp) {
  return (tmp.X >= poc.X && tmp.X <= kraj.X &&
	  tmp.Y >= poc.Y && tmp.Y <= kraj.Y);
}

int main()
{
  scanf("%d%d%d%d", &poc.X, &poc.Y, &kraj.X, &kraj.Y);
  int n;
  scanf("%d", &n);

  REP(i, n) {
    P tmp;
    scanf("%d%d", &tmp.X, &tmp.Y);
    V.push_back(tmp);
  }
  
  if (poc.X > kraj.X)
    swap(poc, kraj);

  if (poc.Y > kraj.Y) {
    poc.Y = -poc.Y;
    kraj.Y = -kraj.Y;
    REP(i, n) V[i].Y *= -1;
  }

  sort(V.begin(), V.end());
  REP(i, MAX) dp[i] = 1e9;
  dp[0] = -1e9;

  for (auto it : V) {
    if (!unutra(it)) continue;
    int lo = 0, hi = MAX-5;
    for (; lo<hi; ) {
      int mid = (lo + hi + 1) / 2;
      if (dp[mid] < it.Y) lo = mid;
      else hi = mid - 1;	
    }

    dp[lo+1] = it.Y;
  }

  int kol = 0;
  REP(i, MAX)
    if (dp[i] != 1e9)
      kol = i;

  double rje = 100.0 * (kraj.Y - poc.Y + kraj.X - poc.X);
  double koef = 10 * (PI/2 - 2);

  TRACE(rje);
  
  if (kol == min(kraj.Y - poc.Y, kraj.X - poc.X) + 1) {
    rje += koef * (kol - 1);
    rje += 10.0 * (PI - 2);
  }
  else
    rje += koef * kol;

  printf("%.15lf\n", rje);    

  return 0;
}


Measured memory_bytes: 2928
#include<iostream>
#include<algorithm>
#include<queue>
#include<algorithm>

using namespace std;
int N, R, T;
priority_queue<pair<int, int>> pq;
int score[1000000], total_time[1000000];
int beforetime = 0, nowteam = 0;

int main() {
	cin >> N >> R >> T;
	for (int i = 0; i < N; i++)pq.push(make_pair(0, -i));
	for (int i = 0; i < R; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		score[a - 1] += c;
		pq.push(make_pair(score[a - 1], -(a - 1)));

		while (1) {
			if (pq.top().first == score[-pq.top().second]) {
				//????????¢????????´???????????§?????????
				//pq.top().second???pq???????§?????????????????????????
				//????????§????????¢??¨?????´????????????????????????????????????????????????(????????¢???????°????????????????????????????)
				//?????§???????????????????????????????¬???§??´??°??????????????¨?????????????????´??°???????????????
				total_time[nowteam] += (b - beforetime);
				beforetime = b;
				nowteam = -pq.top().second;
				break;
			}
			pq.pop();
		}
	}
	total_time[nowteam] += (T - beforetime);
	cout << (max_element(total_time, total_time + N) - total_time) + 1 << endl;
	return 0;
}

Measured memory_bytes: 11712
#include <bits/stdc++.h>
 
using namespace std;
 
#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)
#define lt(a,b) (a-b < -EPS)
 
struct Point{
    double x,y;
 
    Point(){}
    Point(double x,double y) : x(x),y(y) {}
 
    Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
    Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
    Point operator * (const double &k)const{ return Point(x*k,y*k); }
    Point operator / (const double &k)const{ return Point(x/k,y/k); }
    bool operator < (const Point &p)const{ return x != p.x ? x < p.x : y < p.y; }
};
 
double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double norm(const Point &p){ return dot(p,p); }
 
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;
 
int ccw(Point p0,Point p1,Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a,b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a,b) < -EPS) return CLOCKWISE;
    if(dot(a,b) < -EPS) return ONLINE_BACK;
    if(norm(a) < norm(b)) return ONLINE_FRONT;
    return ON_SEGMENT;
}
 
struct Segment{
    Point s,t;
    Segment(){}
    Segment(Point s,Point t) : s(s),t(t) {}
};
 
typedef Segment Line;
 
Point crosspointLL(const Line &a,const Line &b){
    Vector va = a.t-a.s, vb = b.t-b.s;
    double d = cross(vb,va);
    if(abs(d) < EPS) return b.s;
    return a.s+va*cross(vb,b.t-a.s)*(1.0/d);
}
 
#define curr(G,i) (G[i%G.size()])
#define next(G,i) (G[(i+1)%G.size()])
typedef vector<Point> Polygon;
 
Polygon convex_cut(const Polygon &pg,const Line &l){
    Polygon res;
    for(int i = 0 ; i < (int)pg.size() ; i++){
	Point cp = curr(pg,i), np = next(pg,i);
	if(ccw(l.s,l.t,cp) != -1){ res.push_back(cp); }
	if(ccw(l.s,l.t,cp)*ccw(l.s,l.t,np) < 0){
	    res.push_back(crosspointLL(Line(cp,np),l));
	}
    }
    return res;
}
 
int main(){
    int N;
    while(cin >> N, N){
	Polygon pg(N);
	for(int i = 0 ; i < N ; i++){
	    cin >> pg[i].x >> pg[i].y;
	}
	Polygon pg2;
	pg2.push_back(Point(0,0));
	pg2.push_back(Point(10000,0));
	pg2.push_back(Point(10000,10000));
	pg2.push_back(Point(0,10000));
	for(int i = 0 ; i < N ; i++){
	    Line l = Line(curr(pg,i),next(pg,i));
	    pg2 = convex_cut(pg2,l);
	}
	cout << (pg2.size() > 0 ? 1 : 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
 #define all(v) (v).begin(),(v).end()
 using ll = long long;
using Graph = vector<vector<int>>;
const int MAX = 510000;
const int MOD = 1000000007;



int main(){
ll N;
  cin>>N;
  ll dp[N];
  rep(i,N) cin>>dp[i];
  ll ans[N];
  ll gh=0;
  rep(i,N){
  if(i%2==0) gh=gh+dp[i];
  else gh=gh-dp[i];
  } 
  ans[0]=gh;
  rep(i,N-1){
  ans[i+1]=dp[i]*2-ans[i];
  
  }
  rep(i,N) cout<<ans[i]<<' '; 
  }
 





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

int main(){
  int e[101],hoge=0;
  for(int i=0;i<12;i++){
    cin >> e[i];
  }
  sort(e,e+12);
  for(int i=0;i<12;i+=4){
    if(e[i]==e[i+1] && e[i+1]==e[i+2] && e[i+2]==e[i+3]){
      hoge++;
    }
  }
  if(hoge==3){
    cout << "yes\n";
  }else{
    cout << "no\n";
  }
  return 0;
}



Measured memory_bytes: 3176
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)
    h,w=map(int, readline().rstrip().split())
    masu=[]
    count=[[-1 for i in range(w)] for j in range(h)]
    for i in range(h):
        masu.append(readline().rstrip())

    if masu[0][0]=="#":
        count[0][0]=1
    else:
        count[0][0]=0

    for y in range(h):
        for x in range(w):
            if y==0 and x==0:
                continue

            left=999999
            up=999999
            if x > 0: # get left
                if masu[y][x]==".":
                    left=count[y][x-1]
                else: #
                    if masu[y][x-1]==".":
                        left=count[y][x-1]+1
                    else:
                        left=count[y][x-1]
            if y > 0: # get up
                if masu[y][x]==".":
                    up=count[y-1][x]
                else: #
                    if masu[y-1][x]==".":
                        up=count[y-1][x]+1
                    else:
                        up=count[y-1][x]
            count[y][x]=min(left,up)
    print(count[h-1][w-1])
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 53100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
    int N;
    cin >> N;

    vector<int> v;

    int nine=0;
    while(N>=pow((double)9,nine+1)) {
        v.push_back((int)pow((double)9,nine+1));
        nine++;
    }
    int six=0;
    while(N>=pow((double)6,six+1)) {
        v.push_back((int)pow((double)6,six+1));
        six++;
    }
    v.push_back(1);
    sort(v.begin(),v.end(),greater<int>());
    vector<int> dp(N+1, 10000000);
    dp[0] = 0;

    for(int i = 0; i <= N; ++i){
        for(int j = 0; j < v.size(); ++j){
            if(i - v[j] >= 0){
                dp[i] = min(dp[i - v[j]] + 1, dp[i]);
            }
        }
    }

    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N, W;
int x[1000];
int sum[1001];
int memo[1001][1001];
int CASE;
int dfs(int idx, int e){
  int& res = memo[idx][e];
  if(~res) return res;
  int s = sum[idx] - sum[idx - e];
  if(idx == N){
    return max(0, s - W);
  }
  res = dfs(idx + 1, e + 1);
  res = min(res, abs(s + x[idx] - W) + dfs(idx + 1, 0));
  return res;
}

int main(){
  CASE = 1;
  while(cin>>N>>W && N){
    printf("Case %d: ", CASE++);
    memset(sum, 0, sizeof(sum));
    memset(memo, -1, sizeof(memo));
    REP(i, N) cin>>x[i];
    REP(i, N) sum[i + 1] = sum[i] + x[i];
    cout<<dfs(0, 0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

string S[14];
int H, W;

int row_match[14];
// int row_match[14] = {5, 8, 6, 4, 3, 0, 2, 9, 1, 7, 11, 10};

bool make_col_match(){
    int bit = 0;
    bool is_odd = W % 2 == 1;
    for(int k=0;k<W;k++){
        if((bit>>k)&1) continue;

        bool added = false;
        for(int l=k+1;l<W;l++){
            if((bit>>l)&1) continue;
            bool ok = true;
            for(int i=0;i<H;i++){
                if(!(S[i][k] == S[row_match[i]][l] && S[i][l] == S[row_match[i]][k])){
                    ok = false;
                    break;
                }
            }
            if(ok){
                bit |= (1 << k);
                bit |= (1 << l);
                added = true;
                break;
            }
        }

        if(!added && is_odd){
            bool ok = true;
            for(int i=0;i<H;i++){
                if(S[i][k] != S[row_match[i]][k]){
                    ok = false;
                    break;
                }
            }
            if(ok){
                added = true;
                is_odd = false;
                bit |= (1 << k);
            }
        }

        if(!added) {
            return false;
        }
    }
    return true;
}

bool make_row_match(int bit, bool is_odd){
    if(bit == (1 << H) - 1) return make_col_match();

    int i = 0;
    while((bit>>i)&1) i++;

    if(is_odd){
        row_match[i] = i;
        if(make_row_match(bit | (1 << i), false)) return true;
    }

    for(int j=i+1;j<H;j++){
        if((bit>>j)&1) continue;
        row_match[i] = j;
        row_match[j] = i;
        if(make_row_match(bit | (1 << i) | (1 << j), is_odd)) return true;
    }

    return false;
}

int main(){
    cin >> H >> W;

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

    if(make_row_match(0, H % 2 == 1)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int main(){
    long long n;
    long long drops = 0;
    scanf("%lld", &n);
    long long onemove = n;
    onemove *= n + 1;
    onemove /= 2;
    long long tal = 0;
    long long val[n];
    for(long long i = 0; i < n; i++){
        scanf("%lld", &val[i]);
        tal += val[i];
    }
    if(tal % onemove != 0){
        printf("NO");
        return 0;
    }
    long long mves = tal / onemove;
    for(long long i = 0; i < n-1; i++){
        long long diff = val[i] - val[i+1];
        diff += mves;
        if(diff % n != 0 || diff < 0){
            printf("NO");
            return 0;
        }
        //printf("%lld\n", diff);
        drops += diff / n;
    }
    long long diff = val[n-1] - val[0];
    diff += mves;
    drops += diff / n;
    //printf("%lld %lld\n", mves, drops);
    if(diff % n != 0 || drops > mves || (mves-drops) % n != 0){
        printf("NO");
        return 0;
    }
    printf("YES");
    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N,K; vi p,q;
void input()
{
    cin>>N>>K;
    rep(i,N){
        int a; cin>>a; p.emplace_back(a);
    }
    return;
}

void solve()
{
    q.emplace_back(0);
    rep(i,N){
        q.emplace_back(q[i]+p[i]);
    }
    int ma=0;
    rep(i,N-K+1){
        ma=max(ma,q[K+i]-q[i]);
    }
    float ans=1.0/2.0*(ma+K);
    // cout<<ans<<setprecision(10)<<fixed<<endl;
    printf("%.10f\n",ans);
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	vector<vector<int>> a(3, vector<int>(3)), c(3, vector<int>(3, -1));
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> a[i][j];
		}
	}
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int b;
		cin >> b;
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (a[j][k] == b) {
					c[j][k] = 1;
				}
			}
		}
	}

	bool ok = false;
	for (int i = 0; i < 3; ++i) {
		bool tmp = true;
		for (int j = 0; j < 3; ++j) {
			if (c[i][j] < 0) { tmp = false; }
		}
		if (tmp) { ok = true; }
	}
	for (int i = 0; i < 3; ++i) {
		bool tmp = true;
		for (int j = 0; j < 3; ++j) {
			if (c[j][i] < 0) { tmp = false; }
		}
		if (tmp) { ok = true; }
	}
	if (c[0][0] > 0 && c[1][1] > 0 && c[2][2] > 0) { ok = true; }
	if (c[2][0] > 0 && c[1][1] > 0 && c[0][2] > 0) { ok = true; }

	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int c[5003][5003], d[5003][5003];

int main() {
    ios::sync_with_stdio(false);
    int n, p[5003] = {};
    ll a, b, z[5003];
    cin >> n >> a >> b;
    fr1(n) cin >> p[i];
    fr1(n) for (int j = 1; j <= n; j++) c[i][j] = c[i - 1][j] + (p[i] < j), d[i][j] = d[i - 1][j] + (p[i] > j);
    fr1(n) z[i] = a * (i - 1);
    fr1(n) for (int j = 1; j < i; j++) if (p[i] > p[j]) z[i] = min(z[i], z[j] + b * (c[i - 1][p[j]] - c[j][p[j]]) + a * (d[i - 1][p[i]] - d[j][p[i]]) + min(a, b) * (i - j - 1 - c[i - 1][p[j]] + c[j][p[j]] - d[i - 1][p[i]] + d[j][p[i]]));
    fr1(n) z[i] += b * (n - i);
    //fr1(n) cout << z[i] << ' ';
    fr1(n) z[n] = min(z[n], z[i]);
    cout << z[n];
}


Measured memory_bytes: 195840
#include "bits/stdc++.h"

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
//#define int long long;
signed main() {
  string a;
  cin >> a;
  int d = 0;
  int c = 0;
  for (int i = 0; i < a.length(); i++) {
    if (a[i] == 'A' or a[i] == 'C' or a[i] == 'G' or a[i] == 'T') {
      d++;
    } else {
      c = max(d, c);
      d = 0;
    }
  }
  c = max(d, c);
  cout << c;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の
string型配列と同じような感じ） map<int, string> mp; for (auto itr =mp.begin();
itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


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

vector<int> fact, ifact;
const int d = 1000000007;

int comb(int n, int k) {
  if(n < k) return 0;
  return (((ll(fact[n]) * ifact[k]) % d) * ifact[n-k]) % d;
}

int pow(int n, int r) {
  if(r == 0) return 1;
  int p = pow(n, r / 2);
  int ans = (ll(p) * p) % d;
  if(r % 2 == 1) ans = (ll(ans) * n) % d;
  return ans;
}

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

  int di0;
  int di1;
  vector<int> found(n+1, -1);
  rep(i,n+1) {
    int a;
    cin >> a;
    if(found[a] != -1) {
      di0 = found[a];
      di1 = i;
    }
    found[a] = i;
  }

  fact = vector<int>(n+2, 1);
  ifact = vector<int>(n+2, 1);
  for(int i = 1; i <= n + 1; i++) fact[i] = (ll(i) * fact[i-1]) % d;

  ifact[n+1] = pow(fact[n+1], d-2);
  for(int i = n; i >= 0; i--)  ifact[i] = (ll(i+1) * ifact[i+1]) % d;

  for(int i = 1; i <= n+1; i++) {
    cout << (comb(n+1, i) - comb(di0 + n - di1, i - 1) + d) % d << endl;
  }

  return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N;
vec<int> ss, nn;

void init() {
   for (int i = 6; i <= N; i*=6) {
      ss.push_back(i);
   }
   for (int i = 9; i <= N; i*=9) {
      nn.push_back(i);
   }
}

int six(int n) {
   int ret = 0;
   sort(all(ss), greater<int>());
   while (1) {
      bool ok = false;
      rep (i, ss.size()) {
         if (ss[i] <= n) {
            n -= ss[i];
            ok = true;
            ret++;
            break;
         }
      }
      if (!ok) {
         return ret + n;
      }
   }
}

int nine(int n) {
   int ret = 0;
   sort(all(nn), greater<int>());
   while (1) {
      bool ok = false;
      rep (i, nn.size()) {
         if (nn[i] <= n) {
            n -= nn[i];
            ok = true;
            ret++;
            break;
         }
      }
      if (!ok) {
         return ret + n;
      }
   }
}

int main() {
   cin >> N;
   init();
   int ans = 1e8;
   for (int i = 0; i <= N; i++) { // i: 6
      int j = N - i; // j: 9
      int a = six(i), b = nine(j);
      ans = min(ans, a+b);
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
         
     try (Scanner scan = new Scanner(System.in)) {
			int inputN = scan.nextInt();
			int inputQ = scan.nextInt();
			int[] memory = new int[inputN+1];
       		memory[0] = 0;
			String inputStr = scan.next();
			
			for(int n=2; n < inputN+1; n++) {
				memory[n] = memory[n-1];
				if('A'==(inputStr.charAt(n-2)) && 'C'==(inputStr.charAt(n-1))) {
					memory[n]++;
				}
			}
			
			List<Integer> ans = new ArrayList<>();
			
			for (int i = 0; i < inputQ; i++) {
				int inputI = scan.nextInt();
				int inputR = scan.nextInt();
				ans.add(memory[inputR]-memory[inputI]);
			}
			
			for (int i = 0; i < inputQ; i++) {
				System.out.println(ans.get(i));
			
			}
		}
    }
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

void func(long long N, std::vector<long long> x, std::vector<long long> y){

    std::mt19937 mt32(0);

    double best = 1e9;
    double bestX = 500;
    double bestY = 500;

    double dist = 1;
    REP(_,0,2000000){
        dist *= 0.99999;
        double tempX = bestX + dist * ( ((lli)mt32()%1001) - 500);
        double tempY = bestY + dist * ( ((lli)mt32()%1001) - 500);
        LOG2(tempX,tempY);
        double now = 0;
        REP(i,0,N){
            double diffX = tempX - x[i];
            double diffY = tempY - y[i];
            now = max(now,sqrt(diffX*diffX+diffY*diffY));
        }
        if(now<best){
            best=now;
            bestX = tempX;
            bestY = tempY;
        }
   }

    cout<<setprecision(15);
    cout<<best<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    func(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String n = sc.next();
      
      	if(n.charAt(0) == n.charAt(1) 
           && n.charAt(0) == n.charAt(2)){
        	System.out.println("Yes");
        }else if(n.charAt(1) == n.charAt(2) 
           && n.charAt(1) == n.charAt(3)){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
    }
}

Measured memory_bytes: 35608
#include<stdio.h>

static const int MIN = 1;
static const int MAX = 10*10*10*10*10*10*10*10*10;

int main(){
  int a,b,temp,rest;

  scanf("%d", &a);
  scanf("%d", &b);

  if(b > a){
    temp = b;
    b = a;
    a = temp;
  }

  while(1){

    rest = a%b;

    if(rest == 0){
      printf("%d\n",b);
      break;
    }

    if(rest != 0){
      a = b;
      b = rest;
    }
  }

  return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n,l;cin >>n>>l;
    vector<string>s(n);
    for (int i = 0; i < n; ++i) {
        cin >>s[i];
    }
    sort(all(s));
    string ans="";
    for (int i = 0; i < n; ++i) {
        ans+=s[i];
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 3544
a, b, c, x = [int(x) for x in [input() for i in range(4)]]
idx = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                idx += 1
print(idx)

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  long dp[n+1][13];
  for(int i = 1;i <= n;i++){
    for(int j = 0;j < 13;j++){
      dp[i][j] = 0;
    }
  }
  long inf = 1000000007;
  int kai10 = 1;
  if(s.at(n-1) != '?'){
    dp[1][s.at(n-1) - '0'] = 1;
  }
  else{
    for(int i = 0;i <= 9;i++){
      dp[1][i] = 1;
    }
  }
  //文字列アクセス注意
  //cout << 666 << endl;
  for(int i = 2;i <= n;i++){
    kai10 *= 10;
    kai10 %= 13;
    if(s.at(n-i) != '?'){
      int num = s.at(n-i) - '0';
      int d = num*kai10;
      d %= 13;
      for(int j = 0;j < 13;j++){
        dp[i][(j+d)%13] = dp[i-1][j];
        //cout << i << ' ' << (j+d)%13 << ' ' << dp[i][(j+d)%13] << endl;
      }
    }
    else{
      for(int j = 0;j <= 9;j++){
        int d = j*kai10;
        d %= 13;
        for(int k = 0;k < 13;k++){
          dp[i][(d+k)%13] += dp[i-1][k];
          dp[i][(d+k)%13] %= inf;
          //cout << i << ' ' << (d+k)%13 << ' ' << dp[i][(d+k)%13] << endl;
        }
      }
    }
  }
  cout << dp[n][5] << endl;
}

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

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

    if(A % 3 == 0){
        cout << "Possible";
        return 0;
    }else if(B % 3 == 0){
        cout << "Possible";
        return 0;
    }else if((A+B) % 3 == 0){
        cout << "Possible";
        return 0;
    }
    cout << "Impossible";
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;

int main() {
    string s;
    cin>>s;
    cout<<(s[2]==s[3]&&s[4]==s[5] ? "Yes":"No")<<endl;
}


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

void fnInput(vector<int>& rvnEntry)
{
  int nEntrySiz;
  cin >> nEntrySiz;
  rvnEntry.resize(3 * nEntrySiz);

  for (int& rnEntry : rvnEntry)
    cin >> rnEntry;

  sort(begin(rvnEntry), end(rvnEntry), greater<int>());
}

llong fnStrengthChk(const vector<int>& cnrvnEntry)
{
  llong nStrength = 0;
  int nEntrySiz = cnrvnEntry.size() * 2 / 3;

  for (int n = 0; n < nEntrySiz; n++)
    if (n % 2 == 1)  nStrength += cnrvnEntry[n];

  return nStrength;
}

int main()
{
  vector<int> vnEntry;

  fnInput(vnEntry);
  cout << fnStrengthChk(vnEntry) << endl;

  return 0;
}

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


public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int num1 = scan.nextInt();
        int num2 = scan.nextInt();
        if(num1 < num2) System.out.println(0);
        else            System.out.println(10);

    }
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int sieve(int n) {
    int p = 0;
    vector<bool> prime(n + 1, true);
    prime[0] = prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (prime[i]) {
            p++;
            for (int j = i * 2; j <= n; j += i) prime[j] = false;
        }
    }
    return p;
}

int main()
{
    int n;
    while (scanf("%d", &n) != EOF) {
        cout << sieve(n) << endl;
    }
    return 0;
}


Measured memory_bytes: 3244
#include<stdio.h>
int main()
{
	int x,y;
	scanf("%d %d",&x,&y);
	while(x!=0||y!=0)
	{
		if(x>y)
		printf("%d %d",y,x);
		else
		printf("%d %d",x,y);
		printf("\n");
		scanf("%d %d",&x,&y);
	}
	return 0;
} 


Measured memory_bytes: 2568
ans = 0
while True:
    num = list(map(str,input().split()))
    if(num[1] == "?"): break
    a = int(num[0])
    b = int(num[2])
    op = num[1]
    if(op == "+"): ans=a+b
    elif(op == "-"): ans=a-b
    elif(op == "*"): ans=a*b
    elif(op == "/"): ans=a/b
    
    print("%d" %ans)


Measured memory_bytes: 5596
#include <iostream>
#include <iomanip>

int main() {
  unsigned long n, m, d;

  std::cin >> n;
  std::cin >> m;
  std::cin >> d;

  double const ans =
    static_cast<double>((m-1) * (n-d) * (d==0?1:2)) /
    static_cast<double>(n * n);

  std::cout << std::setprecision(9) << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String... args) {

		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		sc.close();



		if (str.matches("k.*eyence")) {
			System.out.println("YES");
			return;
		}

		if (str.matches("ke.*yence")) {
			System.out.println("YES");
			return;
		}

		if (str.matches("key.*ence")) {
			System.out.println("YES");
			return;
		}

		if (str.matches("keye.*nce")) {
			System.out.println("YES");
			return;
		}

		if (str.matches("keyen.*ce")) {
			System.out.println("YES");
			return;
		}

		if (str.matches("keyenc.*e")) {
			System.out.println("YES");
			return;
		}

		if (str.matches(".*keyence")) {
			System.out.println("YES");
			return;
		}

		if (str.matches("keyence.*")) {
			System.out.println("YES");
			return;
		}

		System.out.println("NO");
	}
}


Measured memory_bytes: 23764
<?php
  function checkData($dataA, $dataB){
  	if(count($dataA)!=count($dataB)){
      return false;
    }
  
  	$ret = true;
    foreach($dataA as $key=>$num){
      if(!isset($dataB[$key]) || $dataB[$key]!=$num){
        $ret = false;
        break;
      }
    }
  	return $ret;
  }
  
  $n = intval(fgets(STDIN));

  $data = [];
  for($i=0; $i<$n; $i++){
    $tmp = [];
   	$str = trim(fgets(STDIN));
    
    for($j=0; $j<10; $j++){
      $abc = $str[$j];
      if(isset($tmp[$abc])){
        $tmp[$abc]++;
      }else{
        $tmp[$abc] = 1;
      }
    }
    
    ksort($tmp);
    
    $str2 = "";
    foreach($tmp as $key=>$num){
      $str2 .= $key.$num;
    }
    
    if(isset($data[$str2])){
      $data[$str2]++;
    }else{
      $data[$str2] = 1;
    }
  }

  $count = 0;
  foreach($data as $dataNum){
    if($dataNum > 1){
      $count += ($dataNum * ($dataNum-1) / 2);
    }
  }

  echo $count."\n";
/*
  $count = 0;
  for($i=0; $i<$n-1; $i++){
    $tmpCount=0;
    $groupCount
    for($j=$i+1; $j<$n; $j++){
      if(checkData($data[$i], $data[$j])){
        $count++;
      }
    }
  }
}*/
  

Measured memory_bytes: 13048
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut b = a.clone();
    b.sort();
    let mut even = HashSet::new();
    for i in 0..n {
        if i % 2 == 0 {
            even.insert(b[i]);
        }
    }
    let mut count = 0;
    for i in 0..n {
        if (i % 2 == 0 && even.contains(&a[i])) || (i % 2 == 1 && !even.contains(&a[i])) {
            count += 1;
        }
    }
    println!("{}", (n - count) / 2);
}


Measured memory_bytes: 5696
#include<bits/stdc++.h>
using namespace std;
const int MAXN=110,MAXK=100010;
int n,k;
int a[MAXN],dp[MAXK];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<=k;i++){
		dp[i]=0;
		for(int j=0;j<n;j++){
			if(i-a[j]<0) continue;
			if(!dp[i-a[j]]) dp[i]=1;
		}
	}
	if(dp[k]) cout<<"First\n";
	else cout<<"Second\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

template<int p = 1000000007>
class Z {
	ll x;
public:
	Z(ll X) :x((X + p) % p) { ; }
	Z() :x(0) { ; }
	Z &operator=(ll y) { return *this = Z(y); }
	Z operator-() const { return Z(-x); }
	Z operator+(ll y) const { return Z(x + y); }
	Z &operator+=(ll y) { return *this = *this + y; }
	Z operator-(ll y) const { return Z(x - y); }
	Z &operator-=(ll y) { return *this = *this - y; }
	Z operator*(ll y) const { return Z(x * y); }
	Z &operator*=(ll y) { return *this = *this * y; }
	Z operator/(ll y) const { return *this * Z(y).pow(p - 2); }
	Z &operator/=(ll y) const { return *this = *this / y; }
	Z operator+(const Z &r) const { return *this + r.x; }
	Z &operator+=(const Z &r) { return *this += r.x; }
	Z operator-(const Z &r) const { return *this - r.x; }
	Z &operator-=(const Z &r) { return *this -= r.x; }
	Z operator*(const Z &r) const { return *this * r.x; }
	Z &operator*=(const Z &r) { return *this *= r.x; }
	Z operator/(const Z &r) const { return *this / r.x; }
	Z &operator/=(const Z &r) { return *this /= r.x; }
	Z pow(int i) {
		if (i == 0) return Z(1);
		if (i % 2) return *this * pow(i - 1);
		Z tmp = pow(i / 2);
		return tmp * tmp;
	}
	ll get() { return x; }
	friend istream &operator>>(istream &istr, Z &z) { return istr >> z.x; }
	friend ostream &operator<<(ostream &ostr, const Z &z) { return ostr << z.x; }
};

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

	int N;
	cin >> N;
	vector<ll> A(N);
	ll num[60] = { 0 };
	REP(i, N) {
		cin >> A[i];
		REP(j, 60) {
			num[j] += A[i] >> j & 1;
		}
	}
	Z<> res = 0;
	REP(j, 60) {
		res += Z<>(1LL << j) * num[j] * (N - num[j]);
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>

#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)

using namespace std;

const long long MOD = 1000000000 + 7;
const int MAXN = 100111;
long long a[MAXN];
int n;

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 1, n) cin >> a[i];
  long long cnt = 0;
  long long j = 1;
  long long res = 1;
  FOR(i, 1, n) {
    res = (res * (i-cnt)) % MOD;
    if (a[i] >= j) j += 2;
     else cnt++;
  }
  cout << res << endl;
  return 0;
}

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

vector<ll> fac[1000005];

void build(){
    for(int i=2;i<=1000000;i++){
        if(fac[i].empty()){
            for(int j=i;j<=1000000;j+=i){
                fac[j].push_back(i);
            }
        }
    }
}

int main(){
    build();
    ll n;
    cin >> n;
    ll ar[n];
    for(int i=0;i<n;i++){
        cin >> ar[i];
    }
    ll gcdv=__gcd(ar[0],ar[1]);
    for(int i=2;i<n;i++){
        gcdv=__gcd(gcdv,ar[i]);
    }
    
    // cout << gcdv << '\n';
    
    // for(int i=1;i<=100;i++){
    //     for(auto u:fac[i]){
    //         cout << u << " ";
    //     }
        
    //     cout << '\n';
    // }
    
    map<ll,ll> mfd;
    ll fl=0;
    for(int i=0;i<n;i++){
        for(auto u:fac[ar[i]]){
            if(mfd[u]==1){
                fl=1;
            }
            mfd[u]=1;
        }
    }
    
    if(fl==1 and gcdv!=1){
        cout << "not coprime";
    }
    
    else if(fl==0){
        cout << "pairwise coprime";
    }
    else if(gcdv==1){
        cout << "setwise coprime";
    }
    return 0;
}

Measured memory_bytes: 86324
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 998244353

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

A,B,C,D = LI()

dp = [[0]*(D+1) for _ in range(C+1)]
dp[A][B] = 1

for i in range(A,C+1):
    for j in range(B,D+1):
        if i == A and j == B:
            continue
        dp[i][j] = (dp[i-1][j]*j)%mod + (dp[i][j-1]*i)%mod\
                     - (dp[i-1][j-1]*(i-1)*(j-1))%mod
        dp[i][j] %= mod

print(dp[C][D])

Measured memory_bytes: 139280