akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 998244353;
ll fact[upperlimit];
ll invfact[upperlimit];
ll ncr(int n,int r){
	if((r<0)||(r>n)) return 0;
	ll ans=fact[n];
	ans*=invfact[n-r];ans%=mod;
	ans*=invfact[r];ans%=mod;
	return ans;
}
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	fact[0]=1;invfact[0]=1;
	for(int i = 1; i < upperlimit; i++){
		fact[i]=fact[i-1];fact[i]*=i;fact[i]%=mod;
		invfact[i]=powmod(fact[i],mod-2,mod);
	}
	int n,m,k;
	sd(n);sd(m);sd(k);
	ll ans=powmod(m,n,mod);
	for(int i = k+1; i < n; i++){
		ll calc=ncr(n-1,i);
		calc*=m;calc%=mod;
		calc*=powmod(m-1,n-i-1,mod);calc%=mod;
		ans+=mod-calc;
		ans%=mod;
	}
	plld(ans);
	return 0;
}

Measured memory_bytes: 19460
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){
 
	lli a;
	cin>>a;
	if(a%2==0)cout<<a<<endl;
	else cout<<a*2<<endl;

	return 0;
}

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

int main(){
  string S;
  cin >> S;

  bool flag=true;

  if(S.at(0)!='A'){
    flag=false;
  }else{
    int cnt=0;
    int res=S.size();
    for (int i = 2; i < S.size()-1; i++) {
      if(S.at(i)=='C'){
        cnt++;
        res=i;
      }
    }
    if(cnt==1){
      for (int i = 1; i < S.size(); i++) {
        if(i!=res){
          if(0<=(S.at(i)-'a')&&(S.at(i)-'a')<=25) continue;
          else {
            flag=false;
            break;
          }
        }
      }
    }else{
      flag=false;
    }
  }
  if(flag) cout << "AC" << endl;
  else cout << "WA" << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {
	class Node {
		int p = -1, l, r;
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	public void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		int n = Integer.parseInt(reader.readLine());
		Node[] nodes = new Node[n];
		for (int i = 0; i < n; i++)
			nodes[i] = new Node();
		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(reader.readLine());
			int id = Integer.parseInt(st.nextToken());
			int l = Integer.parseInt(st.nextToken());
			int r = Integer.parseInt(st.nextToken());
			nodes[id].l = l;
			nodes[id].r = r;
			if (l != -1)
				nodes[l].p = id;
			if (r != -1)
				nodes[r].p = id;
		}
		reader.close();

		int rootId = -1;
		for (int i = 0; i < n; i++) {
			if (nodes[i].p == -1) {
				rootId = i;
				break;
			}
		}
		System.out.println("Preorder");
		preOrderItr(nodes, rootId);
		System.out.println();

		System.out.println("Inorder");
		inOrderItr(nodes, rootId);
		System.out.println();

		System.out.println("Postorder");
		postOrderItr(nodes, rootId);
		System.out.println();
	}

	private void preOrderItr(Node[] nodes, int rootId) {
		Stack<Integer> stack = new Stack<Integer>();
		stack.push(rootId);
		while (!stack.isEmpty()) {
			int cur = stack.pop();
			System.out.print(" " + cur);
			if (nodes[cur].r != -1)
				stack.push(nodes[cur].r);
			if (nodes[cur].l != -1)
				stack.push(nodes[cur].l);
		}
	}

	private void inOrderItr(Node[] nodes, int rootId) {
		Stack<Integer> stack = new Stack<Integer>();
		int cur = rootId;
		while (cur != -1 || !stack.isEmpty()) {
			if (cur != -1) {
				stack.push(cur);
				cur = nodes[cur].l;
			} else {
				cur = stack.pop();
				System.out.print(" " + cur);
				cur = nodes[cur].r;
			}
		}
	}

	private void postOrderItr(Node[] nodes, int rootId) {
		Stack<Integer> stack = new Stack<Integer>();
		int lastNodeVisited = -1;
		int cur = rootId;
		while (cur != -1 || !stack.isEmpty()) {
			if (cur != -1) {
				stack.push(cur);
				cur = nodes[cur].l;
			} else {
				int peekId = stack.peek();
				if (nodes[peekId].r != -1 && lastNodeVisited != nodes[peekId].r) {
					cur = nodes[peekId].r;
				} else {
					System.out.print(" " + peekId);
					lastNodeVisited = stack.pop();
				}
			}
		}
	}
	
//	private void preOrder(Node[] nodes, int u) {
//		if (u == -1)
//			return;
//		System.out.print(" " + u);
//		preOrder(nodes, nodes[u].l);
//		preOrder(nodes, nodes[u].r);
//	}	
//	private void inOrder(Node[] nodes, int u) {
//		if (u == -1)
//			return;
//		inOrder(nodes, nodes[u].l);
//		System.out.print(" " + u);
//		inOrder(nodes, nodes[u].r);
//	}
//	private void postOrder(Node[] nodes, int u) {
//		if (u == -1)
//			return;
//		postOrder(nodes, nodes[u].l);
//		postOrder(nodes, nodes[u].r);
//		System.out.print(" " + u);
//	}	
}



Measured memory_bytes: 24380
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int a;
	cin>>a;
	rep(i,50000){
		int j=i*1.08;
		if(j==a){
			cout<<i;
			re 0;
		}
	}
	cout<<":(";
	re 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define eps 0.000000001
using namespace std;
typedef long double ld;
typedef pair<int,int> p;
typedef pair<ld,p> P;

int n;
ld px[200],py[200],pz[200],vx[200],vy[200],vz[200],r[200],vr[200];

