akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N, K;
    cin >> N >> K;
    vector<ll> x;
    rep(i, N) {
        ll a;
        cin >> a;
        if (a == 0) {
            K--;
            N--;
        } else
            x.push_back(a);
    }

    if (x.empty()) {
        cout << 0 << endl;
        return 0;
    }

    int a = lower_bound(all(x), 0) - x.begin();
    ll ans = INF;
    int s = a - K, t = a - 1;
    int cnt = 0;
    while (cnt <= K) {
        if (s < 0 || t >= N) {
            cnt++;
            s++;
            t++;
            continue;
        } else if (x[s] * x[t] < 0) {
            ans = min(ans, abs(x[s] * 2) + abs(x[t]));
            ans = min(ans, abs(x[s]) + abs(x[t] * 2));
        } else
            ans = min(ans, max(abs(x[s]), abs(x[t])));
        cnt++;
        s++;
        t++;
    }

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

Measured memory_bytes: 4264
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <set>
#include <sstream>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <queue>
#include <map>
#include <cstdlib>
#include <vector>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;

ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
ll maxx,ans,tmp1,tmp2;
int main(){
    ll a,b,c;
    a=read();b=read();c=read();
    if (a<=c&&b<=c){
        tmp1=a;
        tmp2=b;
    }else if (a>=b && a>=c){
        tmp1=b;tmp2=c;
    }else {
        tmp1=a;
        tmp2=c;
    }

    if (a%2==0||b%2==0||c%2==0) printf("0");
    else printf("%lld",tmp1*tmp2);
}

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

using namespace std;

int dp[31];

