akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    println!("{}", max_acgt_len(s.as_str()))
}

fn max_acgt_len(s: &str) -> i32 {
    fn inner(rest: &mut std::str::Chars, current: i32, max: i32) -> i32 {
        if let Some(head) = rest.next() {
            if let Some(_) = "ACGT".find(head) {
                let next = current + 1;
                inner(rest, next, if max > next { max } else { next })
            } else {
                inner(rest, 0, max)
            }
        } else {
            max
        }
    }

    inner(&mut s.chars(), 0, 0)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() 
{
  string s; cin >> s;
  int firstTwo = (((int)s[0] -48) * 10) + (int)(s[1] - 48);
  int lastTwo = (((int)s[2] - 48) * 10) + (int)(s[3] - 48);

  if(firstTwo <= 12 && firstTwo)
  {
    if(lastTwo <= 12 && lastTwo)
      cout << "AMBIGUOUS";
    else
      cout << "MMYY";
  }
  else
  {
    if(lastTwo <= 12 && lastTwo)
      cout << "YYMM";
    else
      cout << "NA";
  }
  cout << endl;
}

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

int main() {
    string N;
    int64_t K;
    cin >> N;
    cin >> K;
    
    int64_t n = N.size();
    int64_t dp[110][2][4] = {0};
    
    int64_t n0 = N[0] - '0';
    
    dp[0][0][1] = 1;
    dp[0][1][0] = 1;
    dp[0][1][1] = n0 - 1;
    
    
    for ( int64_t i = 1; i < n; ++i){
        int64_t ni = N[i] - '0';
        if ( ni == 0 ){ // i桁目が0の場合
            // i桁目を0にする
            for ( int64_t j = 0; j <= K; ++j){
                dp[i][0][j] = dp[i][0][j] + dp[i-1][0][j];
            }
        } else { // i桁目が0でない場合
            // i桁目をniにする
            for ( int64_t j = 0; j <= K - 1 ; ++j){
                dp[i][0][j+1] = dp[i][0][j+1] + dp[i-1][0][j];
            }
            // i桁目を(ni>)x(>0)にする
            for ( int64_t j = 0; j <= K - 1 ; ++j){
                dp[i][1][j+1] = dp[i][1][j+1] + ( ni - 1 ) * dp[i-1][0][j];
            }
            for ( int64_t j = 0; j <= K; ++j){
                dp[i][1][j] = dp[i][1][j] + dp[i-1][0][j];
            }
        }
        for ( int64_t j = 0; j <= K; ++j){
            dp[i][1][j] = dp[i][1][j] + dp[i-1][1][j];
        }
        for ( int64_t j = 0; j <= K-1; ++j){
            dp[i][1][j+1] = dp[i][1][j+1] + 9 * dp[i-1][1][j];
        }
    }
    
    cout << dp[n-1][0][K] + dp[n-1][1][K] << endl;
    
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
   string s;
   cin>>s;
   if(s=="SUN") cout<<7<<endl;
   if(s[0]=='M') cout<<6<<endl;
   if(s=="TUE") cout<<5<<endl;
   if(s=="WED") cout<<4<<endl;
   if(s=="THU") cout<<3<<endl;
   if(s=="FRI") cout<<2<<endl;
   if(s=="SAT") cout<<1<<endl;
   
    return 0;
}

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

int main() {
  int A,B,C,X,Y,Z;
  int sum=0;
  cin >> A >> B >> C >> X >> Y;
  if(A + B >= 2*C) { // Cで買ったらお得
    if(X >= Y) { // 2*Y枚はCを買う AのX枚をどっちで買うか
      sum += 2*Y*C;
      sum += min((X-Y)*A, 2*(X-Y)*C);
    } else {
      sum += 2*X*C;
      sum += min((Y-X)*B, 2*(Y-X)*C);
    }
  } else {
    sum += X * A;
    sum += Y * B;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3636
// new day,new strength,new thougts
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) int((c).size())
#define REP(i,n)  for(int i=0;i<int(n);i++)
#define REPD(i,n) for(int i=int(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FORD(i,a,b) for(int i=int(a);i>=int(b);i--)
#define all(s) (s).begin(),(s).end()
#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll mod=1e9+7;
const ll P1=37,P2=109;

map<pair<pll,pll>,ll>mp;
vector<char>ch[2];

pll hsh(vector<char>&v){
    ll nm1=0,nm2=0;
    REP(i,sz(v)){
	nm1=(nm1*P1)+v[i]-'a'+1;
	nm2=(nm2*P2)+v[i]-'a'+1;
	nm1%=mod;
	nm2%=mod;
    }
    return MP(nm1,nm2);
}

int main(){
    ll n;cin>>n;
    string s;cin>>s;
    REP(msk,(1<<n)){
	ch[0].clear();
	ch[1].clear();
	REP(i,n){
	    ch[bit(msk,i)].PB(s[i]);
	}
	mp[MP(hsh(ch[0]),hsh(ch[1]))]++;
    }
    ll ans=0;
    REP(msk,(1<<n)){
	ch[0].clear();
	ch[1].clear();
	REP(i,n){
	    ch[bit(msk,i)].PB(s[i+n]);
	}
	reverse(ch[0].begin(),ch[0].end());
	reverse(ch[1].begin(),ch[1].end());
	ans+=mp[MP(hsh(ch[1]),hsh(ch[0]))];
    }
    cout<<ans;
}


Measured memory_bytes: 41216
import java.util.StringTokenizer;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer str = new StringTokenizer(bfr.readLine());
		
		int N = Integer.parseInt(str.nextToken());
		str = new StringTokenizer(bfr.readLine());
		
		String S = str.nextToken();
		
		if (N %2 == 1) {
			System.out.println("No");
		}
		else {
			
			if (S.substring(0,(N/2)).equals(S.substring(N/2, N))) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
	}

}


Measured memory_bytes: 22356
import math
from functools import reduce

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n,k = get_nums_l()

ans = 0
for init_score in range(1,n+1):
    score = init_score
    # 勝つために連続で表を出さなければならない回数
    need = 0
    while score < k:
        need += 1
        score *= 2

    rate = 1 / 2**need
    ans += rate / n

print(ans)

Measured memory_bytes: 39664
def solve(a, b):
    mod = 1
    while mod != 0:
        mod = b%a
        b = a
        a = mod
    return b

N = int(input())
A = list(map(int, input().split()))

minA = min(A)
B = [a%minA for a in A]
print(solve(minA, max(B)))

Measured memory_bytes: 63468
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n;
    string s;
    int ans=0;
	cin >> n>>s;
    int trmax = n/2;
    int hajime=0;
    for(int i = 1;i<=trmax;i++){
      bool end = true;
      bool tugi = false;
      for(int j = hajime;j<=n-2*i;j++){
        for(int k=j+i;k<=n-i;k++){
          if(s.substr(j, i)==s.substr(k, i)){
            if(hajime<j)hajime=j;
            ans = i;
            tugi = true;
            end = false;
            trmax = min(trmax,max(k-j,n-k));
            break;
          }
        }
      if(tugi)break;
      }
    if(end)break;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>

#define MAX_N 50

int main(int argc, char const *argv[])
{
	int N, d, ans;
	int d_list[MAX_N];

	ans = 0;

	scanf("%d", &N);

	for(int i = 0; i < N; i++)
	{
		scanf("%d", &d_list[i]);
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (i != j)
			{
				d = d_list[i] * d_list[j];
				ans += d;
			}
		}
	}

	ans /= 2;
	printf("%d\n", ans);

}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn=2000+5;
const LL MOD=1e9+7;
int a[maxn],c[maxn],n;
LL k,d,cnt,ans=0;
void modify(int x,int d){
  for(int i=x;i<=2000;i+=i&-i)c[i]+=d;
}
int query(int x){
  int sum=0;
  for(int i=x;i>=1;i-=i&-i)sum+=c[i];
  return sum;
}
int main(){
  scanf("%d%lld",&n,&k);
  for(int i=1;i<=n;i++){
    scanf("%d",&a[i]);
    d=query(2000)-query(a[i]);
    cnt=k&1?(k+1)/2*k%MOD:k/2*(k+1)%MOD;
    ans=(ans+d*cnt%MOD)%MOD;
    modify(a[i],1);
  }
  memset(c,0,sizeof(c));
  for(int i=n;i>=1;i--){
    d=query(2000)-query(a[i]);
    cnt=k&1?(k-1)/2*k%MOD:k/2*(k-1)%MOD;
    ans=(ans+d*cnt%MOD)%MOD;
    modify(a[i],1);
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>


int main(void){
    int s, ans, cnt=1;
    std::cin >> s;
    std::vector<int> d(1000001, 0);
    ++d.at(s);

    while (true){
        ++cnt;
        if (s % 2 == 0) s /= 2;
        else s = 3 * s + 1;
        if (d.at(s) == 1) break;
        ++d.at(s);
    }

    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 7172
require 'set'

r = true
while r do
h, w = readline.split(" ").map(&:to_i)
m = []
h.times do |i|
  m << readline.split("")
end

if h == 0 then
  r = false
  next
end

d = (0...h).map{|y| (0...w).map{|x| lambda {return {x: x, y: y} }}}
s = Set.new

h.times do |y|
  w.times do |x|
    if x-1>=0 && m[y][x]==m[y][x-1] then
      to = d[y][x-1].call
      if !s.delete?(to).nil?
        d[to[:y]][to[:x]] = lambda{ d[y][x].call }
      end
    end
    if y-1>=0 && m[y][x]==m[y-1][x] then
      to = d[y-1][x].call
      if !s.delete?(to).nil?
        d[to[:y]][to[:x]] = lambda{ d[y][x].call }
      end
    end
    s.add({x: x, y: y})
  end
end
p s.count
end


Measured memory_bytes: 18324
#include<bits/stdc++.h> 
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const LL N=200005,mo=1e9+7;
LL n,m,a,b,fac[N+2],inv[N+2];
LL qpow(LL x,LL k)
{
	LL ret=1;
	while(k){
		if(k&1) ret*=x,ret%=mo;
		x*=x;x%=mo;k>>=1;
	}
	return ret;
}
LL C(int x,int y)
{
	return fac[x]*inv[y]%mo*inv[x-y]%mo;
}
int main()
{
	cin>>n>>m>>a>>b;
	fac[0]=1;
	for(int i=1;i<=N;i++) fac[i]=(fac[i-1]*i)%mo;
	inv[N]=qpow(fac[N],mo-2);
	for(int i=N-1;i>=0;i--) inv[i]=(inv[i+1]*(i+1))%mo;
	LL ans=0;
	for(int i=1;i<=n-a;i++){
		LL cur=C(b+i-2,b-1)*C(n-i+m-b-1,m-b-1)%mo;
//		cout<<i<<"  "<<b+i-1<<' '<<b<<' '<<n-i+m-b-1<<' '<<m-b-1<<endl;
//		cout<<C(b+i-1,b)<<' '<<C(n-i+m-b-1,m-b-1)<<endl;
		(ans+=cur)%=mo;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 3456
N = int(input())
A_s = list(map(int, input().split()))

def count_even(num):
    cnt = 0
    
    while (num % 2 == 0):
        num = num // 2
        cnt += 1
    
    return (cnt)

ctr = 0

for i in range(N):
    n = A_s[i]
    ctr += count_even(n)

print(ctr)

Measured memory_bytes: 4148
import java.util.*;

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

		int N = sc.nextInt();
		HashMap<Integer,Integer> map = new HashMap<>();
		
		for (int i=0;i<N;i++){
			int x = sc.nextInt();
			if(map.containsKey(x)){
				map.put(x, map.get(x)+1);
			}else{
				map.put(x, 1);
			}
		}
		
		boolean flag = true;
		
		for(int i=0;i<(N+1)/2&&flag;i++){
			if(N%2==0){
				flag = false;
				if(map.containsKey((i)*2+1)){
					if(map.get((i)*2+1)==2){
						flag=true;
					}
				}
			}
			if(N%2==1){
				if(i==0){
					flag = false;
					if(map.containsKey(0)){
						if(map.get(0)==1){
							flag=true;
						}
					}
				}
				else{
					flag=false;
					if(map.containsKey(2*i)){
						if(map.get(2*i)==2){
							flag=true;
						}
					}
					
				}
			}
		}
		
		if(!flag){
			System.out.println(0);
		}
		else{
			int num = 1;
			for(int i=0;i<N/2;i++){
				num *=2;
				if(num>1000000007){
					num = num% 1000000007;
				}
			}
//			long num = (long)Math.pow(2,(N/2));
//			num = num%1000000007;
			System.out.println(num);
		}
		
	}
	
}

Measured memory_bytes: 51828
K = int(input())
input_line = list(map(int, input().split()))
A = input_line[0]
B = input_line[1] + 1
count = 0

for i in range(A, B):
    if i % K == 0:
        count += 1

if count != 0:
    print('OK')
else:
    print('NG')

Measured memory_bytes: 61780
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
 int H,W,K;
 cin>>H>>W>>K;
 char c[10][10];
 for(int i=0;i<10;i++){
   for(int j=0;j<10;j++){
     c[i][j]='A';
   }
 }
 int kuro=0;
 for(int i=0;i<H;i++){
   for(int j=0;j<W;j++){
     cin>>c[i][j];
     if(c[i][j]=='#'){kuro++;}
   }
 }
int ans=0;int roop=0;
for(int s=0;s<(1<<H+W);s++){
  vector<bool>t(H,false);
  for(int i=0;i<H;i++){
    if((s>>i)&1){t[i]=true;}
  }
  vector<bool>y(W+H+1,false);
  for(int i=H;i<H+W;i++){
    if((s>>i)&1){y[i-H]=true;}
   }
 // for(int p=0;p<H;p++){
   // cout<<t[p];}
  //for(int p=0;p<H;p++){
   // cout<<y[p];}
  //cout<<endl;
  roop++;
  int cnt=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
       if(t[i]||y[j]){if(c[i][j]=='#'){
         cnt++;}}
    }
  }
  if(kuro-cnt==K){ans++;}
 }
cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
   
typedef long long int64;
const int INF = 1 << 30;

int main(){
  int plen, cnum, width, cspace;
  string str;

  while(cin >> plen, plen){
    cin >> cnum;
    cin >> width;
    cin >> cspace;

    vector< string > buffer;
    cin.ignore();
    while(getline(cin, str), str != "?"){
      if(str.empty()){
        buffer.push_back("");
      } else {
        for(int i = 0; i < str.size(); i += width){
          buffer.push_back( str.substr( i, width));
        }
      }
    }
    while(buffer.size() % (plen * cnum) != 0){
      buffer.push_back("");
    }
    for(int i = 0; i < buffer.size() / (plen * cnum); i++){ //ページ数
      for(int j = 0; j < plen; j++){ // 行数
        for(int k = 0; k < cnum; k++){ // 横数
          int pos = i * plen * cnum + j + plen * k;
          cout << (k ? string(cspace,'.') : "") << buffer[pos] << string(width - buffer[pos].size(), '.');
        }
        cout << endl;
      }
      cout << "#" << endl;
    }
    cout << "?" << endl;
  }
}

Measured memory_bytes: 1236
#include<iostream>
using namespace std;
long mod=1e9+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long C(int N,int K)
{
  long x=1,y=1;
  for(int i=1;i<=K;i++)
  {
    x=x*(N-i+1)%mod;
    y=y*i%mod;
  }
  return x*power(y,mod-2)%mod;
}
main()
{
  long N,A,B;
  cin>>N>>A>>B;
  long ans=power(2,N);
  ans-=C(N,A);
  ans-=C(N,B);
  ans--;
  cout<<(ans%mod+mod)%mod<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Abc173
{
    class D
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).OrderByDescending(x => x).ToArray();

            long ans = 0;
            for (int i = 1; i < n; i++)
                ans += a[i / 2];

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 50936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MOD = 998244353;
ll fpow(ll a, ll b, ll m = MOD) {
    ll ans = 1;
    b %= (m - 1); // fermat's little theorem
    a %= m;
    while (b) {
        if (b & 1) {
            ans = ans * a % m;
            b--;
        }
        b >>= 1;
        a = a * a % m;
    }
    return ans;
}
ll dp[3014][3014];
int a[3014];
const ll inv2 = fpow(2, MOD - 2);
int main() {
    int n, s;
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    memset(dp, 0, sizeof(dp));
    dp[0][0] = fpow(2, n);
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= s; j++) {
            dp[i+1][j] += dp[i][j]; dp[i+1][j] %= MOD;
            if (j + a[i] > s) continue;
            dp[i+1][j+a[i]] += dp[i][j] * inv2; dp[i+1][j+a[i]] %= MOD;
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

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

int main() {
  int N, x;
  int a[110];
  cin >> N >> x;
  for(int i=0; i<N; i++) cin>>a[i];

  sort(a, a+N);
  
  int count=0;
  for(int i=0; i<N; i++) {
    if(x<0) break;
    x-=a[i];
    count++;
  }
  if(x!=0) count--;
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define ld long double

int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    //int a[100005];
    int gcd=0;
    int Max=0;
    for(int i = 1;i<=n;i++){
        int x;
        scanf("%d",&x);
        gcd=__gcd(gcd,x);
        Max=max(Max,x);
    }
    if(k%gcd==0&&Max>=k){
        printf("POSSIBLE\n");
    }
    else{
        printf("IMPOSSIBLE\n");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a+b >= 10) cout << "error" << endl;
  else cout << a+b << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			List<long> answerList = new List<long>();
			string[] array = { "", "", "" };

			while (array[1] != "?") {
				array = Console.ReadLine().Split(' ');
				long a = long.Parse(array[0]);
				string op = array[1];
				long b = long.Parse(array[2]);
				long answer = 0;

				if (array[1] == "?") {
					break;
				}

				switch (op) {
					case "+":
					default:
						answer = a + b;
						break;
					case "-":
						answer = a - b;
						break;
					case "*":
						answer = a * b;
						break;
					case "/":
						answer = a / b;
						break;
				}

				answerList.Add(answer);
			}

			foreach (var item in answerList) {
				Console.WriteLine($"{item}");
			}

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 17996
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int a = Integer.parseInt(br.readLine());
        String s = br.readLine();
        
        if ( a < 3200 ) {
            System.out.println("red");
        } else {
            System.out.println(s);
        }
        
    }
}


Measured memory_bytes: 21076
#include <iostream>
#include<stdio.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long int ll;
using namespace std;
 
ll rec(ll x) {
	if (x == 1) {
		return 1;
	}
	if (x == 0) {
		return 0;
	}
	else {
		return 1 + 2 * rec(x / 2);
	}
}
 
int main(void) {
	ll x;
	cin >> x;
	cout << rec(x) << endl;
	return 0;
}

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

using namespace std;

class Point{
public:
  double x, y;
  int n;
  bool operator < (const Point &s)const{
    if(x==s.x) return y<s.y;
    else return x<s.x;
  }
};

main(){
  int n;
  Point in[100];
  while(1){
    cin >> n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      scanf("%lf,%lf", &in[i].x, &in[i].y);
    }
    sort(in, in+n);
    for(int i=0;i<n;i++) in[i].n=i;
    vector<Point> data;
    Point p, q, r;
    data.push_back(in[0]);
    data.push_back(in[1]);
    for(int i=2;i<n;i++){
      while(1){
	if(i>=n) break;
	p=data[data.size()-2];
	q=data[data.size()-1];
	r=in[i];
	if((q.x-p.x)*(r.y-q.y)-(q.y-p.y)*(r.x-q.x)<=0){
	  data.push_back(r);
	  break;
	}else{
	  data.pop_back();
	  if(data.size()<2){
	    data.push_back(r);
	    i++;
	  }
	}
      }
    }
    bool use[100];
    for(int i=0;i<n;i++) use[i]=false;
    vector<Point>::iterator ite=data.begin();
    for(;ite!=data.end();ite++){
      use[(*ite).n]=true;
    }
    data.clear();
    data.push_back(in[n-1]);
    data.push_back(in[n-2]);
    for(int i=n-3;i>=0;i--){
      while(1){
	if(i<0) break;
	p=data[data.size()-2];
	q=data[data.size()-1];
	r=in[i];
	if((q.x-p.x)*(r.y-q.y)-(q.y-p.y)*(r.x-q.x)<=0){
	  data.push_back(r);
	  break;
	}else{
	  data.pop_back();
	  if(data.size()<2){
	    data.push_back(r);
	    i--;
	  }
	}
      }
    }
    ite=data.begin();
    for(;ite!=data.end();ite++) use[(*ite).n]=true;
    int ans=0;
    for(int i=0;i<n;i++){
      if(!use[i]) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
from collections import defaultdict
N = int(input())
d = defaultdict(int)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n = x*x+y*y+z*z+x*y+y*z+z*x
            d[n]+=1
for i in range(1,N+1):
    print(d[i])

Measured memory_bytes: 11944
#include<stdio.h>

int main(){
  int a[3], b[3];

  int i;

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

  int c = 0;
  int k[4] = {};

  for(i = 0; i < 3; i++){
    k[a[i]-1]++;
    k[b[i]-1]++;
  }
  
  int d = 0;

  for(i = 0; i < 4; i++){
   if(k[i] == 1) d++;
   else if(k[i] == 2) c++;
  }

  if(d == 2 && c == 2) printf("YES\n");
  else printf("NO\n");

  return 0;
}


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

int main(void)
{
    string S;
    cin >> S;
    
    for( char c = 'a'; c <= 'z'; c++){
        if(count(S.begin(), S.end(), c) == 0){
            cout << c;
            return 0;
        }
    }

    cout << "None";

    return 0;
}

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

#define INF 2000000000

int a[100005] ;

int lis(int n)
{
    vector <int> l ;
    for(int i=0 ; i<=n ; i++) l.push_back( INF ) ;
    l[0] = -INF ;

    int ans = 0 ;

    for(int i=1 ; i<=n ; i++)
    {
        int idx = upper_bound( l.begin() , l.end() , a[i] ) - l.begin() ;
        ans = max(ans,idx) ;
        l[idx] = a[i] ;
    }
    return ans ;
}

int main()
{
    int n ;
    scanf("%d",&n) ;

    for(int i=1 ; i<=n ; i++) scanf("%d",&a[n-i+1]) ;

    printf("%d\n" , lis(n) ) ;

    return 0 ;
}



Measured memory_bytes: 1276
#include <stdio.h>

int main(void)
{
	int n;
	
	scanf("%d",&n);
	
	int v[n];
	int c[n];
	
	int i;
	int sum = 0;
	
	for(i = 0; i < n; i++){
		scanf("%d",&v[i]);
	}
	
	for(i = 0; i < n; i++){
		scanf("%d",&c[i]);
	}
	
	for(i = 0; i < n; i++){
		if(v[i] - c[i] > 0){
			sum = sum + v[i] - c[i];
		}
	}
	
	printf("%d",sum);
	
	return 0;
}	

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

#define ll long long
#define N 2010
const int p = 1e9 + 7;
int n, k;
ll fac[N], inv[N];
ll qmod(ll base, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1) {
			res = res * base % p;
		}
		base = base * base % p;
		n >>= 1;
	}
	return res;
}

ll C(int n, int m) {
	if (n < m) return 0;
	return fac[n] * inv[m] % p * inv[n - m] % p;
}

ll f(int n, int i, int k) {
	ll remind = n - k;
	if (n - k < i - 1) {
		return 0;
	}
	remind -= i - 1;
	return C(k - 1, i - 1) * C(i + remind, i) % p;
}

int main() {
	fac[0] = 1;
	for (int i = 1; i <= 2000; ++i) {
		fac[i] = fac[i - 1] * i % p;
	}
	inv[2000] = qmod(fac[2000], p - 2);
	for (int i = 2000; i >= 0; --i) {
		inv[i - 1] = inv[i] * i % p;
	}
	while (scanf("%d%d", &n, &k) != EOF) {
		for (int i = 1; i <= k; ++i) {
			printf("%lld\n", f(n, i, k));
		}
	}
	return 0;
}


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

int main() {
  int number1, number2, number3, number4;
  
  cin >> number1 >> number2;
  
  number3 = number1 + number2;
  
  if (number3 % 2 == 0) {
    number4 = number3 / 2;
  } else {
    number4 = number3 / 2 + 1;
  }
  cout << number4 << endl;
}

Measured memory_bytes: 256
class BIT
    def initialize(n)
        @n = n
        @dat = Array.new(@n, 0)
    end

    def sum(i)
        s = 0
        while i >= 0 do
            s += @dat[i]
            i = (i & (i+1)) - 1
        end
        s
    end

    def sum_between(a, b)
        sum(b) - sum(a-1)
    end

    def add(i, x)
        while i < @n do
            @dat[i] += x
            i |= i+1
        end
    end

    def lower_bound(x)
        ret = -1
        k = 1
        k <<= 1 while 2*k <= @n
        while k > 0
            if ret+k < @n && @dat[ret+k] < x
                x -= @dat[ret+k]
                ret += k
            end
            k >>= 1
        end
        ret + 1
    end
end

N = gets.to_i
A = gets.split.map(&:to_i)
hash = Hash.new(0)
A.each do |a|
    hash[a] += 1
end
cmp = hash.keys.sort.reverse
sz = cmp.size
nums = sz.times.map{|i| hash[cmp[i]]}

bit = BIT.new(sz)
slimes = [0]
nums[0] -= 1
sz.times do |i|
    bit.add(i, nums[i])
end

N.times do
    slimes2 = []
    slimes.each do |a|
        i = bit.lower_bound(bit.sum(a)+1)
        if i == sz
            puts "No"
            exit
        end
        bit.add(i, -1)
        slimes2.push(i)
    end
    slimes.concat(slimes2)
end
puts "Yes"

Measured memory_bytes: 55692
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=200010, LOG=20;

int n, m, k=inf, u, v, x, y, t, a, b, ans;
int A[MAXN];
int dp[MAXN];
string S;

inline void fix(int &x){
	if (x>=mod) x-=mod;
	if (x<0) x+=mod;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m>>S;
	for (int i=0; i<m; i++) if (S[i]=='R') S[i]='A'; // :(
	if (S[0]=='B'){
		for (int i=0; i<m; i++) S[i]='A'+'B'-S[i];
	}
	while (S.size()>1 && S.back()=='A') S.pop_back();
	m=S.size();
//	debug(S)
	if (m==1){
		dp[1]=1;
		for (int i=3; i<=n; i++){
			fix(dp[i]=dp[i-1]+dp[i-2]);
		}
		ans=n+1;
		for (int i=3; i<n; i++) ans=(ans + (n-i+1ll)*dp[i])%mod;
		fix(ans);
		cout<<ans<<"\n";
		
		return 0;
	}
	if (n&1) kill(0)
	for (int i=0, j=0; i<m; i=j){
		if (S[i]=='B') j++;
		else{
			while (S[j]=='A' && j<m) j++;
			if (i==0 || (j-i)%2==1) k=min(k, j-i);
		}
	}
//	debug(k)
	k>>=1;
	n>>=1;
//	debug2(n, k)
	dp[0]=1;
	dp[1]=1+(k>=1);
	for (int i=2; i<=n; i++){
		fix(dp[i]=2*dp[i-1]-(k>=i-1)+(k>=i));
		if (i>=k+2) fix(dp[i]-=dp[i-k-2]);
	}
//	debug(dp[1])
//	debug(dp[2])
//	debug(dp[3])
	
	for (int i=0; i+2<=n; i++) if (n-i-2<=k) ans=(ans + (n-i-1ll)*dp[i])%mod;
	if (n-1<=k) fix(ans+=n);
	fix(ans*=2);
	fix(ans);
	cout<<ans<<"\n";
	
	return 0;
}
/*
12 5
AAAAB

6 5
RRRRB

6 5
RRBRB


*/

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

int main() {
	int i, n[30]={0};
	while(cin >> i){
		n[i]++;
	}
	for(int j=1; j<30; j++){
		if(n[j]==0) cout << j << endl;
	}
	if(n[30]==0) cout << "30" << endl;
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int n, m, s, t;
vector<vector<pair<long, pair<long, long>>>> graph(100005);

void dijkstra(long s, vector<long> &dist, bool isYen) {
  priority_queue<pair<long,long>, vector<pair<long, long>>, greater<>> queue;
  queue.push(make_pair(0, s));
  while (!queue.empty()) {
    pair<long, long> p = queue.top();
    queue.pop();
    long start = p.second;
    long d = p.first;
    if (d > dist.at(start)) {
      continue;
    }
    for (auto e : graph.at(start)) {
      long end = e.first;
      long cost = isYen ? e.second.first : e.second.second;
      if (dist.at(end) > d + cost) {
        dist.at(end) = d + cost;
        queue.push(make_pair(dist.at(end), end));
      }
    }
  }
}

int main() {
  cin >> n >> m >> s >> t;

  for (int i=1; i<=m; i++) {
    long u,v,a,b;
    cin >> u >> v >> a >> b;
    graph.at(u).push_back(make_pair(v, make_pair(a, b)));
    graph.at(v).push_back(make_pair(u, make_pair(a, b)));
  }

  vector<long> dist1(n+1);
  vector<long> dist2(n+1);
  for (int i=1; i<=n; i++) {
    dist1.at(i) = LONG_MAX;
    dist2.at(i) = LONG_MAX;
  }
  dist1.at(s) = 0;
  dist2.at(t) = 0;

  dijkstra(s, dist1, true);
  dijkstra(t, dist2, false);

  vector<long> dvec(n+1);
  dvec.at(n) = dist1.at(n) + dist2.at(n);
  for (int i=n-1; i>=1; i--) {
    dvec.at(i) = dist1.at(i) + dist2.at(i);
    dvec.at(i) = min(dvec.at(i), dvec.at(i+1));
  }
  long init = 1;
  for (int i=1; i<=15; i++) {
    init *= 10;
  }
  for (int i=1; i<=n; i++) {
    cout << init-dvec.at(i) << endl;
  }
}


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

int main(){
  long long dp[35] = {0LL};

  dp[0] = 1;

  for(int i = 0; i < 30; i++){
    dp[i + 1] += dp[i];
    dp[i + 2] += dp[i];
    dp[i + 3] += dp[i];
  }

  int n;

  while(cin >> n, n){
    cout << ((dp[n] + 9LL) / 10LL + 364) / 365 << endl;
  }
}

Measured memory_bytes: 1156
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
Asorted = sorted(A)[:: -1]


L=[0]*N
R=[0]*N
L[0]=A[0]
R[0]=A[N-1]

for n in range(1,N):
  L[n]=gcd(A[n],L[n-1])
  R[n]=gcd(A[N-n-1],R[n-1])
  
  ans=max(L[N-2],R[N-2])

for i in range(1,N-1):
  ans=max(ans,gcd(L[i-1],R[N-i-2]))

print(ans)

Measured memory_bytes: 16112
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define FASTNIBBA   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define lbnd        lower_bound
#define ubnd        upper_bound
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
#define endl        '\n'
int dp[100005][3];
void solve()
{
   int n; cin>>n;
   int a[n][3];
   rep(i,0,n) cin>>a[i][0]>>a[i][1]>>a[i][2];
   dp[0][0]=a[0][0],dp[0][1]=a[0][1],dp[0][2]=a[0][2];
   rep(i,1,n)
   {
         dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
         dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
         dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
   }
   int ans=0;
   rep(i,0,3)
   {
     ans=max(ans,dp[n-1][i]);
   }
   cout<<ans;
}
int main()
{
    FASTNIBBA;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n, q;
	cin >> n >> q;
	vector<vector<int>> v(n + 1, vector<int>(0));
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	vector<long long int> increment(n + 1, 0);
	vector<long long int> res(n + 1, -1);
	for (int i = 0; i < q; i++) {
		int p, x;
		cin >> p >> x;
		increment[p] += x;
	}
	vector<int> nodes(1, 1);
	res[1] = increment[1];
	while (nodes.size() > 0) {
		int node = nodes.back();
		nodes.pop_back();
		for (auto next : v[node]) {
			if (res[next] == -1) {
				nodes.push_back(next);
				res[next] = res[node] + increment[next];
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << res[i] << " ";
	}
	cout << endl;
}


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

bool activ[200010];
vector <int> adia[200010];
bool viz[200010];
int val[200020];
int f[200010];
int frc[200010];

bool dfs(int nod);
int set_val(int nod);
bool set_parinti(int nod, int init);

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

	int n, a;
	cin >> n;

	for (int i(0); i <= n; i++)
		val[i] = -1;

	for (int i(1); i <= n; i++) {
		cin >> a;
		f[i] = a;
		adia[a].push_back(i);
	}

	for (int i(1); i <= n; i++)
		dfs(i);

	int cnt(0);
	for (int i(1); i <= n; i++)
		if (activ[i])
			cnt++;

	for (int i(1); i <= n; i++) {
		if (activ[i])
			for (auto j : adia[i])
				if (!activ[j])
					frc[set_val(j)]++;
	}
	int q;

	for (int i(0); ; i++) {
		if (frc[i] != cnt) {
			q = i;
			break;
		}
	}

	for (int i(1); i <= n; i++) {
		if (!activ[i])
			continue;
		bool gas(0);
		for (auto j : adia[f[i]])
			if (val[j] == q && !activ[j])
				gas = 1;
		if (!gas) {
			val[i] = q;
			bool ok(1);
			for (auto j : adia[i])
				if (!activ[j] && val[j] == q)
					ok = 0;
			if (set_parinti(f[i], i) && ok) {
				cout << "POSSIBLE";
				return 0;
			}
			val[f[i]] = q;
			if (set_parinti(f[f[i]], f[i])) {
				cout << "POSSIBLE";
				return 0;
			}

			cout << "IMPOSSIBLE";
			return 0;
		}
	}

	return 0;
}

bool set_parinti(int nod, int init)
{
	vector <int> v;
	for (auto i : adia[nod])
		v.push_back(val[i]);
	sort(v.begin(), v.end());
	int x(0);
	for (auto i : v) {
		if (i == x)
			x++;
		else if (i > x)
			break;
	}
	if (nod == init && val[nod] != x)
		return false;
	else if (nod == init)
		return true;
	val[nod] = x;
	return set_parinti(f[nod], init);
}

int set_val(int nod)
{
	if (val[nod] != -1)
		return val[nod];
	vector <int> v;
	for (auto i : adia[nod])
		v.push_back(set_val(i));
	sort(v.begin(), v.end());
	int x(0);
	for (auto i : v) {
		if (i == x)
			x++;
		else
			break;
	}
	val[nod] = x;
	return x;
}

bool dfs(int nod)
{
	if (viz[nod])
		return false;
	viz[nod] = 1;
	activ[nod] = 1;
	for (auto i : adia[nod]) {
		if (activ[i])
			return true;
		if (dfs(i))
			return true;
	}
	activ[nod] = 0;
	return false;
}


Measured memory_bytes: 33024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int ans=0,count;
	string s,t;	cin>>s>>t;
	FOR(i,0,s.size()-t.size()+1){
		count=0;
		FOR(j,0,t.size()){
			if(s[i+j]==t[j])	count++;
		}
		//cout<<count<<endl;
		if(ans<count)	ans=count;
	}

	cout<<t.size()-ans<<endl;


    return 0;
}



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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int H,W;
    Scd2(H,W);

    static char S[2111][2111];
    static int l[2111][2111] = {};
    static int t[2111][2111] = {};
    Rep(i,H){
        Scs(S[i]);
    }

    int cnt = 0;
    Rep(i,H){
        cnt = 0;
        Rep(j,W){
            if( S[i][j] == '#' ){
                cnt = 0;
            }else{
                cnt++;
                l[i][j] = cnt;
            }
        }
        cnt = 0;
        Rep(k,W){
            int j = W - k - 1;
            if( S[i][j] == '#' ){
                cnt = 0;
            }else{
                if( cnt == 0 )
                    cnt = l[i][j];
                l[i][j] = cnt;
            }
        }
    }
    Rep(j,W){
        cnt = 0;
        Rep(i,H){
            if( S[i][j] == '#' ){
                cnt = 0;
            }else{
                cnt++;
                t[i][j] = cnt;
            }
        }
        cnt = 0;
        Rep(k,H){
            int i = H - k - 1;
            if( S[i][j] == '#' ){
                cnt = 0;
            }else{
                if( cnt == 0 )
                    cnt = t[i][j];
                t[i][j] = cnt;
            }
        }
    }
    int ans = 0;
    Rep(j,W){
        Rep(i,H){
            ans = max( ans, t[i][j]+l[i][j]-1  );
        }
    }
    printf ("%d\n", ans );


    return 0;
}



Measured memory_bytes: 39168
n = int(input())
a = list(map(int,input().split()))

sum1 = [0] * n
sum2 = [0] * n
sum1[0] = a[0]
sum2[-1] = a[n - 1]

for i in range(1, n):
    sum1[i] = sum1[i - 1] + a[i]
    sum2[-i - 1] = sum2[-i] + a[-i - 1]

d = 10 ** 10
index = 0

for i in range(n - 1):
    if abs(sum1[i] - sum2[i + 1]) < d:
        d = abs(sum1[i] - sum2[i + 1])

print(d)

Measured memory_bytes: 28640
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
	
}


Measured memory_bytes: 3552
import sys
def input(): return sys.stdin.readline().strip()


def main():
    s = input()
    l = len(s)
    forward = 0
    while s[forward] != "A": forward += 1
    back = -1
    while s[back] != 'Z': back -= 1
    print(l - forward + back + 1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 64060
#include <iostream>
#include <math.h>
#include <iomanip>
#include <algorithm>
#include <limits.h>

using namespace std;

int main()
{
    double p;
    int n,i;
    double s1=0,s2=0,s3=0,x[100],y[100],max=INT_MIN;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x[i];
    }
    for(i=1;i<=n;i++)
    {
        cin>>y[i];
    }
    for(i=1;i<=n;i++)
    {
        if(x[i]<y[i]) swap(x[i],y[i]);
        s1+=(x[i]-y[i]);
        s2+=(x[i]-y[i])*(x[i]-y[i]);
        s3+=(x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]);
        if(x[i]-y[i]>max) max=x[i]-y[i];
    }
    p = (double) 1/3;
    cout<<fixed<<setprecision(7)<<s1<<"\n"<<sqrt(s2)<<endl;
    cout<<pow(s3,p)<<"\n"<<max;
    return 0;
}



Measured memory_bytes: 3476
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
#include <utility>
using namespace std;
using P = pair<int,int>;
using ll = long long;
const int MOD=1e9+7;
int main(){
    ll n;
    cin>>n;
    ll ret=0;
    for(ll i=1;i<=n;i++){
        ret+=n/i*(i+n/i*i)/2;
    }
    cout<<ret<<endl;
}

Measured memory_bytes: 3604
mod = 1000000007
import sys
sys.setrecursionlimit(1000000)
x, y = map(int, input().split())
a = ((2*x-y)//3)
b = ((2*y-x)//3)
if (x+y) % 3 != 0 or a < 0 or b < 0:
    print(0)
else:
    n = (a + b)%mod
    kaijo = [1, 1]
    for i in range(2, n+1):
        kaijo.append(i*kaijo[i-1]%mod)
    def mul(a, b):
        return ((a % mod) * (b % mod)) % mod
    def power(x, y):
        if y == 0:
            return 1
        elif y == 1:
            return x % mod
        elif y % 2 == 0:
            return power(x, y // 2) ** 2 % mod
        else:
            return power(x, y // 2) ** 2 * x % mod
    def div(a, b):
        return mul(a, power(b, mod - 2))
    n_a = div(kaijo[n], kaijo[a])
    ans = div(n_a, kaijo[n-a])
    print(ans)

Measured memory_bytes: 86704
A,B,C=input().split()
k=int(input())
a=int(A)
b=int(B)
c=int(C)
if a>=b:
  if a>=c:
    a=a*(2**k)
    print(a+b+c)
  else:
    c=c*(2**k)
    print(a+b+c)
else:
  if b>=c:
    b=b*(2**k)
    print(a+b+c)
  else:
    c=c*(2**k)
    print(a+b+c)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class  Main{
	static int mod=(int)1e9+7;
    public static void main(String[] args) throws Exception{
        //MScanner sc = new MScanner("chess.in");
        MScanner sc = new MScanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        int n=sc.nextInt();
        int[]in=new int[n];
        for(int i=0;i<n;i++) {
        	in[i]=sc.nextInt();
        	
        }
        int[]val=new int[n];
        int c=0;
        for(int i=n;i>0;i--) {
        	int sum=0;
        	int j=i-1;
        	while(j<n) {
        		sum+=val[j];j+=i;
        	}
        	if(sum%2!=in[i-1]) {
        		val[i-1]=1;c++;
        	}
        }
        pw.println(c);
        for(int i=0;i<n;i++) {
        	if(val[i]!=0) {
        		pw.println(i+1);
        	}
        }
        pw.flush();
    }
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 45012
#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    map<int,int> cnt;
    bool ok0 = false;
    for (int i = 0; i < n; ++i)
    {
        static int x;
        scanf("%d", &x);
        if (x == 0) ok0 = true;
        ++cnt[x];
    }
    if ((int)cnt.size() > 3)
        printf("No");
    else if ((int)cnt.size() == 1)
    {
        if (ok0)
            printf("Yes");
        else
            printf("No");
    }
    else if ((int)cnt.size() == 2)
    {
        if (!ok0)
            printf("No");
        else
        {
            if (n % 3 == 0 && cnt[0] == n / 3)
                printf("Yes");
            else
                printf("No");
        }
    }
    else
    {
        vector<int> v;
        int sum = 0;
        for (auto pr : cnt)
        {
            v.push_back(pr.second);
            sum ^= pr.first;
        }
        if (sum == 0 && v[0] == v[1] && v[1] == v[2])
            printf("Yes");
        else
            printf("No");
    }
}


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

int main(void){
	ll N,M,res;
	cin>>N>>M;
	if(M-2*N >= 0)res = (M-2*N)/4 + N;
	else res = M/2;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=1e18;

vector<ll> prime(){
    vector<ll> res;
    vector<bool> is_prime(55556,true);
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i*i<=55555;i++){
        if(!is_prime[i]) continue;
        for(int j=i*2;j<=55555;j+=i) is_prime[j]=false;
    }
    for(int i=0;i<=55555;i++){
        if(is_prime[i]) res.push_back(i);
    }
    return res;
}
int main(){
    int n;cin>>n;
    vector<ll> res=prime(),ans;
    for(auto it:res)if(it%5==2) ans.push_back(it);
    for(int i=0;i<n;i++){
        cout<<ans[i];
        if(i<n-1) cout<<' ';
    }
    cout<<endl;
    return 0;
}

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

using namespace std;

int main() {
    long long int A, B;
    cin >> A >> B;
    if(B-A+1>=2019) {
        cout << 0 << endl;
    } else {
        long long int ans=2020;
        for(long long int a=A; a<B; a++) {
            for(long long int b=a+1; b<=B; b++) {
                ans = min(ans, a*b%2019);
            }
        }
        cout << ans << endl;
    }


    return 0;
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
struct nd{int id,y,p,ans;}a[100005];
int cmp1(const nd &a,const nd &b) {return a.p<b.p||a.p==b.p&&a.y<b.y;}
int cmp2(const nd &a,const nd &b) {return a.id<b.id;}
void wrt(int x)
{
	int s=100000;
	while(s>x) printf("0"),s/=10;
	printf("%d",x);
}
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d%d",&a[i].p,&a[i].y),a[i].id=i;
	sort(a+1,a+m+1,cmp1);
	int cnt;
	for(int i=1;i<=m;i++)
	{
		if(i==1||a[i].p!=a[i-1].p) cnt=1;
		a[i].ans=cnt;cnt++;
	}
	sort(a+1,a+m+1,cmp2);
	for(int i=1;i<=m;i++)
	{
		wrt(a[i].p);wrt(a[i].ans);
		printf("\n");
	 } 
	return 0;
}

Measured memory_bytes: 2944