ld getlen(int a,int b,ld M){
  ld ax=px[a]+vx[a]*M,ay=py[a]+vy[a]*M,az=pz[a]+vz[a]*M,ar=r[a]-vr[a]*M;
  ld bx=px[b]+vx[b]*M,by=py[b]+vy[b]*M,bz=pz[b]+vz[b]*M,br=r[b]-vr[b]*M;
  ld dx=ax-bx,dy=ay-by,dz=az-bz;
  return sqrt(dx*dx+dy*dy+dz*dz)-(ar+br);
}

ld check(int a,int b){
  ld L=0,R=100,M;
  int s=0;
  while(s++<50){
    M=(L+R)/2;
    ld len=getlen(a,b,M),len1=getlen(a,b,M+eps);
    if(len<len1||len<0)R=M;
    else L=M;
  }
  if(getlen(a,b,R)>0)return 1000;
  return R;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    priority_queue<P,vector<P>,greater<P> > q;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)
	q.push(P(check(i,j),p(i,j)));
      q.push(P(r[i]/vr[i],p(i,i)));
    }
    ld used[200]={};
    while(!q.empty()){
      ld t=q.top().first;
      int a=q.top().second.first,b=q.top().second.second;
      q.pop();
      if(used[a]||used[b])continue;
      used[a]=used[b]=t;
    }
    for(int i=0;i<n;i++)printf("%.10Lf\n",used[i]);
  }
  return 0;
}

Measured memory_bytes: 4568
n,h = map(int, input().split())
al = []
bl = []
for _ in range(n):
    a,b = map(int, input().split())
    al.append(a)
    bl.append(b)

al.sort(reverse=True)
bl.sort(reverse=True)

rem = h
ans = 0
for b in bl:
    if b >= al[0]:
        ans += 1
        rem -= b
    if rem <= 0:
        print(ans)
        exit()

cnt = (rem-1)//al[0]+1
print(ans+cnt)

Measured memory_bytes: 86632
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
    cout << "#";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using Graph = vector<vector<LL>>;

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
long long chmax(long long a,long long b){
  a = max(a,b);
}
long long chmin(long long a, long long b){
  a = min(a,b);
}
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;

    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v);
    }
}



int main() {
  LL n,k=-1,sum=0,a=0,b=0,c=0,d=0,ans=0;
  LL MOD = 1000000007;
  LL INF = 1LL << 60;
  string S="",T="",U="";
  cin >> n >>S;
  for (LL i=0;i<n-1;i++){
    if(S[i]!=S[i+1]) ans++;
  }
  cout << ans+1 << endl;
}

Measured memory_bytes: 512
class UnionFind(object):
    def __init__(self, nodes):
        self.__parents = {node: None for node in nodes}

    def union(self, a, b):
        root_of_a = self.find(a)
        root_of_b = self.find(b)
        if root_of_a != root_of_b:
            self.__parents[root_of_a] = root_of_b

    def find(self, a):
        if self.__parents[a] is None:
            return a
        root = self.find(self.__parents[a])
        self.__parents[a] = root
        return root

    @property
    def roots(self):
        return set(node for node, parent in self.__parents.items() if parent is None)

n, m = map(int, input().split())

xyzs = [tuple(map(int, input().split())) for _ in range(m)]

union_find = UnionFind(range(1, n+1))
for x, y, z in xyzs:
    union_find.union(x, y)

print(len(union_find.roots))


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    
    int x,y;
    cin>>x>>y;

    for(int i=0;i<=x;i++){
        if(i*2+(x-i)*4==y){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;

}
/*


*/


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

int main()
{
	int A,B;
	int answer;
	
	cin >> A >> B;
	
	if(A >= 13){
		answer = B;
	} else if (A >= 6){
		answer = B / 2;
	} else {
		answer = 0;
	}
	
	cout << answer;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,A,B;
    cin >>N>>A>>B;
    ll ans = N/(A+B)*A + min(N%(A+B),A);
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3576
#include <stdio.h>

int main(void){
  char class[11][13] = {"light fly", "fly", "bantam", "feather",
                        "light", "light welter", "welter", "light middle",
			"middle", "light heavy", "heavy"};
  int i, kg[10] = {48, 51, 54, 57, 60, 64, 69, 75, 81, 91};
  double w;

  while(scanf("%lf", &w) != EOF){
    for(i = 0; i < 10 && w > kg[i]; i++){
      ;
    }
    printf("%s\n", class[i]);
  }
  return 0;
}

Measured memory_bytes: 608
n = int(input())
a = n//2
ans = 0
for j in range(1,n+1):
    count = 0
    for i in range(1,j+1):
        if j % i == 0:
            count += 1
        if count >= 8 and j % 2 == 1:
            ans +=1
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

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

}


Measured memory_bytes: 256
z[2002],*a=z,*b=z+1001,m,i,j,t;
main(n){
	for(;scanf("%d",&n),i=n;printf("%d\n",m)){
		for(memset(a,m=0,4004);i--;){
			for(scanf(" "),j=n;j--;)
				m=fmax(m,b[j]=getchar()-'*'?1+fmin(fmin(b[j+1],a[j+1]),a[j]):0);
			t=a;a=b;b=t;
		}
	}
	exit(0);
}

Measured memory_bytes: 0
#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=1e9,MOD=1e9+7;

int main(){
    int n; cin>>n;
    long long c; cin>>c;
    long long x[n],v[n]; rep(i,n) cin>>x[i]>>v[i];
    long long left_walk[n+1]={};
    rep(i,n) left_walk[i+1]=x[i];
    long long right_walk[n+1]={};
    rep(i,n) right_walk[i+1]=(c-x[n-1-i]);
    long long left_sushi[n+1]={};
    rep(i,n) left_sushi[i+1]=left_sushi[i]+v[i];
    long long right_sushi[n+1]={};
    rep(i,n) right_sushi[i+1]=right_sushi[i]+v[n-1-i];

    // 左からi個目まで取れる時の最大値と距離
    long long left_max[n+1];
    left_max[0]=0;
    rep(i,n){
        left_max[i+1]=max(left_max[i],left_sushi[i+1]-left_walk[i+1]);
    }
    long long left_max_wrap[n+1];
    left_max_wrap[0]=0;
    rep(i,n){
        left_max_wrap[i+1]=max(left_max_wrap[i],left_sushi[i+1]-2*left_walk[i+1]);
    }

    long long ans=0;
    // 右にi貫とる
    for(int i=0;i<=n;i++){
        // 左端往復
        long long left=left_max_wrap[n-i]+right_sushi[i]-right_walk[i];
        // 右端往復
        long long right=left_max[n-i]+right_sushi[i]-2*(right_walk[i]);
        ans=max({ans,left,right});
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define d double
d dp[305][305][305];
int ar[305];
int mp[4];
int n;
d f(int a, int b, int c)
{
    if (!a && !b & !c)
        return 0;
    d &ans = dp[a][b][c];
    if (ans != -1) return ans;
    ans = n;
    if (a != 0)
        ans += a * f(a - 1, b, c);
    if (b != 0)
        ans += b * f(a + 1, b - 1, c);
    if (c != 0)
        ans += c * f(a, b + 1, c - 1);
    ans /= (a + b + c);
    return ans;
}
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < 305; ++i)
    {
        for (int j = 0; j < 305; ++j)
        {
            for (int k = 0; k < 305; ++k)
            {
                dp[i][j][k] = -1;
            }
        }
    }
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &ar[i]);
        mp[ar[i]]++;
    }
    cout << fixed << setprecision(10) << f(mp[1], mp[2], mp[3]);
    return 0;
}