int main()
{
  dp[0] = 1;
  dp[1] = 1;
  dp[2] = 2;
  for(int i = 3; i <= 30; i++){
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
  }
  int n;
  while(cin >> n, n){
    cout << dp[n] / 10 / 365 + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;
int main(){
    int x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int saa = x2-x1;
    int sab = y2-y1;
    cout << x2-sab << ' ' <<  y2+saa << ' ' <<  x2-sab-saa << ' ' << y2+saa - sab << endl;
    return 0;
    
}

Measured memory_bytes: 256
r,D, x_2000 = map(int,input().split())


def add(x):
    a = r * x - D
    return a

x_2001 = add(x_2000)
x_2002 = add(x_2001)
x_2003 = add(x_2002)
x_2004 = add(x_2003)
x_2005 = add(x_2004)
x_2006 = add(x_2005)
x_2007 = add(x_2006)
x_2008 = add(x_2007)
x_2009 = add(x_2008)
x_2010 = add(x_2009)

print(x_2001)
print(x_2002)
print(x_2003)
print(x_2004)
print(x_2005)
print(x_2006)
print(x_2007)
print(x_2008)
print(x_2009)
print(x_2010)

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

using namespace std;
using ll = long long;

const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    COMinit();
    int ans = 0;
    vector<ll> pw(n, -1);
    pw[0] = 1;
    for(int i = 1; i < n; i++){
        pw[i] = pw[i-1] * (m-1) % MOD;
    }
    for(int i = 0; i <= k; i++){
        ll temp = m * COM(n-1, i) % MOD * pw[n-1-i] % MOD;
        ans = (ans + temp) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 16716
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=1000000007;

int main() {
  vector<string> ans;
  string S;
  cin>>S;
  int k=S.size();
  vector<string> T(k);
  for(int i=0;i<k;i++) {
    char temp=S.at(i);
    T.at(i)=temp;
  }
  int a=min(k,5);
  for(int i=0;i<a;i++){
    for(int j=0;j<k-i;j++){
      string d;
      if(i==0) d=T.at(j);
      if(a>1&&i==1) d=T.at(j)+T.at(j+1);
      if(a>2&&i==2) d=T.at(j)+T.at(j+1)+T.at(j+2);
      if(a>3&&i==3) d=T.at(j)+T.at(j+1)+T.at(j+2)+T.at(j+3);
      if(a>4&&i==4) d=T.at(j)+T.at(j+1)+T.at(j+2)+T.at(j+3)+T.at(j+4);
      ans.push_back(d);
    }
  }
  int W;
  cin>>W;
  sort(ans.begin(),ans.end());
  int i=1,count=1;
  while(true){
    if(S.size()==1){
      cout<<S.at(0);
      break;
    }
    if(ans.at(i)!=ans.at(i-1)) count++;
    if(count==W){
      cout<<ans.at(i);
      break;
    }
    i++;
  }
}


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

int main(){
    string s;
    cin >> s;
    int counter = 0;
    if(s[0] == '1') ++counter;
    if(s[1] == '1') ++counter;
    if(s[2] == '1') ++counter;
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
int main(void){
	int n;
	int max=INT_MIN;int min=INT_MAX; long sum=0;int i;
	int temp=0;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d",&temp);
		if(temp>max)max=temp;
		if(temp<min)min=temp;
		sum+=temp;
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}




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

long long nod(long long n){

    if(n == 0)
        return 1;
    long long ans = 0;
    while(n > 0){

        n = n / 10;
        ans = ans + 1;
    }
    return ans;
}

long long func(long long n){

    long long ans = nod(n);
    for(long long i=1;i<=sqrt(n);i++){

        if(n%i == 0){

            long long ans1 = nod(i);
            long long ans2 = nod(n/i);
            ans = max(ans,max(ans1,ans2));
        }
    }
    return ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

long long a,b;
cin >> a >> b;
cout << (a + b)%24 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int H, W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		REP(i, H) {
			REP(j, W) {
				if (i == 0 || i == H - 1) {
					cout << "#";
				} else {
					if (j == 0 || j == W - 1) cout << "#";
					else cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define  X first
#define  Y second

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

const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 998244353;

int a[maxN];
int b[maxN];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	while(k--)
	{
		for(int i=1;i<=n;i++)
		{
			int L = max(1,i-a[i]);
			int R = min(n,i+a[i]);
			b[L]+=1;
			b[R+1] -= 1;	
		} 
		for(int i=1;i<=n;i++)
		{
			b[i] += b[i-1];
		}
		int flag = 0;
		for(int i=1;i<=n;i++)
		{
			a[i] = b[i];
			if(a[i] < n)
				flag = 1;
			else
			{
				a[i] = n;
			}
			b[i] = 0;
		}
		if(!flag)
			break;
	}
	for(int i=1;i<n;i++)
	{
		printf("%d ",a[i]);
	}
	printf("%d\n",a[n]);
	return 0;
}

Measured memory_bytes: 5372
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c)cout<<"Yes";
	else cout<<"No";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3532
#include<iostream>
using namespace std;
int main(){
  int n,x[100],i,j,min=100000000,sum=0;
  cin >> n;
  for(i=0; i<n; i++){
    cin >> x[i];
  }
  for(i=1; i<100; i++){
    sum=0;
    for(j=0; j<n; j++){
      sum+=(x[j]-i)*(x[j]-i);
    }
    if(sum<min){
      min=sum;
    }
  }
  cout << min << endl;
 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll n;
ll cal1(ll x)
{
	ll res=1;
	for(ll i=2;i<=x/i;i++){
		if(x%i==0){
			res+=2;
			if(x/i==i)res--;
		}
	}
	return res;
}
ll cal2(ll x)
{
	ll res=1;
	for(ll i=2;i<=x/i;i++)
	{
		if(x%i==0){
			ll tmp=x;
			while(tmp%i==0){
				tmp/=i;
			} 
			if(tmp%i==1){
				res++;
			}
			if(x/i==i){
				continue;
			}
			tmp=x;
			ll ii=tmp/i;
			while(tmp%ii==0){
				tmp/=ii;
			}
			if(tmp%ii==1){
				res++;
			}
		}
	}
	return res;
}
int main(){
	scanf("%lld",&n);
	if(n==2){
		printf("1");
		return 0;
	}
	ll ans=cal1(n-1)+cal2(n);
	printf("%lld",ans);
	
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
string s,l,x;
bool a_u,b_u;
int lflag,xflag;
int main(){
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(a_u==0){
			l+='0';
			a_u=1;
			b_u=0;
		}
		else {
			l+='1';
			b_u=1;
			a_u=0;
		}
	}
	for(int i=0;i<s.length();i++){
		if(b_u==0) {
			x+='1';
			b_u=1;
			a_u=0;
		}
		else{
			x+='0';
			a_u=1;
			b_u=0;
		}
	}
	for(int i=0;i<s.length();i++){
		if(s[i]==l[i]){
			lflag++;
		}
		else{
			xflag++;
		}
	}
	cout<<min(lflag,xflag);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,c[4010],a[4010],
    pos[2010],pos1[2010],
    dp[2010][2010],
    cost[4010][2010],cost1[4010][2010];
    
    
    
int main()
{
    
    
    
    //color
    
    scanf("%d",&n);
    for (int i=1;i<=2*n;i++)
    {
        char s;
        cin>>s>>a[i];
        c[i]=(s=='W'?0:1);
        if(c[i]==0) pos[a[i]]=i; else pos1[a[i]]=i;
    }
    
    
    
    

    
    for (int i=1;i<=2*n;i++) for (int j=0;j<n;j++)
    {
        cost[i][j]=cost[i-1][j]+(a[i-1]>j&&c[i-1]==0);
        cost1[i][j]=cost1[i-1][j]+(a[i-1]>j&&c[i-1]==1);
    }




    for (int i=0;i<=n;i++) for (int j=0;j<=n;j++)
    {
        if (i==0 &&j==0) continue;
        dp[i][j]=0x3f3f3f3f;
        
        int p=pos[i];
        if (i) dp[i][j] = min(dp[i][j],dp[i-1][j]+cost[p][i-1]+cost1[p][j]);



        int p1=pos1[j];
        if (j) dp[i][j] = min(dp[i][j],dp[i][j-1]+cost1[p1][j-1]+cost[p1][i]);
    }


    cout<<dp[n][n]<<endl;


    return 0;
}

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

class Program{


  static int Main() {

    int a = 0;
    string nyu = Console.ReadLine();

    for(int i = 0; i < nyu.Length-1; i++){
      if (nyu[i] != nyu[i+1]) a ++;
    }

    Console.WriteLine("{0}", a);

    return 0;
  }

}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


string Main(int N, VI &P)
{
    int counter = 0;
    REP(i, N) if(P[i] != i+1) counter++;
    return (counter == 2 || counter == 0) ? "YES" : "NO";

}

int main(void){
    int N;
    cin >> N;
    VI P(N);
    REP(i, N) cin >> P[i];
    cout << Main(N, P) << endl;
    return 0;
}

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

using namespace std;
using LL = long long;
int Xx[1000];
int Yy[1000];
int Zz[1000];
int main()
{
    int N;cin >> N;
    int X;cin >> X;
    for(int a = 0;a < X;a++){
        int s;cin >> s;
        Xx[s]=1;
    }
    int Y;cin >> Y;
    for(int a = 0;a < Y;a++){
        int s;cin >> s;
        Yy[s]=1;
    }
    int Z;cin >> Z;
    for(int a = 0;a < Z;a++){
        int s;cin >> s;
        Zz[s]=1;
    }
    int ans = 0;
    for(int a = 1;a <= N;a++){
        if(Zz[a] == 1 && (Xx[a] != 1 || Yy[a] == 1)){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>

void ask(const std::vector<int>& bits, int from, int until) {
	std::cout << '?';
	for (auto i = 0; i < from; ++i) std::cout << '0';
	while (from < until) std::cout << bits[from++];
	for (auto i = until; i < bits.size(); ++i) std::cout << '0';
	std::cout << std::endl;
}

int main() {
	int n, k; std::cin >> n >> k;
	std::vector<int> bits(n), confirmed;
	std::mt19937 rand;
	while (confirmed.size() < k) {
		for (auto& b : bits) b = rand() & 1;
		for (const auto c : confirmed) bits[c - 1] = 0;
		ask(bits, 0, bits.size());
		int response; std::cin >> response;
		if (response == 0) continue;
		int min = 0, max = bits.size() ;
		while (min < max) {
			const auto mid = (min + max) / 2;
			if (mid == 0) {
				min = mid + 1; continue;
			}
			ask(bits, 0, mid);
			std::cin >> response;
			if (response == 1) {
				max = mid;
			}
			else {
				min = mid + 1;
			}
		}
		confirmed.push_back(max);
	}
	std::sort(confirmed.begin(), confirmed.end());
	std::cout << '!';
	for (auto i = 0; i < confirmed.size(); ++i) {
		if (i != 0) std::cout << ' ';
		std::cout << confirmed[i];
	}
	std::cout << std::endl;
}



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

class Progaram
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().ToCharArray().ToList();
        bool f = false;
        var alon = 0;
        while (!f)
        {
            s.RemoveAt(s.Count - 1);
            if (s.Count % 2 != 0) continue;
            var s1 = new List<char>();
            var s2 = new List<char>();
            for (var i = 0; s.Count / 2 > i; i++)
            {
                s1.Add(s[i]);
            }
            for (var i = s.Count / 2; s.Count > i; i++)
            {
                s2.Add(s[i]);
            }
            alon = s.Count;
            var t1 = new String(s1.ToArray());
            var t2 = new String(s2.ToArray());
            if (t1 == t2) f = true;
        }
        Console.WriteLine(alon);
    }
}


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


    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846
    const int MOD=1e9+7;

    long long dp[3005][3005][2];

    long long solve(vector<int>& a, int i, int j,int turn){
        if(i>j)
            return 0;
        if(dp[i][j][turn]!=-1)
            return dp[i][j][turn];
        if(turn ==1)
            return dp[i][j][turn]=max(a[i]+solve(a,i+1,j,0),a[j]+solve(a,i,j-1,0));
        else
            return dp[i][j][turn]=min(solve(a,i+1,j,1),solve(a,i,j-1,1));
    }

    void solve(){
        int n;
        cin>>n;
        vector<int>a(n);
        long long s=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            s+=(long long)a[i];
        }
        memset(dp,-1,sizeof(dp));
        long long sx=solve(a,0,n-1,1);
//        cout<<sx<<"\n";
//        cout<<s<<"\n";
        long long sy=s-sx;
        cout<<sx-sy;
        return;
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 141568
from collections import deque

h, w = map(int, input().split())
p = [list(input()) for i in range(h)]

INF = 10**7

# 探索用ベクトル
vx = (0, -1, 0, 1)
vy = (-1, 0, 1, 0)

# 幅探索用キューの準備
q = deque()
for i, vi in enumerate(p):
    for j, vj in enumerate(vi):
        if vj == '#':
            q.appendleft((j, i))
            
qans = deque()

# 新しく黒に塗りつぶした座標をキューで返却
def bfs(q):
    for i in range(INF):
        # キューが空なら終了
        if len(q) == 0:
            return qans

        # キューから一つ取り出す
        x, y = map(int, q.pop())

        # 4方向のいずれかに白があれば、黒にする
        for j in range(4):
            nx, ny = x+vx[j], y+vy[j]

            # エリア外 or 黒色なら探索しない
            if nx < 0 or w <= nx or ny < 0 or h <= ny or p[ny][nx] == '#':
                continue

            p[ny][nx] = '#'
            qans.appendleft((nx, ny))

# 操作を白がなくなるまで繰り返す
for i in range(INF):
    qans = deque()
    q = bfs(q)
    # キューが空なら終了
    if len(q) == 0:
        ans = i
        break
    
print(ans)

Measured memory_bytes: 115292
<?php
class Line {
    protected $lineData;
    protected $pointer;
    public function __construct(array $line)
    {
        $this->lineData = $line;
        $this->pointer = 0;
        $this->count = count($line);
    }

    public function next()
    {
        if ($this->count > $this->pointer) {
            return $this->lineData[$this->pointer++];
        }
        return false;
    }
}

class IOW {
    /**
     * @return Line
     */
    public static function nl()
    {
        $str = trim(fgets(STDIN));
        return new Line(explode(' ', $str));
    }

    public static function out($data)
    {
        print_r ($data . PHP_EOL);
    }
}

$line = IOW::nl();

$qCount = $line->next();
$aL = new SplPriorityQueue();
$aR = new SplPriorityQueue();
$minValue = null;
for ($i = 0; $i < $qCount; $i++) {
    $line = IOW::nl();
    $qType = $line->next();
    switch ($qType) {
        case 1:
            $a = $line->next();
            $b = $line->next();
            if ($aL->isEmpty()) {
                $aL->insert($a, $a);
                $aR->insert($a, -$a);
                $minValue = $b;
                break;
            }

            switch (true) {
                case $a < $aL->top():
                    $minValue += abs($aL->top() - $a) + $b;
                    break;
                case $a > $aR->top():
                    $minValue += abs($aR->top() - $a) + $b;
                    break;
                default:
                    $minValue += $b;
            }

            $aL->insert($a, $a);
            $aR->insert($a, -$a);
            if ($aL->top() > $aR->top()) {
                $aLNewTop = $aR->extract();
                $aRNewTop = $aL->extract();
                $aL->insert($aLNewTop, $aLNewTop);
                $aR->insert($aRNewTop, -$aRNewTop);
            }
            
            break;
        case 2:
            IOW::out($aL->top() . " " . $minValue);
            break;
    }
}


Measured memory_bytes: 195064
N,M = [int(c) for c in input().split()]
ab = [list(map(int,input().split())) for c in range(N)]
cd = [list(map(int,input().split())) for c in range(M)]
for i in range(N):
    mi = 2*10**9
    for j in range(M):
        tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if mi > tmp:
            mi = tmp
            ans = j+1
    print(ans)


Measured memory_bytes: 9140
N = int(input())
A = list(map(int,input().split()))

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
        
def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a

print(gcdlist(A))

Measured memory_bytes: 15020
n, m = map(int, input().split())
edge = [set() for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    edge[a].add(b)
    edge[b].add(a)

closed_path = set()
n = 1
answer = []
while True:
    answer.append(n)
    closed_path.add(n)
    for i in edge[n]:
        if i not in closed_path:
            n = i
            break
    else:
        break

n = 1
answer.reverse()
del answer[-1]
        
while True:
    answer.append(n)
    closed_path.add(n)
    for i in edge[n]:
        if i not in closed_path:
            n = i
            break
    else:
        break

print(len(answer))
print(*answer)

Measured memory_bytes: 37256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

//Seven Puzzle
public class Main{

	static int[] pow = {1,10,100,1000,10000,100000,1000000,10000000};

	static int swap(int x, int k){
		int pos = 0;
		while((x/pow[pos])%10>0){
			pos++;
		}
		int tp = 0;
		if(k==0){
			if(pos+4>7)return 0;
			tp = pos+4;
		}
		else if(k==1){
			if((pos+1)%4==0)return 0;
			tp = pos+1;
		}
		else if(k==2){
			if(pos-4<0)return 0;
			tp = pos-4;
		}
		else if(k==3){
			if(pos%4==0)return 0;
			tp = pos-1;
		}
		int d = x/pow[tp]%10;
		return x - d*pow[tp] + d*pow[pos];
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		List<Integer> l = new ArrayList<Integer>();
		l.add(1234567);
		m.put(1234567, 0);
		int step = 1;
		while(!l.isEmpty()){
			List<Integer> next = new ArrayList<Integer>();
			for(int a:l){
				for(int k=0;k<4;k++){
					int n = swap(a, k);
					if(n!=0 && !m.containsKey(n)){
						m.put(n, step);
						next.add(n);
					}
				}
			}
			step++;
			l = next;
		}
		while(sc.hasNext()){
			int x = 0;
			for(int i=0;i<8;i++){
				x*=10;
				x+=sc.nextInt();
			}
			System.out.println(m.get(x));
		}
	}
}

Measured memory_bytes: 0
x,n=[int(i) for i in input().split()]
arr=[int(i) for i in input().split()]
ele=set()
for i in arr:
    ele.add(i)
left=x
rigth=x
while True:
    if rigth not in ele and left not in ele:
        print(min(rigth,left))
        break
    if left not in ele:
        print(left)
        break
    if rigth not in ele:
        print(rigth)
        break
    left-=1
    rigth+=1

Measured memory_bytes: 9112
import java.util.*;
 
public class Main{
	public static void main(String[] $){
		Scanner sc = new Scanner(System.in);
 
		long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
		if(A >= K)
			System.out.println(A-K+" "+B);
		else
			System.out.println("0 "+Math.max(0,B-K+A));
	}
}

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

using namespace std;

int main()
{
	int n,m,i,j,ans;
	vector<int> num[4];
	int card;
	
	for(;;)
	{
		cin >> n >> m ;
		if(n==0 && m==0)
			break;
		
		num[0].clear();
		num[1].clear();
		num[2].clear();
		card=0;
		ans=1;
		
		for(i=0;i<=n;i++)
		{
			num[0].push_back(0);
			num[1].push_back(0);
			num[2].push_back(0);
		}
		
		for(i=0;i<m;i++)
		{
			int a;
			cin >> a ;
			if(a==0)
				card=1;
			num[0][a]=1;
		}
		
/*		for(i=0;i<m;i++)
			if(num[0][i]==1)
				cout << i << " " ;
		cout << endl;
*/		
		if(card==0)
		{
			for(i=1;i<=n;i++)
			{
				if(num[0][i]==1)
				{
					num[1][i]=num[1][i-1]+1;
				}
			}
			for(i=1;i<=n;i++)
			{
				if(ans<num[1][i])
					ans=num[1][i];
			}
		}
		else
		{
			for(i=1;i<=n;i++)
			{
				if(num[0][i]==1)
				{
					num[1][i]=num[1][i-1]+1;
				}
			}
			for(i=1;i<=n;i++)
			{
				if(card==1)
				{
					if(num[0][i]==1)
					{
						for(j=i+1;j<=n;j++)
						{
							if(num[0][j]==0)
							{
								num[2][j]=num[1][j-1]+1;
								card=0;
								i=j;
								break;
							}
						}
					}
				}
				if(card==0)
				{
					for(j=i;j<=n;j++)
					{
						if(num[0][j]==1)
						{
							num[2][j]=num[2][j-1]+1;
						}
						else
						{
							i=j-1;
							card=1;
							break;
						}
					}
				}
			}
			for(i=1;i<=n;i++)
			{
				if(num[2][i-1]!=0)
					num[1][i]+=num[2][i-1];
				if(num[1][i-1]>num[1][i] && num[0][i]==1)
					num[1][i]=num[1][i-1]+1;
			}
			for(i=1;i<=n;i++)
			{
				if(ans<num[1][i])
					ans=num[1][i];
			}
		}
/*		for(i=0;i<=n;i++)
		{
			cout << num[1][i] << " " ;
		}
		cout << endl;
		for(i=0;i<=n;i++)
		{
			cout << num[2][i] << " " ;
		}
		cout << endl;
*/		cout << ans << endl;
	}
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    scanf("%d" , &n);

    vi freq(n + 1 , 0);

    ll ans = 0;

    vi a(n + 1);

    set < int > st;
    for(int i = 1 ; i <= n ; i ++){
            scanf("%d" , &a[i]);
            freq[a[i]] ++;
            st.insert(a[i]);
    }

    for(int S : st){
            ll tmp = freq[S];
            ans += tmp * (tmp - 1) / 2;
    }

    for(int i = 1 ; i <= n ; i ++){
            ll tmp = freq[a[i]];

            ll ans2 = ans;
            ans2 -= tmp * (tmp - 1) / 2;
            ll tmp2 = tmp - 1;

            ans2 += tmp2 * (tmp2 - 1) / 2;
            printf("%lld\n" , ans2);
    }

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 9088
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

int main() {
    cin >> N;

    for (int A = 1; A < 10; A++) {
        for (int B = 1; B < 10; B++) {
            if (A * B == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


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

struct point{
  double x, y;
};

void koch(int n, point p1, point p2){
  point  p3, p4, p5;
  double rad60=M_PI*60.0/180.0;
  
  if(n==0) return;
  
  p3.x=(2.0*p1.x+p2.x)/3.0;
  p3.y=(2.0*p1.y+p2.y)/3.0;

  p4.x=(p1.x+2.0*p2.x)/3.0;
  p4.y=(p1.y+2.0*p2.y)/3.0;

  p5.x=(p4.x-p3.x)*cos(rad60)-(p4.y-p3.y)*sin(rad60)+p3.x;
  p5.y=(p4.x-p3.x)*sin(rad60)+(p4.y-p3.y)*cos(rad60)+p3.y;

  koch(n-1, p1, p3);
  printf("%.8f %.8f\n", p3.x, p3.y);
  koch(n-1, p3, p5);
  printf("%.8f %.8f\n", p5.x, p5.y);
  koch(n-1, p5, p4);
  printf("%.8f %.8f\n", p4.x, p4.y);
  koch(n-1, p4, p2);
}

int main(void){
  int n;
  point p1, p2;
  
  scanf("%d", &n);

  p1.x=0.0; p1.y=0.0;
  p2.x=100.0; p2.y=0;
  
  printf("%.8f %.8f\n", p1.x, p1.y);
  koch(n, p1, p2);
  printf("%.8f %.8f\n", p2.x, p2.y);
  
  return 0;
}



Measured memory_bytes: 3204
// https://beta.atcoder.jp/contests/abc112

#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(5
100 100 0
2 3 5
2 1 5
1 2 5
3 2 5
)");
#endif
    int n;
    in >> n;

    vector<int> x, y, h;
    for (int i = 0; i < n; ++i) {
        int xi, yi, hi;
        in >> xi >> yi >> hi;
        x.push_back(xi);
        y.push_back(yi);
        h.push_back(hi);
    }

    auto non_zero_index = std::distance(h.begin(), find_if(h.begin(), h.end(), [](int hi) { return hi != 0; }));
    for (int cx = 0; cx <= 100; ++cx) {
        for (int cy = 0; cy <= 100; ++cy) {
            int h_est = h[non_zero_index] + abs(cx - x[non_zero_index]) + abs(cy - y[non_zero_index]);
            bool ok = true;
            for (int i = 0; i < x.size(); ++i) {
                if (h[i] == 0) {
                    if (abs(cx - x[i]) + abs(cy - y[i]) < h_est) ok = false;
                }
                else if (h_est != h[i] + abs(cx - x[i]) + abs(cy - y[i])) ok = false;
            }

            if (ok) {
                cout << cx << " " << cy << " " << h_est << endl;
                exit(0);
            }
        }
    }
    return 0;
}

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

using ll=long long;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,d,a;
  cin>>n>>d>>a;
  d<<=1;
  vector<pair<ll,ll>> vp(n);
  for(int i=0;i<n;i++){
    cin>>vp[i].first>>vp[i].second;
  }
  sort(vp.begin(),vp.end());
  ll c=0,pd=0;
  vector<ll> arr(n,0);
  for(int i=0;i<n;i++){
    vp[i].second-=pd;
    if(vp[i].second>0){
      ll need=(vp[i].second+a-1)/a;
      c+=need;
      pd+=need*a;
      int low=0,high=n-1,ans;
      while(low<=high){
        int mid=(low+high)>>1;
        if(vp[mid].first<=vp[i].first+d){
          ans=mid;
          low=mid+1;
        }
        else{
          high=mid-1;
        }
      }
      arr[ans]+=need*a;
    }
    pd-=arr[i];
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 4992
# ball and box 5
MOD = pow(10,9)+7
from math import factorial
def P(n,r):
    return factorial(n)//factorial(n-r)
def C(n,r):
    return P(n,r)//factorial(r)
def H(n,r):
    return C(n+r-1,r)
n, k = map(int, input().split())

print(C(k,n)%MOD if n < k else 0 if n > k else 1)


Measured memory_bytes: 5668
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from itertools import groupby
def resolve():
    n,k,l=map(int,input().split())
    K=[[] for _ in range(n)]
    L=[[] for _ in range(n)]
    for _ in range(k):
        p,q=map(int,input().split())
        p-=1; q-=1
        K[p].append(q)
        K[q].append(p)
    for _ in range(l):
        r,s=map(int,input().split())
        r-=1; s-=1
        L[r].append(s)
        L[s].append(r)

    # KについてのDFS
    C1=[-1]*n
    col=0
    def dfs1(v)->bool:
        if(C1[v]!=-1): return False
        C1[v]=col
        Q=[v]
        while(Q):
            v=Q.pop()
            for nv in K[v]:
                if(C1[nv]!=-1): continue
                C1[nv]=col
                Q.append(nv)
        return True

    for v in range(n):
        col+=dfs1(v)

    # LについてのDFS
    C2=[-1]*n
    col=0
    def dfs2(v)->bool:
        if(C2[v]!=-1): return False
        C2[v]=col
        Q=[v]
        while(Q):
            v=Q.pop()
            for nv in L[v]:
                if(C2[nv]!=-1): continue
                C2[nv]=col
                Q.append(nv)
        return True

    for v in range(n):
        col+=dfs2(v)

    ans=[None]*n
    X=[(C1[v],C2[v],v) for v in range(n)]
    X.sort()
    for key,iter in groupby(X,key=lambda x:(x[0],x[1])):
        s=list(iter)
        for a,b,c in s:
            ans[c]=len(s)
    print(*ans)
resolve()

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

int main(void)
{
  int n, k, d;
  cin >> n >> k;
  vector<int> A(n, 0);
  
  for (int i=0;i<k;i++){
    cin >> d;
    for (int j=0;j<d;j++){
      int x;
      cin >> x;
      A[x-1] = 1;
    }
  }
  
  int cnt = 0;
  for (int i=0;i<n;i++){
    if (A[i] == 0){
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to) : from(-1), to(to), cost(-1) {}
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}

template<typename T>
vector<T> dijkstra(int s, graph<T> &g){
  vector<T> dist(g.size()+10, INF);dist[s] = 0;
  priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T,int>>> que;que.push(P(0,s));
  while(!que.empty()){
    pair<T,int> p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge<T> e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(make_pair(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

  int n;
signed main(){
  cin>>n;int ans = 0;
  repd(i,1,n+1){
    repd(j,1,n+1){
      repd(k,1,n+1){
        ans += __gcd(i,__gcd(j,k));
      }
    }
  }
  cout << ans << endl;
}


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

int main() {
  int i, j;
  int x[3];
  int maxval = 0;
  int maxindex;
  int sum = 0;

  scanf("%d %d %d", &x[0], &x[1], &x[2]);
  for (i = 0; i < 3; i++) {
    if (x[i] >= maxval) {
      maxval = x[i];
      maxindex = i;
    }
  }

  for (i = 0; i < 3; i++) {
    if (i != maxindex) {
      sum += x[i];
    }
  }

  printf("%d", sum);

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
string str[8]={"AAA","AA","A","B","C","D","E","NA"};
double t[8]={35.5 , 37.5 , 40.0 , 43.0, 50.0, 55.0, 70.0,9999999.9999999};
double u[8]={71.0 , 77.0 , 83.0 , 89.0,105.0,116.0,148.0,9999999.9999999};
double a,b;
int main(){
  while(cin>>a>>b){
    for(int i=0;i<8;i++){
      if(a<t[i]&&b<u[i]){cout<<str[i]<<endl;break;}
    }
  }
}


Measured memory_bytes: 3132
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long A = sc.nextInt();
		long B = sc.nextInt();
		
		if(B<A){
			System.out.println(0);
		}
		else if(N==1){
			if(B!=A){
				System.out.println(0);
			}
			if(B==A){
				System.out.println(1);
			}
		}
		else{
			System.out.println(B*(N-2)-A*(N-2)+1);
		}
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
//#define int long long 
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	ll n,k;
	cin>>n>>k;
	const ll mxm=500000;
	vl fac(mxm+1);
	fac[0]=1;
	for(ll i=1;i<=mxm;i++) fac[i]=fac[i-1]*i%mod;
	ll ans=0;
	for(ll i=0;i<=min(k,n-1);i++){
		ll r=i;
		ll tmp = fac[n]*fac[n-1]%mod;
		tmp = tmp*mi(fac[r],mod)%mod;
		tmp = tmp*mi(fac[n-r-1],mod)%mod;
		tmp = tmp*mi(fac[n-r],mod)%mod;
		tmp = tmp*mi(fac[r],mod)%mod;
		ans = (ans+tmp)%mod;
	}
	cout<<ans;
	
 
 
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 4096
#include<stdio.h>
int main()
{
    int x=1,y=2,A,B;
    scanf("%d\n %d",&A,&B);
    if(x !=A && x !=B)
    {
        printf("%d\n",x);
    }
    else if(y != A && y != B)
    {
        printf("%d\n",y);
    }
    else
    {
        printf("3\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
ll fac(ll n){if(n<=1)return 1; else return n*fac(n-1);}
int main()
{
    string ans;
    vector<string>s(3);
    for(int i=0;i<3;i++)cin >> s[i];
    for(int i=0;i<3;i++)ans+=s[i][i];
    cout << ans << endl;
}


Measured memory_bytes: 3624
def main():
    s = int(input())
    mod = 10**9 + 7

    dp = [0] * (s+1)
    dp[0] = 1
#    for i in range(1, s+1):
#        for j in range(0, (i-3)+1):
#            dp[i] += dp[j]
#            dp[i] %= mod
    for i in range(1, s+1):
        if i < 3:
            dp[i] = 0
        else:
            dp[i] = dp[i-1] + dp[i-3]
            dp[i] %= mod

    print(dp[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 62952
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace Print_a_Chessboard
{
    class Program
    {
        static void Main(string[] args)
        {
            String str;
            while ((str = Console.ReadLine()) != "0 0")
            {
                String[] ss = str.Split(' ');
                for (int i = 0; i < int.Parse(ss[0]); ++i)
                {
                    for (int j = 0; j < int.Parse(ss[1]); ++j)
                    {
                        if (i % 2 == 0)
                        {
                            if (j % 2 == 0) Console.Write("#");
                            else Console.Write(".");
                        }
                        else
                        {
                            if (j % 2 == 0) Console.Write(".");
                            else Console.Write("#");
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}


Measured memory_bytes: 8972
S = input()
atgc,tmp = 0,0
for i in range(len(S)):
    if(S[i] == "A" or S[i] == "T" or S[i] == "G" or S[i] == "C"):
        tmp += 1
        atgc = max(tmp,atgc)
    else:
        tmp = 0
print(atgc)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
  ll n;
  cin >> n;
  vector<ll>a(n);
  for(ll i=0;i<n;i++){
    cin >> a[i];
  }
  bool judge=true;
  for(ll i=0;i<n;i++){
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0){
        judge=false;
      }
    }
  }
  if(judge) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 3604
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
int main()
{
	//ifstream cin("testcase.txt");
	//ofstream cout("output.txt");	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		int a,b,c;
		cin>>a>>b>>c;
		int flag=0;
		for(i=1;i<1000000;i++)
		{
			if( (a*i)%b==c )
			{
				flag=1;
				break;
			} 
		}
		if(flag==1)
		{
			cout<<"YES"<<endl;
			return 0;
		}
		cout<<"NO"<<endl;
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


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

int main()
{
#if 0
    // ??\??? cin ?????\????????? 'xxx.txt' ?????????
    //std::ifstream in("alds1_4_a.txt");
    std::ifstream in("ALDS1_4_A-in8.txt");
    std::cin.rdbuf(in.rdbuf());
#else
#endif
    

    int n;
    cin >> n;
    vector<int> s;
    for (int i = 0; i < n; i++)
    {
        int s_num;
        cin >> s_num;
        s.push_back(s_num);
    }

    int q;
    cin >> q;
    vector<int> t;
    for (int i = 0; i < q; i++)
    {
        int t_num;
        cin >> t_num;
        t.push_back(t_num);
    }

    int ttl = 0;
    vector<int>::iterator it_t;
    for (it_t = t.begin(); it_t != t.end(); it_t++)
    {
        vector<int>::iterator it_s;
        for (it_s = s.begin(); it_s != s.end(); it_s++)
        {
            // cout << *it_s << "/" << *it_t << endl;
            bool is_found = false;
            if(*it_s == *it_t)
            {
                ttl++;
                //cout << *it_s << "/" << *it_t << endl;
                is_found = true;
            }
            if(is_found)
            {
                break;
            }
        }
    }

    cout << ttl << endl;
        


    return 0;
}

Measured memory_bytes: 1320
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Word
import qualified Data.ByteString as BSW
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Array.ST

-- Input: s t
-- Output: arr
--   arr ! (i,j) == length of lcs of (drop i s, drop j t)
lcsTable2 :: BS.ByteString -> BS.ByteString -> UArray (Int,Int) Word16
lcsTable2 s t = runSTUArray $ do
  let !m = BS.length s
      !n = BS.length t
      !n' = n+1
  arr <- newArray ((0,0),(m,n)) 0
  forM_ [m-1,m-2..0] $ \ !i -> do
    let !x = BSW.index s i
        loopY !j !v
          -- v = readArray arr (i,j+1)
          | j < 0 = return ()
          | otherwise = do
              let !y = BSW.index t j
              if x == y
                then do l2 <- readArray arr (i+1,j+1)
                        let !l = l2 + 1
                        writeArray arr (i,j) l
                        loopY (j-1) l
                else do l0 <- readArray arr (i+1,j)
                        let !l = max l0 v
                        writeArray arr (i,j) l
                        loopY (j-1) l
    loopY (n-1) 0
  return arr

main = do
  s <- BS.getLine
  t <- BS.getLine
  -- BS.length s <= 3000, BS.length t <= 3000, BS.all isAsciiLower s, BS.all isAsciiLower t
  let !table = lcsTable2 s t
      !m = BS.length s
      !n = BS.length t
      !n' = n+1
  let recon !i !j | i >= m || j >= n = Nothing
                  | x == y = let !i' = i+1 ; !j' = j+1
                             in Just (x, (i', j'))
                  | table ! (i+1,j) >= table ! (i,j+1) = reconY y (i+1) j
                  | otherwise = reconX x i (j+1)
        where x = BSW.index s i
              y = BSW.index t j
      reconX !x !i !j | j >= n = Nothing
                      | x == y = let !i' = i+1 ; !j' = j+1
                                 in Just (x, (i', j'))
                      | table ! (i+1,j) >= table ! (i,j+1) = reconY y (i+1) j
                      | otherwise = reconX x i (j+1)
        where y = BSW.index t j
      reconY !y !i !j | i >= m = Nothing
                      | x == y = let !i' = i+1 ; !j' = j+1
                                 in Just (x, (i', j'))
                      | table ! (i+1,j) >= table ! (i,j+1) = reconY y (i+1) j
                      | otherwise = reconX x i (j+1)
        where x = BSW.index s i
      (result, _) = BSW.unfoldrN (fromIntegral $ table ! (0,0)) (\(!i,!j) -> recon i j) (0,0)
  BS.putStrLn result


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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define pb push_back
#define eb emplace_back
#define fst first
#define snd second
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int n;
  while(cin >> n, n){
    vs s(n); rep(i,n) cin >> s[i];

    vi ppos(n,-1); // +の位置
    rep(i,n) rep(j,s[i].size()-1){
      if(s[i][j] != '.') break;
      if(s[i][j+1] == '.') s[i][j] = ' ';
      else{
	ppos[i] = j;
	s[i][j] = '+';
	break;
      }
    }
    //dump(ppos);
    rep(i,n){
      if(ppos[i] == -1) continue;
      //dump(i);
      int d = -1;
      FOR(j,i+1,n){
	if(ppos[j] < ppos[i]) break;
	if(ppos[j] == ppos[i]){
	  d = j;
	  break;
	}
      }
      if(d != -1)
	FOR(j,i+1,d) s[j][ppos[i]] = '|';
    }
    rep(i,n) cout << s[i] << endl;
  }
}


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

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double deg = abs(h * (360.0 / 12) + m * (30.0 / 60) - m * (360.0 / 60));
    double rad = deg * (M_PI / 180.0);
    double ans = sqrt(a * a + b * b - 2.0 * a * b * cos(rad));

    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 4232