Measured memory_bytes: 221952
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <array>
#include <map>
#include <set>
using namespace std;

int main()
{
    size_t N;
    cin >> N;
    long long ai;
    vector<long long> A(N+1, 0);
    A[0] = ai;
    for(size_t i=1;i<=N;i++){
        cin >> ai;
        A[i] = ai + A[i-1];
    }
    sort(A.begin(), A.end());
    long long res = 0;
    int prev = 0;
    for(long long i=1; i<=N; i++){
        if(A[prev] != A[i]){
            res += (i-prev)*(i-prev-1)/2;
            prev = i;
        }
    }
    res += ((N+1)-prev)*((N+1)-prev-1)/2;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

typedef long long ll;
const int INF = 1e8;
// const ll INF = 1LL << 60;
typedef pair<ll, string> P;

ll X, Y, A, B, C;
vector<ll> p, q, r;
vector<P> v;

int main() {
    cin >> X >> Y >> A >> B >> C;
    p.resize(A);
    q.resize(B);
    r.resize(C);

    rep(i, A) cin >> p[i];
    rep(i, B) cin >> q[i];
    rep(i, C) cin >> r[i];

    // sort(p.rbegin(), p.rend());
    // sort(q.rbegin(), q.rend());
    // sort(r.rbegin(), r.rend());

    rep(i, A) {
        v.push_back(P(p[i], "red"));
    }
    rep(i, B) {
        v.push_back(P(q[i], "blue"));
    }
    rep(i, C) {
        v.push_back(P(r[i], "musyoku"));
    }
    sort(v.rbegin(), v.rend());

    ll ans = 0;
    ll cnt = 0;
    ll x_cnt = 0, y_cnt = 0;

    for (int i = 0; i < v.size(); i++) {
        // cout << v[i].first << " " << v[i].second << " " << x_cnt << " " << y_cnt << endl;
        if (x_cnt >= X && v[i].second == "red") {
            continue;
        }
        if (y_cnt >= Y && v[i].second == "blue") {
            continue;
        }
        ans += v[i].first;
        if (v[i].second == "red") x_cnt++;
        if (v[i].second == "blue") y_cnt++;

        cnt++;
        if (cnt >= X + Y) {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 24940
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt() + 1;
        int sum = 0;
        int c = scan.nextInt();
        for(int i = 0; i < c; i++){
            sum += scan.nextInt();
        }
        System.out.println(sum % n == 0 ? sum / n : sum / n + 1);
        scan.close();
    }
}


Measured memory_bytes: 26212
from itertools import combinations
import math
from statistics import mean

N = int(input())
l = []
ans = []
for i in range(N):
  l.append(list(map(int, input().split())))
  
for v in combinations(l, 2):
  ans.append(math.sqrt((v[0][0]-v[1][0])**2 + (v[0][1]-v[1][1])**2))
  
print(sum(ans)/N*2)

Measured memory_bytes: 5404
#include<bits/stdc++.h>
#define maxn 100050
using namespace std;

int n,m;

vector<int> A[maxn];

int main()
{
	scanf("%d",&n);
	for (m=1;m*(m-1)<2*n;++m)	;
	if (m*(m-1)>2*n)
		puts("No");
	else
	{
		int x=0;
		for (int i=1;i<=m;++i)
			for (int j=i+1;j<=m;++j)
				++x,A[i].push_back(x),A[j].push_back(x);
		puts("Yes");
		printf("%d\n",m);
		for (int i=1;i<=m;++i)
		{
			printf("%d ",m-1);
			for (auto x:A[i])
				printf("%d ",x);
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 4608
S = input()
max_l = 0
tmp = 0

for i in S:
  if i == 'A' or i == 'C' or i == 'G' or i == 'T':
    tmp += 1
    if max_l < tmp:
      max_l = tmp
  else:
    tmp = 0
print(max_l)



Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
    int h,w,sum,i,o,temp;
    int line[151];
    for(i=1;i<151;i++)
        line[i]=i*i;
    for(;scanf("%d %d",&h,&w),h+w;){
        sum=h*h+w*w;
        for(i=h+1;i < w;i++){
            temp=sum;
            if(temp < i*i)
                break;
            temp-=(i*i);
            for(o=1;o<151;o++){
                if(line[o] == temp && o != i)
                    break;
            }
            if(o != 151)
                break;
        }
        if(i == w){
            for(sum++;;sum++){
                for(i=1;i<151;i++){
                    temp=sum;
                    temp-=(i*i);
                    for(o=i+1;o<151 && o != i;o++){
                        if(line[o] == temp && o != i)
                            break;
                    }
                    if(o != 151)
                        break;
                }
                if(o != 151){
                    break;
                }
            }
            printf("%d %d\n",i,o);
        }
        else{
            printf("%d %d\n",i,o);
        }
    }
    return 0;
}

Measured memory_bytes: 1820
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma comment(linker, "/STACK:2000000")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'
using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 3e5 + 5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;
void printCase(int cs){
  cout << "Case #" << cs<<": ";
}

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
  
  int a,b,c;
  cin >> a >> b >> c;
  swap(a,b);
  swap(a,c);
  cout<<a<<' '<<b<<' '<<c<<'\n';




  return 0;
}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	LL sum = 0;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin >> A[i];
		sum += A[i];
	}
	
	LL ans = 0;
	if( sum % 10 == 0 ){
		ans = 0;
	}else{
		ans = sum;
	}
	for(int i=0;i<N;++i){
		LL temp = sum - A[i];
		LL res = 0;
		if( temp % 10 == 0 ){
			res = 0;
		}else{
			res = temp;
		}
		ans = max(ans,res);
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int n,a[21];

bool isOK(int i,double ub){
	if(i==n) return true;

	bool f;
	int tmp;
	for(int b=(a[i]+a[i-1]-1)/a[i-1]*a[i-1];abs(a[i]-b)<ub*a[i];b+=a[i-1]){
		tmp=a[i];
		a[i]=b;
		f=isOK(i+1,ub);
		a[i]=tmp;
		if(f) return true;
	}
	for(int b=a[i]/a[i-1]*a[i-1];abs(a[i]-b)<ub*a[i];b-=a[i-1]){
		if(b<a[i-1]) break;
		tmp=a[i];
		a[i]=b;
		f=isOK(i+1,ub);
		a[i]=tmp;
		if(f) return true;
	}
	return false;
}

int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%d",a+i+1);
	a[0]=1; n++;

	double lo=0,hi=0;
	for(int i=1;i<n-1;i++){
		int prev=a[i]/a[i-1]*a[i-1];
		hi=max(hi,(double)abs(a[i+1]-a[i+1]/prev*prev)/a[i+1]);
	}
	rep(_,100){
		double mi=(lo+hi)/2;
		if(isOK(1,mi)) hi=mi; else lo=mi;
	}
	printf("%.15f\n",lo,hi);

	return 0;
}

Measured memory_bytes: 716
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = 1e9+7;
ll kai[100001];
ll gyaku[100001];
int a[100000];
P pa[100000];

ll kuri2(ll a,ll x)
{
	ll ret=1;ll tmp=a;
	while(x>0)
	{
		if(x&1)
		{
			ret*=tmp;
			ret%=MOD;
		}
		tmp=tmp*tmp;
		tmp%=MOD;
		x>>=1LL;
	}
	if(ret<0)
		ret+=MOD;
	return ret;
}

ll comb(ll n,ll k)
{
	if(n<k)
		return 0;
	ll ret=kai[n]*gyaku[k];
	ret%=MOD;
	ret*=gyaku[n-k];
	ret%=MOD;
	if(ret<0)
		ret+=MOD;
	return ret;
}
int main()
{
	int n,k;
	ll ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		pa[i]=P(a[i],i);
	}
	kai[0]=1;
	for(int i=1;i<100001;i++)
	{
		kai[i]=kai[i-1]*(ll)i;
		kai[i]%=MOD;
		if(kai[i]<0)
			kai[i]+=MOD;
	}
	for(int i=0;i<100001;i++)
		gyaku[i]=kuri2(kai[i],MOD-2);
	sort(pa,pa+n);
	for(int i=0;i<n;i++)
	{
		ll tmp=comb(i,k-1)*pa[i].first;
		//cerr<<pa[i].first<<" "<<comb(i,k-1)<<endl;
		tmp%=MOD;
		ans+=tmp;
		ans%=MOD;
	}
	for(int i=0;i<n;i++)
	{
		ll tmp=comb(n-i-1,k-1)*pa[i].first;
		tmp%=MOD;
		ans-=tmp;
		ans%=MOD;
	}
	if(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    while (true){
        string s; cin >> s;
        if (s == "-") break;
        int m; cin >> m;
        for (int i = 0; i < m; i++){
            int h; cin >> h;
            string x = s;
            s = x.substr(h, x.size()-h) + x.substr(0, h);
        }
        cout << s << endl;
    }
    return 0;    
}


Measured memory_bytes: 3156
#define f(X) for(c=0;c<X;c+=v[p++]);if(c-X)goto L;
n,v[50],s,p,c;main(){for(;n=atoi(gets(v));){for(p=s=0;p<n;v[++p]=strlen(gets(v+n)));L:p=++s;f(5)f(7)f(5)f(7)f(7)printf("%d\n",s);}}

Measured memory_bytes: 524
n = int(input())
a = [int(input()) for _ in range(n)]

result = {}
for a_i in a:
    if not a_i in result or 0 == result[a_i]:
        result[a_i] = 1
    else:
        result[a_i] = 0
print(list(result.values()).count(1))


Measured memory_bytes: 16272
n = int(input())
h = [0] + list(map(int, input().split()))
cost = {1:0,2: abs(h[2] - h[1])}
for i in range(1, n):
    cost[i + 1] = min(cost[i + 1], cost[i] + abs(h[i + 1] - h[i]))
    if i==n-1:break
    cost[i + 2] = cost[i] + abs(h[i + 2] - h[i])

print(cost[n])


Measured memory_bytes: 23184
package main

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

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

func main() {
	H, W := ReadInt(), ReadInt()
	s := make([]string, H)
	blockCount := 0
	for y := 0; y < H; y++ {
		s[y] = ReadString()
		for x := 0; x < W; x++ {
			if s[y][x] == '#' {
				blockCount++
			}
		}
	}

	goal := H*W - 1
	dist := make([]int, W*H)
	q := make([][]int, 0)
	q = append(q, []int{0, 1})
	for len(q) > 0 {
		id, d := q[0][0], q[0][1]
		q = q[1:]
		if dist[id] > 0 {
			continue
		}
		dist[id] = d
		if id == goal {
			break
		}
		x, y := id%W, id/W
		for i := 0; i < 4; i++ {
			nx, ny := x+dx[i], y+dy[i]
			if 0 <= nx && nx < W && 0 <= ny && ny < H {
				if s[ny][nx] == '.' {
					q = append(q, []int{nx + W*ny, d + 1})
				}
			}
		}
	}
	goalDist := dist[goal]
	if goalDist == 0 {
		fmt.Println(-1)
		return
	}
	fmt.Println(H*W - blockCount - goalDist)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

const int S_SIZE = 4;

bool isYYMM(const char str[]) {
  int YY = (str[0] - '0') * 10 + (str[1] - '0');
  int MM = (str[2] - '0') * 10 + (str[3] - '0');

  if (0 <= YY && YY <= 99 && 1 <= MM && MM <= 12) return true;

  return false;
}

bool isMMYY(const char str[]) {
  int MM = (str[0] - '0') * 10 + (str[1] - '0');
  int YY = (str[2] - '0') * 10 + (str[3] - '0');

  if (0 <= YY && YY <= 99 && 1 <= MM && MM <= 12) return true;

  return false;
}

int main() {
  char S[S_SIZE];
  for (int i = 0; i < S_SIZE; i++) {
    scanf("%s", &S[i]);
  }

  if (isYYMM(S) && isMMYY(S)) {
    printf("AMBIGUOUS");
    return 0;
  }

  if (isYYMM(S)) {
    printf("YYMM");
    return 0;
  }

  if (isMMYY(S)) {
    printf("MMYY");
    return 0;
  }

  printf("NA");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,i;
  cin>>n>>m;long long b[n+1]={0},p=0,a[n+1];
  for(i=1;i<=n;i++)
    cin>>a[i];
  for(i=0;i<m;i++){
    long long l,r;
    cin>>l>>r;
    if(b[l]==0)
    b[l]=1;
    if(b[r]==0)
    b[r]=1;
    if(a[l]>a[r])
      b[r]=2;
    else if(a[r]>a[l])
      b[l]=2;
    else if(a[r]==a[l]){
      b[r]=2;b[l]=2;
    }
  }for(i=1;i<=n;i++){
   if(b[i]==0||b[i]==1)
     p++;
  }cout<<p;return 0;
}

Measured memory_bytes: 5164
n,m,k = map(int,input().split())

mod = 10**9+7 
fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,n*m+1):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod    


ans = 0

for i in range(1,n):
    
    ans += nCr(n*m-2,k-2,mod)*i*(n-i)*m**2
    ans %= mod
    
for i in range(1,m):
    
    ans += nCr(n*m-2,k-2,mod)*i*(m-i)*n**2
    ans %= mod
    
print(ans)

Measured memory_bytes: 27036
n=int(input())

if n/1.08==int(n/1.08):
    print(int(n/1.08))

else:
    if n<=n//1.08*1.08<n+1:
        print(int(n//1.08))
    elif n<=(n//(1.08)+1)*1.08<n+1:
        print(int(n//1.08+1))
    else:
        print(':(')

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main() {
	int i, j, W, H;
	while (cin >> H >> W, H || W){
		for (i = 1; i <= H; i++){
			for (j = 1; j <= W; j++){
			    if(i > 1 && i != H && j > 1 && j != W)
                                     cout << ".";
                                 else
                                     cout << "#";
			}
			cout << endl;
		}
          cout << endl;
	}
}

Measured memory_bytes: 1152
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
A = np.frombuffer(read(), 'S1').reshape(N, -1)[:, :M] == b'#'

R = np.full((N, M), '.')
B = np.full((N, M), '.')
s = '#'
R[A] = s
B[A] = s
R[:, 0] = s
B[:, -1] = s
R[::2, :-1] = s
B[1::2, 1:] = s

print('\n'.join(''.join(row) for row in R.tolist()))
print()
print('\n'.join(''.join(row) for row in B.tolist()))

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;
vector<int> Eratosthenes(int n);
int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = min(a * x + b * y, c * max(x, y) * 2);
    if (x > y)
    {
        ans = min(ans, c * y * 2 + (x - y) * a);
    }
    else
    {
        ans = min(ans, c * x * 2 + (y - x) * b);
    }
    c(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
static const int MAX = 200000;


int main()
{
	vector<int> v(3);
	for (int i = 0; i < 3; i++)cin >> v.at(i);
	sort(v.begin(), v.end());

	bool flg = false;
	if (v.at(0) == 5 && v.at(1) == 5 && v.at(2) == 7) flg = true;

	if (flg == true)cout << "YES" << endl;
	else cout << "NO" << endl;

    return 0;
}

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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define br cout<<endl;
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> pii;
const int MAX = 100005;
const int INF = 1e9+7;
const LL LINF = 1e18 + 7;

/***************************************************************************/


int main() {
	int N;
	ios_base::sync_with_stdio(false);
	cin >> N;
	vector<LL> A(N, 0), B(N, 0);
	LL sumall = 0;
	for(int i=0; i<N; i++) {
		cin >> A[i];
		sumall += A[i];
	}
	for(int i=0; i<N; i++) {
		cin >> B[i];
		sumall -= B[i];
	}
	LL sum = 0, ans = 0;
	multiset<LL, greater <LL> >pq;
	for(int i=0; i<N; i++) {
		sum += A[i] - B[i];
		LL cur = sumall - sum;
		ans += abs(cur);
		if(cur<=0) {
			pq.insert(0);
			continue;
		}

		if(cur > sumall) cur = sumall;
		pq.insert(-cur);
		pq.insert(-cur);
		multiset<LL, greater <LL> >::iterator it=pq.begin();
		ans += *it;
		pq.erase(it);

	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b))cout << "A" << endl;
	else cout << "B" << endl;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<cassert>
#define fr first
#define sc second
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 998244353;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
int dp[5005][5005];
signed main() {
	int n; cin >> n;
	string s; cin >> s;
	rep(i, n) {
		rep(j, n) {
			if (s[i] == s[j]) {
				dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
				if (dp[i+1][j+1] > abs(j - i))dp[i+1][j+1] = 0;
			}
		}
	}
	int ans = 0;
	rep(i, n + 1) {
		rep(j, n + 1) {
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 195712
#include <bits/stdc++.h>
#define lli long long int
#define DBG false
using namespace std;
 
int main() {
	int N;
	string S;
	cin >> N >> S;
	long long r = 0, g = 0, b = 0;
	for(int i=0; i<N; i++){
		if (S[i] == 'R') r++;
		if (S[i] == 'G') g++;
		if (S[i] == 'B') b++;
	}

	long long sum = r * g * b;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			int k = (j - i) + j;
			if (k >= N) break;
			if (S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) sum--;
		}
	}
	cout << sum << endl;
	return 0;
}

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

ll H, W, N;

ll iceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

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

    ll ans = iceil(N, max(H, W));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
using llng = long long;
template<typename T> using v = vector<T>;
template<typename T> using vv = v<v<T> >;

int main() {
    string S; cin >> S;
    if (S.substr(0, 4) == "YAKI") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

const ll MOD = 1e9 + 7;

int mpow(int base, int exp);
typedef  vector<int> vi;
typedef  vector<ll> vll;
typedef  vector<pair<ll,ll>> vpll;
typedef  vector<pair<int, int>> vpii;
typedef  pair<int, int> pii;
typedef  pair<ll, ll> pll;
typedef  unordered_map<ll, ll> umpll;
typedef  unordered_map<int, int> umpii;
typedef  unordered_map<ll, int> umpli;
typedef  unordered_set<int> usi;
typedef  unordered_set<ll> usll;
typedef  set<int> si;
typedef  set<ll> sll;
typedef  set<pair<int, int>> spii;
typedef  set<pair<ll, ll>> spll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fo(i,n) for(i = 0;i < n; i++)
#define Fo(i,k,n) for(i = k;k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define deb3(x, y, z) cout << #x << " = " << x << ", " << #y << " = " << y << ", "<< #z << " = " << z << endl

ll randGen(ll lower, ll upper) { return (rand() % (upper - lower + 1)) + lower; }
ll dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
// cout << fixed;
// cout.precision(10);
//******************          Function here          *********************//

   void solve(){
      string s, t;
      cin >> s >> t;
      int ans = 1100;
      for(int i = 0; i <= s.size() - t.size(); i++) {
         int count = 0, k = i;
         for(int j = 0; j < t.size(); j++) {
            if(s[k++] != t[j]) count++;
         }
         // deb(count);
         ans = min(count, ans);
      }
      cout << ans << endl;
   }

//*********************************************************************//

int main()
{
    #ifndef ONLINE_JUDGE
      string inputFile, outputFile;
      inputFile = "input.txt";
      outputFile = "output.txt";
      freopen(inputFile.c_str(), "r", stdin);
      freopen(outputFile.c_str(), "w", stdout);
    #endif

    int t = 1;
    // cin>>t;
    while(t-- >0){
      solve();
    }
    return 0;
}



/**********************   Utility Functions  *****************************/
   int mpow(int base, int exp) {
     base %= MOD;
     int result = 1;
     while (exp > 0) {
       if (exp & 1) result = ((ll)result * base) % MOD;
       base = ((ll)base * base) % MOD;
       exp >>= 1;
     }
     return result;
   }
/***********************************************************************/


Measured memory_bytes: 3616
#include <iostream>
//#include <cstdio>
using namespace std;

#define ll long long
const int M=1e9+7;

int n,a,b;
ll tmp,ans;

ll pow_mod(ll a,ll b,ll c){
    ll ans = 1;
    ll base = a%c;
    while(b){
        if(b & 1) ans = (ans*base)%c;
        base = (base*base)%c;
        b >>= 1;
    }
    return ans;
}

ll mulit(ll a, ll b, ll m)
{
    ll ans = 0;
    while(b)
    {
        if(b & 1)
            ans = (ans + a) % m;
        a = (a << 1) % m;
        b >>= 1;
    }
    return ans;
}
 
ll quick_mod(ll a, ll b, ll m)
{
    ll ans = 1;
    while(b)
    {
        if(b&1)
            ans = mulit(ans, a, m);
        a = mulit(a, a, m);
        b >>= 1;
    }
    return ans;
}
 
ll comp(ll a, ll b, ll m)
{
    if(a < b)
        return 0;
    if(a == b)
        return 1;
    if(b > a - b)
        b = a - b;
    ll ans = 1, ca = 1, cb = 1;
 
    for(int i = 0; i < b; i++)
    {
        ca = ca * (a - i) % m;
        cb = cb * (b - i) % m;
    }
 
    ans = ca * quick_mod(cb, m - 2, m) % m;
    return ans;
}
 
ll lucas(ll a,ll b,ll m)
{
    ll ans = 1;
    while(a && b)
    {
        ans = (ans * comp(a % m, b % m, m)) % m;
        a /= m;
        b /= m;
    }
    return ans;
}

int main()
{
    cin>>n>>a>>b;
    ans=pow_mod(2,n,M)-lucas(n,a,M)-lucas(n,b,M)-1;
    while (ans<0) ans+=M;
    cout<<ans%M;
    return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
  n <- (read :: String -> Int) <$> getLine
  strs <- getLine
  let answers = solve n $ encode strs
  --mapM_ putStrLn $ map (decode.reverse) answers
  putStrLn $ if null answers
             then "-1"
             else decode.drop 1 $ reverse.drop 1 $head answers
                       
encode :: String -> [Bool]
encode = map (== 'o')

decode :: [Bool] -> String
decode = map (\b -> if b then 'S' else 'W')


xor :: Bool -> Bool -> Bool
xor a b = (not a && b) || (not b && a)

solve :: Int -> [Bool] -> [[Bool]]
solve n input = filter check $ foldl (\a b -> map (next b) a)  [[True, True]
                                           ,[True, False]
                                           ,[False, True]
                                           ,[False, False]] input
  where
    next :: Bool -> [Bool] -> [Bool]
    next x bs@(s1:s2:_) = if xor x s1
                        then not s2:bs
                        else s2:bs 
    check :: [Bool] -> Bool
    check bs = and $ zipWith (==) (take 2 bs) (drop n bs)

Measured memory_bytes: 31228
if __name__ == '__main__':
    m1, d1 = map(int, input().split())
    m2, d2 = map(int, input().split())
    month =[2,4,6,9,11]

    if m1 in month:
        if m1 ==2:
            if d1 ==28:
                print(1)
            else:
                print(0)
        else:
            if d1 ==30:
                print(1)
            else:
                print(0)
    else:
        if d1 ==31:
            print(1)
        else:
            print(0)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


enum Type{
	NOT,
	YES,
	TOIMEN,
};

ll dp_odd[101][9][2][2];
ll dp_even[101][9][3][3];

void makeTable(){

	dp_odd[1][1][YES][YES] = 1;
	dp_odd[1][0][NOT][NOT] = 1;

	for(int loc = 2; loc <= 100; loc++){
		for(int num = 8; num >= 0; num--){
			for(int first = 0; first <= 1; first++){
				dp_odd[loc][num][first][NOT] += dp_odd[loc-1][num][first][YES]+dp_odd[loc-1][num][first][NOT];

				if(num == 0)continue;
				dp_odd[loc][num][first][YES] += dp_odd[loc-1][num-1][first][NOT];
			}
		}
	}

	dp_even[1][0][NOT][NOT] = 1;
	dp_even[1][1][YES][YES] = 1;
	dp_even[1][1][TOIMEN][TOIMEN] = 1;

	for(int loc = 2; loc <= 100; loc++){
		for(int num = 8; num >= 0; num--){
			for(int first = 0; first <= 2; first++){

				dp_even[loc][num][first][NOT] += dp_even[loc-1][num][first][NOT]+dp_even[loc-1][num][first][YES]+dp_even[loc-1][num][first][TOIMEN];

				if(num == 0)continue;
				dp_even[loc][num][first][YES] += dp_even[loc-1][num-1][first][NOT]+dp_even[loc-1][num-1][first][TOIMEN];
				dp_even[loc][num][first][TOIMEN] += dp_even[loc-1][num-1][first][NOT]+dp_even[loc-1][num-1][first][YES];
			}
		}
	}
}

void func(int N){

	ll ans;

	if(N%2 == 1){

		ans = dp_odd[N][8][NOT][NOT]+dp_odd[N][8][NOT][YES]+dp_odd[N][8][YES][NOT];

	}else{

		ans = 0;

		for(int i = 0; i <= 2; i++){
			for(int k = 0; k <= 2; k++){

				if(i == 1 && k == 2)continue;
				if(i == 2 && k == 1)continue;

				ans += dp_even[N/2][8][i][k];
			}
		}
	}

	ans *= 40320;

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

int main(){

	for(int a = 0; a < 101; a++){
		for(int b = 0; b < 9; b++){

			for(int c = 0; c < 2; c++){
				for(int d = 0; d < 2; d++)dp_odd[a][b][c][d] = 0;
			}

			for(int c = 0; c < 3; c++){
				for(int d = 0; d < 3; d++)dp_even[a][b][c][d] = 0;
			}
		}
	}

	makeTable();

	int N;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func(N);
	}

	return 0;
}



Measured memory_bytes: 3204
n, x = gets.split.map &:to_i

mod = []

def x(p)
	2 * p + 3
end

seed = 1

n.times{
	seed = x(seed)
	mod << seed
}

mod.reverse!

count = 0

if x == mod[0] then
	puts mod[0] / 2 + 1
	exit
end

mod[1..-1].each{ |m|
	if x >= 2 * m + 2 then
		count += 2 * (m / 2 + 1) + 1
		x = 0
		break
	elsif x >= m + 1 then
		if x >= m + 2 then
			x -= 1
			count += 1
		end

		count += (m / 2 + 1)
		x -= m
	end
	
	x -= 1
}

if x >= 2 then
	count += 1
end

if x >= 3 then
	count += 1
end

if x >= 4 then
	count += 1
end

puts count


Measured memory_bytes: 1788
#include <stdio.h>
int main(void){
    int a,b,c,x;
    scanf("%d",&a);
    while(scanf("%d%d%d",&a,&b,&c)>0){
        int&t=(a>b?a:b);
        if(t>c)x=c,c=t,t=x;
        printf(a*a+b*b==c*c?"YES\n":"NO\n");
    }
    return 0;
}

Measured memory_bytes: 1008
/* 
 * File:   main.cpp
 * Author: administrator
 *
 * Created on 2011å¹´8æ20æ¥, ä¸å1:21
 */

#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#include <set>
#include <math.h>
using namespace std;

/*
 * 
 */
int main(int argc, char** argv) {
    int sumL, sumD, sumM;
    int n;
    int tL1 = 11 * 60, tL2 = 14 * 60 + 59;
    int tD1 = 18 * 60, tD2 = 20 * 60 + 59;
    int tM1 = 21 * 60, tM2 = 25 * 60 + 59;
    while (scanf("%d", &n), n) {
        sumL = sumD = sumM = 0;
        int L = 0, D = 0, M = 0;
        int h, m1, m2;
        while (n-- && scanf("%d:%d %d", &h, &m1, &m2)) {
            if (h < 3)h += 24;
            int t1, t;
            t = h * 60 + m1;
            if (m2 >= m1)t1 = m2 - m1;
            else t1 = m2 + 60 - m1;
            if (t >= tL1 && t <= tL2) {
                sumL++;
                if (t1 <= 8)L++;
            } else if (t >= tD1 && t <= tD2) {
                sumD++;
                if (t1 <= 8)D++;
            } else if (t >= tM1 && t <= tM2) {
                sumM++;
                if (t1 <= 8)M++;
            }
        }
        printf("lunch ");
        if (sumL == 0)puts("no guest");
        else printf("%d\n", 100 * L / sumL);
        printf("dinner ");
        if (sumD == 0)puts("no guest");
        else printf("%d\n", 100 * D / sumD);
        printf("midnight ");
        if (sumM == 0)puts("no guest");
        else printf("%d\n", 100 * M / sumM);
    }
    return 0;
}

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

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

   if(a+b+c>=22) cout<<"bust"<<endl;
   else cout<<"win"<<endl;
   return 0;
}


Measured memory_bytes: 3620
# https://atcoder.jp/contests/abc078/tasks/arc085_a

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


time_trial = 1900 * M + (N - M) * 100

# 1/2**M の確率で打ち切るときの打ち切りまでの平均回数は？
# 無限級数を無理やり数値的に出しちゃうのは？
# mul = 0
# for i in range(1, 100000):
#     mul += i * (1 - ((1 / 2) ** M))**(i - 1) * ((1 / 2) ** M)
# # print(mul)
# from math import ceil
# print(ceil(time_trial * mul))


# 重要な性質→trialを確率pで打ち切るとき、期待されるtrial数は？→1/p
# 1/1-xのマクローリン展開をするとΣの項の形と一致可能。式を整理すると1/pになる
print(time_trial * 2**M)


Measured memory_bytes: 61656
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

typedef struct {
    int a;
    int x[16];
    int y[16];
}human_t;

int cmp(const void* p, const void* q) {
    return ((human_t*)p)->a - ((human_t*)q)->a;
}
void get_binary(int m,int n,int* array) {
    //printf("m=%d\n", m);
    for (int i = 0; i < n;i++) {
        array[i] = m % 2;
        m /= 2;
    }
}
int main() {
    int n,N,i,j,k,ans=0,temp=0;
    human_t human[16] = { 0 };
    int list[16] = { 0 };
    int flag = 0;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &human[i].a);
        for (int j = 0; j < human[i].a; j++) 
            scanf("%d %d", &human[i].x[j], &human[i].y[j]);
    }
    /*
    for (int i = 0; i < n; i++) {
         printf("%d\n", human[i].a);
        for (int j = 0; j < human[i].a; j++)
            printf("%d %d\n", human[i].x[j], human[i].y[j]);
    }
    */
    N = pow(2,n);
    for (i = 0; i < N ; i++) {
        flag = 0;
        temp = 0;
        get_binary(i, n, list);
        //for (int x = 0; x < n; x++) printf("list[%d]=%d\n", x, list[x]);
        for (j = 0; j < n; j++) {
            if (list[j]) {
                for (k = 0; k < human[j].a; k++) {
                    if (human[j].y[k] != list[human[j].x[k] - 1]) {
                        flag = 1;
                        break;
                    }
                }
            }
            if (flag) break;
            else if (j == n - 1) {
                //printf("i=%d\n", i);
                for (int l = 0; l < n; l++) temp += list[l];
                if (temp >= ans) ans = temp;
            }
        }
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

void sout(string* a, string* b) {
	if (*a > * b) {
		string c = *a;
		*a = *b;
		*b = c;
	}
}

int combination(int n, int k) {
	if (n > k && k > 0) {
		return (combination(n - 1, k) + combination(n - 1, k - 1));
	}
	else
		return 1;
}

int main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
using namespace std;
int main(){
	int n,k,p,q,r,s;
	while(cin>>n>>k,n){
		int d[n][n],cost[n]; rep(i,n)rep(j,n)d[i][j]=INF;
		rep(i,k){
			cin>>p>>q>>r,q--,r--;
			if(p)cin>>s,d[q][r]>s?d[q][r]=d[r][q]=s:0;
			else{
				queue<int> F; rep(i,n)cost[i]=INF;
				F.push(q); cost[q]=0;
				while(!F.empty()){
					int c=F.front(); F.pop();
					rep(j,n)if(d[j][c]!=INF&&cost[j]>cost[c]+d[j][c])
					cost[j]=cost[c]+d[j][c],F.push(j);
				}
				cout<<(cost[r]==INF?-1:cost[r])<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 948
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val ss = next().toSet()
    val abc = "abcdefghijklmnopqrstuvwxyz".toList()

    abc.forEach {
        if (!ss.contains(it)) {
            println(it)
            return
        }
    }

    println("None")
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 36716