akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define BP 1000000007

using namespace std;

typedef unsigned long long ull;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> vull;
typedef vector<ll> vll;
typedef vector<ui> vui;
typedef vector<long> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ull, ull> pull;
typedef pair<ll, ll> pll;
typedef pair<ui, ui> pui;
typedef pair<long, long> pl;
typedef pair<int, int> pi;

typedef vector<pair<long, long> > vpl;
typedef vector<pair<int, int> > vpi;

typedef queue<long> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    int x, a, b; cin >> x >> a >> b;
    if (a >= b) {
        cout << "delicious" << endl;
    } else if (b - a <= x) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
while True:
    n, m = map(int, input().split())
    if n == 0:
        break

    lst = [1]*n
    a = 0
    b = 0
    c = 0
    while b < n-1:
        a += lst[c%n]
        if a == m:
            a = 0
            lst[c%n] = 0
            b +=1
        c += 1
    print(lst.index(1)+1)


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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    cout << n*n*n;
    return 0;
}


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

int bh[300010];
int bw[300010];
int bhm[300010];
int bwm[300010];

int main() {
	int h,w,m;
	int h_max,w_max;
	int h_count,w_count;
	int x,y,p;

	cin >> h >> w >> m;

	rep(i, m) {
		cin >> x >> y ;
		x--;
		y--;
		bhm[i]=x;
		bwm[i]=y;
		bh[x]++;
		bw[y]++;
	}
	h_max=0;
	rep(i, h) if (h_max<bh[i]) h_max=bh[i];
	h_count=0;
	rep(i, h) if (h_max==bh[i]) h_count++;
	w_max=0;
	rep(i, w) if (w_max<bw[i]) w_max=bw[i];
	w_count=0;
	rep(i, w) if (w_max==bw[i]) w_count++;
	p=0;
	rep(i, m) {
		if (h_max>bh[bhm[i]]) continue;
		if (w_max>bw[bwm[i]]) continue;
		p++;
	}
	if(p==h_count*w_count) cout << h_max+w_max-1 << endl;
	else cout << h_max+w_max << endl;
	return 0;
}

Measured memory_bytes: 8304
#include <stdio.h>
int main(void){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int ans = a+b+c;
	int min = a;
	if(min < b){
		min = b;
	}
	if(min < c){
		min = c;
	}
	ans -= min;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int time2min(int month,int day,int hour,int min){
  const int total_day_of_month[]
    = {31,28,31,30,31,30,31,31,30,31,30,31};
  int total = 0;
  for(int i=1;i<month;i++){
    total += total_day_of_month[i]*24*60;
  }
  for(int i=1;i<day;i++){
    total += 24*60;
  }
  total += hour * 60 + min;

  return total;
}

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

    map<int,vector<int> > log;
    for(int i=0;i<N;i++){
      int month,day,hour,min,id;
      char action[2];
      scanf("%d/%d %d:%d %s %d",
	    &month,&day,&hour,&min,action,
	    &id);
      
      int t = time2min(month,day,hour,min);
      log[id].push_back(t);
    }

    int total[1000];
    memset(total,0,sizeof(total));
    
    for(int i=0;i+1<log[0].size();i+=2){
      int god_start = log[0][i];
      int god_end = log[0][i+1];

      for(map<int,vector<int> >::iterator it = log.begin();
	  it != log.end();
	  it++){
	int id = it->first;
	if(id == 0) continue;
	vector<int>& schedule = it->second;
	for(int j=0;j<schedule.size();j+=2){
	  int ppl_start = schedule[j];
	  int ppl_end = schedule[j+1];
	  int start = max(god_start,ppl_start);
	  int end = min(god_end,ppl_end);
	  total[id] += max(0,end-start);
	}
      }
    }

    int max_v = 0;
    for(int id=0;id<1000;id++){
      max_v = max(total[id],max_v);
    }
    printf("%d\n",max_v);
  }
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
char ch[150][150];
bool vis[150][150];	
int n,m;
bool flag = true;
void y() {
	flag = true;
	for(int i = 1; i <= m; i++) {
		for(int j = 1; j <= n; j++) {
			if(ch[j][i] != '.') {
				flag = false;
				break;
			}
		}
		if(flag) {
			for(int k = 1; k <= n; k++) {
				vis[k][i] = false;
			}
		}
		flag = true;
	}
	return;
}
void x() {
	flag = true;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(ch[i][j] != '.') {
				flag = false;
				break;
			}
		}
		if(flag) {
			for(int k = 1; k <= m; k++) {
				vis[i][k] = false;
			}
		}
		flag = true;
	}
	return;
}
void print() {
	flag = false;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(vis[i][j]) {
				cout<<ch[i][j];
				flag = true;
			}
		}
		if(flag)cout<<endl;
		flag = false;
	}
	return;
}
void init() {
	memset(vis,true,sizeof(vis));
}
void read() {
	cin>>n>>m;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			cin>>ch[i][j];
		}
	}
	return;
}
int main() {
	init();
	read();
	x();
	y();
	print();
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
  if A[i] < B[i]:
    ans += A[i]
    B[i] -= A[i]
  else:
    ans += B[i]
    B[i] = 0
  if B[i] > 0:
    if A[i+1] < B[i]:
      ans += A[i+1]
      A[i+1] = 0
    else:
      ans += B[i]
      A[i+1] -= B[i]
print(ans)

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

int main(){
    string S; cin >> S;
    ll cnt=0;
    ll ans=0;

    rep(i,S.size()){

        if(S[i] == 'W'){
            ans += cnt;
        }
        else cnt++;

    }

    cout << ans << endl;
}

Measured memory_bytes: 640
n,m,t=map(int,input().split())
a=list(map(int,input().split()))
a.insert(0,-m)
ans=0
for i in range(n):
    if a[i]+2*m<a[i+1]:
        ans+=a[i+1]-a[i]-2*m
if a[-1]+m<t:ans+=t-a[-1]-m
print(ans)


Measured memory_bytes: 5596
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
l.sort(key= lambda x:x[1])
t=0
cnt=0
for i in l:
    cnt+=1
    a,b=i
    t+=a
    if(t>b):
        print("No")
        break
    elif cnt==N:
        print("Yes");


Measured memory_bytes: 53728
#include <iostream>

using namespace std;
// int n = 7;  int a[] = {4,2,5,3,5,8,3}; sort(a,a+n)
int main() {
    int n;
    cin >> n;
    int a, b;
    if(n == 1){
        cout << "Hello World";
    } else if(n == 2){
        cin >> a >> b;
        cout << a + b;
    }
    return 0;
}

Measured memory_bytes: 3620
from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))

def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]

print('ABC') if II() <= 999 else print('ABD')


Measured memory_bytes: 64876
#include <iostream>

using namespace std;

int M, N, A[105];

int main(void) {

	cin >> N>>M;
	int sum = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i]; sum += A[i];
	}

	int num = 0;

	//cout << "sum= " << sum << endl;

	for (int i = 1; i <= N; i++) {
		if (4 * M*A[i] >= sum) { num++; }
	}

	//cout << "num= " << num << endl;

	if (num >= M) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int linearSearch(int,int*,int);

int main(){
  int n,s[10000],q,key,i,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    sum+=linearSearch(n,s,key);
  }
  printf("%d\n",sum);

  return 0;
}

int linearSearch(int n,int a[],int key){
  int i=0;
  a[n]=key;
  while(a[i]!= key){
    i++;
      }
  if(i==n)return 0;
  else return 1;
}



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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop(i,b,n) for(int i=b;i<(n);++i)
#define each(e,v) for(auto &&e : v)

#define all(v) (v).begin(),(v).end()
#define sz(v) (int)v.size()

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const double EPS = 1e-9;
const ll MOD = 1e+9 + 7;

template<typename A,typename B> inline void chmin(A &a,B b){ if(a>b) a=b; }
template<typename A,typename B> inline void chmax(A &a,B b){ if(a<b) a=b; }
template <typename T> inline void print(const T& x) { cout << x << endl; }

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

    vector<ll> a(n,0);
    rep(i,n){
        cin >> a[i];
    }

    sort(all(a),[](ll x, ll y){ return abs(x)>abs(y);});

    int neg_count = 0;
    for(int i=0; i<k; ++i){
        if(a[i] < 0) ++neg_count;
    }

    if(neg_count%2==0){
        ll res = 1;
        for(int i=0; i<k; ++i){
            res = (res * a[i]) % MOD;
        }
        print(res);
        return 0;
    }

    int last_neg = -1;
    int last_pos = -1;
    for(int i=k-1; i>=0; --i){
        if (last_neg<0 && a[i]< 0) last_neg = i;
        if (last_pos<0 && a[i]>=0) last_pos = i;
    }

    int next_neg = -1;
    int next_pos = -1;
    for(int i=k; i<n; ++i){
        if (next_neg<0 && a[i]< 0) next_neg = i;
        if (next_pos<0 && a[i]>=0) next_pos = i;
    }

    if((last_neg == -1 || next_pos == -1) && (last_pos == -1 || next_neg == -1)){
        ll res = 1;
        for(int i=0; i<k; ++i){
            res = (res * a[n-1-i]) % MOD;
        }
        print(res >= 0 ? res : (res + MOD));
        return 0;
    }

    bool b;
    if(next_neg == -1 || last_pos == -1) b = true;
    else if(next_pos == -1 || last_neg == -1) b = false;
    else b = abs(a[next_pos]) * abs(a[last_pos]) > abs(a[next_neg]) * abs(a[last_neg]);

    ll res = 1;
    if(b){
        for(int i=0; i<k; ++i){
            res = (res * a[i==last_neg ? next_pos : i]) % MOD;
        }
    }else{
        for(int i=0; i<k; ++i){
            res = (res * a[i==last_pos ? next_neg : i]) % MOD;
        }
    }
    print(res >= 0 ? res : (res + MOD));

    return 0;
}


Measured memory_bytes: 4720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    cin>>n;
    ll arr[n];
    s=0;
    for(i=0;i<n;i++){cin>>arr[i];s+=arr[i];}
    var=s/n;
    ans=0;
    for(i=0;i<n;i++)
    {
        v=(arr[i]-var)*(arr[i]-var);
        ans+=v;
    }
    z=0;
    var++;
    for(i=0;i<n;i++)
    {
        v=(arr[i]-var)*(arr[i]-var);
        z+=v;
    }
    ans=min(ans,z);
    z=0;
    var-=2;
    for(i=0;i<n;i++)
    {
        v=(arr[i]-var)*(arr[i]-var);
        z+=v;
    }
    ans=min(ans,z);
    cout<<ans;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

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

    if (n == 2) {
        int a1, a2;
        cin >> a1 >> a2;
        if (a1 >= 0 && a2 >= 0) {
            if (a1 > a2) {
                cout << a1 - a2 << endl;
                cout << a1 << " " << a2 << endl;
            } else {
                cout << a2 - a1 << endl;
                cout << a2 << " " << a1 << endl;
            }
        } else if (a1 < 0 && a2 >= 0) {
            cout << a2 - a1 << endl;
            cout << a2 << " " << a1 << endl;
        } else if (a2 < 0 && a1 >= 0) {
            cout << a1 - a2 << endl;
            cout << a1 << " " << a2 << endl;
        } else {
            if (a1 < a2) {
                cout << a1 - a2 << endl;
                cout << a1 << " " << a2 << endl;
            } else {
                cout << a2 - a1 << endl;
                cout << a2 << " " << a1 << endl;
            }
        }
        return 0;
    }

    vector<int> p;
    vector<int> m;
    int a;
    REP(i, n) {
        cin >> a;
        if (a >= 0) {
            p.push_back(a);
        } else {
            m.push_back(a);
        }
    }
    vector<pair<int, int>> q;
    int t = 0;
    if (m.size() == 0) {
        sort(ALL(p));
        m.push_back(p[0] - p[n - 1]);
        q.emplace_back(p[0], p[n - 1]);
        vector<int> tmp;
        FOR(i, 1, p.size() - 1) {
            tmp.push_back(p[i]);
        }
        p = tmp;

    } else if (p.size() == 0) {
        sort(ALL(m));
        p.push_back(m[n - 1] - m[0]);
        q.emplace_back(m[n - 1], m[0]);
        vector<int> tmp;
        FOR(i, 1, m.size() - 1) {
            tmp.push_back(m[i]);
        }
        m = tmp;
    }

    if (m.size() < p.size()) {
        vector<int> x;
        REP(i, m.size() - 1) {
            q.emplace_back(p[i], m[i]);
            x.push_back(p[i] - m[i]);
        }
        FOR(i, m.size() - 1, p.size()) {
            x.push_back(p[i]);
        }
        int mm = m[m.size() - 1];
        REP(i, x.size() - 1) {
            q.emplace_back(mm, x[i]);
            mm -= x[i];
        }
        q.emplace_back(x[x.size() - 1], mm);
        cout << x[x.size() - 1] - mm << endl;
    } else if (m.size() >= p.size()) {
        vector<int> x;
        REP(i, p.size() - 1) {
            q.emplace_back(m[i], p[i]);
            x.push_back(m[i] - p[i]);
        }
        FOR(i, p.size() - 1, m.size()) {
            x.push_back(m[i]);
        }
        int pp = p[p.size() - 1];
        REP(i, x.size()) {
            q.emplace_back(pp, x[i]);
            pp -= x[i];
        }
        cout << pp << endl;
    }
    REP(i, q.size()) {
        cout << q[i].first << " " << q[i].second << endl;
    }
}



Measured memory_bytes: 3256
#include<stdio.h>
 
int main(){
    int a[4], b[4];
    int hit, blow, i, j;

    while(scanf("%d", &a[0]) != EOF){
        for(i = 1;  i < 4; i++) scanf("%d", &a[i]);
        for (i = 0; i < 4; i++) scanf("%d", &b[i]);
        hit = 0;
        blow = 0;

        for (i = 0; i < 4; i++){
            for(j = 0; j < 4; j++){
                if(a[i] == b[j] && i == j) hit++;
                if (a[i] == b[j] && i != j) blow++;
            }
        }
        printf("%d %d\n", hit, blow);
    }
    return 0;
}

Measured memory_bytes: 596
N,K =  [int(x) for x in input().split()]

L = [0]*N
num =1
for i in range(N):
    num = 1
    if i < K:
        while num*(i+1) < K:
            num *= 2
        L[i]= 1/N * 1/num
    else:
        L[i] = 1/N

ans = 0
for i in range(N):
        ans +=L[i]

print(ans)

Measured memory_bytes: 6132
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        
        public int gcd(int a, int b)
        {
            if (a == b) return a;
            else
            {
                return gcd(Abs(a - b), Min(a, b));
            }
        }
        public SortedSet<int> Frac_(int t)
        {
            var s = new SortedSet<int>();
            for (int i = 1; i <= Sqrt(t); i++)
            {
                if((t % i) == 0)
                {
                    s.Add(i);
                    s.Add(t / i);
                }
            }
            return s;
        }
        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadIntArray(3);
            var g = gcd(a[0], a[1]);
            var s = Frac_(g).Reverse();
            int i = 0;
            foreach (var item in s)
            {
                i++;
                if (i == a[2])
                {
                    Console.WriteLine(item);
                    return;
                }
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}

Measured memory_bytes: 13396
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        while (scanner.hasNext()) {
            int n =scanner.nextInt();
            int combination = 0;

            for (int i = 0; i < 10; i++) {
                int sum1 = 0;
                sum1 += i;
                if (sum1 > n) {
                    break;
                }
                for (int j = 0; j < 10; j++) {
                    int sum2 = sum1;
                    sum2 += j;
                    if (sum2 > n) {
                        break;
                    }
                    for(int k = 0; k < 10; k++) {
                        int sum3 = sum2;
                        sum3 += k;
                        if (sum3 > n) {
                            break;
                        }
                        for(int l = 0; l < 10; l++) {
                            int sum4 = sum3;
                            sum4 += l;
                            if (sum4 == n) {
                                combination++;
                            }
                        }
                    }
                }
            }
            System.out.println(combination);
        }
    }
}

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

int main( ) {
  int A, B, K;
  cin >> A >> B >> K;
  
  for(int i = min(A,B); i >= 1; i--){
    if(A % i == 0 && B % i == 0){
      K--;
      if(K == 0){
        cout << i << endl;
        return 0;
      }
    }
  }
  assert(false);
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
ll const MOD = 1e9+7;

ll mod_pow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (mod_pow(a, 1, p) * mod_pow(a, n-1, p)) % p;
  ll t = mod_pow(a, n / 2, p);
  return (t * t) % p;
}

ll mod_multi(ll a, ll b, ll p) {
  ll res = 1;
  rep(i, b) {
    res = res * a % p;
    a--;
  }
  return res % p;
}

ll mod_com(ll a, ll b, ll p) {
  b = min(b, a-b);
  ll res = mod_multi(a, b, p);
  ll tmp = mod_multi(b, b, p);
  tmp = mod_pow(tmp, MOD-2, MOD) % MOD;

  res = (res * tmp) % MOD;
  return res;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = 0;

  ans = mod_pow(2, n, MOD) - 1;
  ans -= mod_com(n, a, MOD);
  ans -= mod_com(n, b, MOD);
  ans %= MOD;
  while (ans < 0) ans += MOD;
  
  cout << ans <<endl;

  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val line = readLine()!!.split(" ").map { it.toInt() }
    val a = line[0]
    val b = line[1]

    var result = 0
    for (i in (a..b)) {
        val reversed = i.toString().toCharArray().reversed().joinToString("")

        if (i.toString() == reversed) {
            result += 1
        }
    }

    print(result)

}

Measured memory_bytes: 47508
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
map<ll, int> prime_factor(ll n)
{
    map<ll, int> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] = 1;
    }
    return res;
}
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}


int main()
{
    int N;
    cin >> N;
    vint a(N + 1);
    set<int> anss;
    int g = 0;
    for (size_t i = 0; i <= N; i++)
    {
        cin >> a[i];
        g = gcd(g, a[i]);
    }
    reverse(all(a));
    auto ps = prime_factor(g);
    for (auto &&i : ps)
    {
        anss.insert(i.first);
    }
    auto pr = prime_table(N);
    for (int i = 2; i <= N; i++)
    {
        if (pr[i] and anss.count(i) == 0)
        {
            vector<int> poly(N + 1);
            for (int j = 0; j <= N; j++)
            {
                poly[j] = a[j] % i;
            }
            for (int j = N; j - i + 1 > 0; j--)
            {
                poly[j - i + 1] = (poly[j - i + 1] + poly[j]) % i;
                poly[j] = 0;
            }
            bool flag=true;
            for (int j = 0; j <= N; j++)
            {
                if (poly[j] != 0)
                    flag=false;
            }
            if(flag)
            anss.insert(i);
        L:;
        }
    }
    for (auto &&i : anss)
    {
        cout << i << "\n";
    }
    return 0;
}


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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back
#define t top()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo 1e17
#define int long long

const int N = 2e5 + 5;
int n , x , y;
int f[N] , a[N] , h[N];

void up(int pos , int val)
{
    for(int i = pos ; i <= n ; i += i & -i)
        f[i] = max(f[i] , val);
}

int get(int pos)
{
    int res = 0;
    for(int i = pos ; i ; i -= i & -i)
        res = max(res , f[i]);
    return res;
}

main()
{
    //freopen("Q.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    FOR(i , 1 , n)
        cin >> h[i];
    FOR(i , 1 , n)
        cin >> a[i];
    FOR(i , 1 , n)
        up(h[i] , get(h[i] - 1) + a[i]);
    cout << get(n);
}


Measured memory_bytes: 4992
N = int(input())
statement = []
for _ in range(N):
    A = int(input())
    temp = {}
    for _ in range(A):
        x, y = map(int, input().split())
        temp[x-1] = y
    statement.append(temp)
ans = 0
for i in range(2**N):
    honest = []
    for j in range(N):
        if (i >> j) & 1: honest.append(j)
    for h in honest:
        contradiction = False
        for j, y in statement[h].items():
            if (y == 1 and j not in honest) or (y == 0 and j in honest): contradiction = True; break
        if contradiction: break
    else:
        ans = max(format(i, 'b').count('1'), ans)
print(ans)

Measured memory_bytes: 3064
N,L= map(int,input().split())

ajilist=[]
for i in range(N):
    ajilist.append(L+i+1-1)

if min(ajilist) <0 and max(ajilist)>=0:
    abso = 0
elif min(ajilist)<0 and max(ajilist)<0:
    abso = abs(max(ajilist))
else:
    abso=abs(min(ajilist))
    

for i in range(len(ajilist)):
    temp = abs(ajilist[i])
    if abso==temp:
        ajilist.pop(i)
        break
print(sum(ajilist))

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

signed main() {
    int L, R;
    cin >> L >> R;

    const int mod = 2019;
    R = min(L + mod, R);

    int ans = 1e18;
    for (int i = L; i <= R; i++) {
        for (int j = i + 1; j <= R; j++) {
            ans = min(ans, i * j % mod);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  long long x;
  cin >> x;
  long long k[n];
  rep(i,n)cin >> k[i];
  long long mi[n][n];
  rep(i,n){
    mi[i][0]=k[i];
  }
  rep(i,n-1){
    rep(j,n){
      mi[j][i+1]=min(mi[j][i],k[(j-i-1+n)%n]);
    }
  }
  long long ans=100000000000000;
  rep(i,n){
    long long t=0;
    rep(j,n)t+=mi[j][i];
    ans=min(ans,t+i*x);
  }
  cout << ans << endl;
} 


Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
const int MX=(1<<20);
int arr[MX] , n , st , en ;
long long ans = 0;
int main(){
    cin>>n;
    n *= 3;
    st = 1 , en = n;
    for(int j = 1 ; j <= n ; j++) scanf("%d",&arr[j]);
    sort(arr+1 , arr+1+n);
    while(st <= en){
        ans += arr[--en];
        --en;
        ++st;

    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1536
import java.util.*;

public class Main {
	public static void main(String[] args) {
		// practice contest

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		double b = 0;
		b = (double) a / 2;
		double odd_num = 0;
		odd_num = Math.ceil(b);

		double probability = 0;
		probability = odd_num / (double) a;
		System.out.printf("%.9f", probability);
		System.out.println();

	}
}


Measured memory_bytes: 23252
#include <iostream>;
#include <queue>;
#include <string>;
#include <vector>;
using namespace std;


int main() {
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int>a(q);
	vector<int>b(q);
	for (int i = 0; i < q; i++)
	{
		cin >> a[i] >> b[i];
	}
	vector<int>c(n,0);
	int count = 0;
	for (int i = 1; i <= n-1; i++)
	{
		if (s[i-1] == 'A'&&s[i] == 'C') {
			count++;
		}
		c[i] = count;
	}
	for (int i = 0; i < q; i++)
	{
		cout << c[b[i] - 1] - c[a[i] - 1] << endl;
	}

}

Measured memory_bytes: 2304
#include<stdio.h>
using namespace std;
int main()
{
    int A, B, ad, time;
    scanf("%d %d", &A, &B);
    if(A>=0 && B >=0 && A <=23 && B <= 23){
        ad=A+B;
        if(ad >= 24){
            time=ad - 24;
        }
        else{
            time = ad;
        }
        printf("%d\n", time);
    }
   return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector

signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int ans = 0;
    int n;
    cin>>n;
    int arr[n+10];
    forn(i,1,n)
    {
        int a;
        cin>>a;
        
        arr[i] = (a%2?1:2);
        arr[i] = min(a,arr[i]);
        ans+=(a-1)/2;
    }
   // cout<<ans;nl;
    forn(i,1,n-1)
    {
        if(arr[i]==0)continue;
        if(arr[i]==2)ans++,arr[i]=0;
        else if(arr[i]==1)
        {
            if(arr[i+1]>0)
            {
                ans++;
                arr[i]--;
                arr[i+1]--;
            }
        }
       // cout<<i<<" "<<ans<<"\n";
    }
   // forn(i,1,n)cout<<arr[i]<<" ";nl;
    cout<<ans+(arr[n]/2);



    return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 1024
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		char[] stone = new char[S.length()];
		for( int i=0; i<S.length(); i++ ){
			stone[i] = S.charAt(i); 
		}
		int count = 0;
		for( int i=1; i<S.length(); i++ ){
			if( stone[i]!=stone[i-1] ){
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 28244
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define x first
#define y second
#define mp make_pair
#define pii pair<int,int>
#define MEM(x) memset(x,0,sizeof(x))
using namespace std;
bool cmp(const pii &a,const pii &b){
   // if(a.x!=b.x)return a.x<b.x;
    if(a.y!=b.y)
    return a.y<b.y;
}
bool cmp2(const pii &a,const pii &b){
    if(a.x!=b.x)return a.x<b.x;
    return a.y>b.y;
}
int main(){
    int n;
    scanf("%d",&n);
    pii p[200005];
    for(int i = 0;i<n;i++){
        int l,r;
        scanf("%d %d",&l,&r);
        p[i]=mp(l,r);
    }
    int ans=0;
    sort(p,p+n,cmp2);
    multiset<int> L,R;
    //int l=0,r=1e9;
    for(int i = 0;i<n;i++){
        L.insert(p[i].x);
        R.insert(p[i].y);
    }
    for(int i = 0;i<n;i++){
        L.erase(L.find(p[i].x));
        R.erase(R.find(p[i].y));
        ans=max(ans,max(*R.begin()-*L.rbegin()+1,0)+p[i].y-p[i].x+1);
        L.insert(p[i].x);
        R.insert(p[i].y);
    }
      //  l=max(l,p[i].x),r=min(r,p[i].y);
    //ans=max(r-l+1,0)+p[0].y-p[0].x+1;
    sort(p,p+n-1,cmp);
    L.clear();
    R.clear();
 //   multiset<int> L,R;
    for(int i = 0;i<n-1;i++){
        L.insert(p[i].x);
        R.insert(p[i].y);
    }
    int Min=p[n-1].y;
    for(int i=n-2;i>=0;i--){
        ans=max(ans,max(Min-p[n-1].x+1,0)+max(*R.begin()-*L.rbegin()+1,0));
        Min=min(Min,p[i].y);
        L.erase(L.find(p[i].x));
        R.erase(R.find(p[i].y));
    }
    printf("%d\n",ans);
}
/*
1 4
2 5
4 7
5 8

*/

Measured memory_bytes: 11136
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;

vector<ll> p;
vector<ll> q;
vector<ll> r;
vector<ll> merged;
int x,y,a,b,c;
vector<ll> s;
vector<ll> mer;

bool check(ll v){
    rep(i,x+1){
        ll tmp = v;
        tmp -= s[i];
        if (mer[x+y-i-1] >= tmp) return true;
    }
    return false;
};


int main(){

    cin >> x >> y >> a >> b >> c;
   
    
    rep(i,a){
        ll j;
        cin >> j;
        p.pb(j);
    }
    SORTR(p);
    ll add = 0LL;
    s.pb(add);
    rep(i,x){
        add += p[i];
        s.pb(add);
    }
    
    rep(i,b){
        ll j;
        cin >> j;
        q.pb(j);
    }
    SORTR(q);
    rep(i,y){
        merged.pb(q[i]);
    }
    
    rep(i,c){
        ll j;
        cin >> j;
        merged.pb(j);
    }
    
    SORTR(merged);
    add = 0LL;
    rep(i,merged.size()){
        add += merged[i];
        mer.pb(add);
    }
    
    
    ll left = 0;
    ll right = (ll) 1e18;
    
    while(left+1!=right){
        ll m = (left+right)/2;
        if (check(m)){
            left = m;
        }
        else right = m;
    }
    
    cout << left;
    
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int64_t a, b;
    double bf;
    cin >> a >> bf;
    b = bf * 100 + 0.5;
    cout << a * b / 100 << endl;
    return 0;
}

Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner a = new Scanner(System.in);
		int v = a.nextInt();
		String c = a.next();
		int w = a.nextInt();
		int flg = 1;
		if(c.equals("?"))
			flg = 0;
		while(flg > 0){
		if(c.equals("+")){
			System.out.println(v+w);
		}
		if(c.equals("-")){
			System.out.println(v-w);
		}
		if(c.equals("*")){
			System.out.println(v*w);
		}
		if(c.equals("/")){
			System.out.println(v/w);
		}
		if(c.equals("?")){
			return;
		}
		v = a.nextInt();
		c = a.next();
		w = a.nextInt();
		flg = 1;
		if(c.equals("?"))
			flg = 0;
		}
	}

}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a,b;

main() {
    cin >> a >> b;
    if (a%3 && b%3 && (a+b)%3) ct("Impossible")
    else ct("Possible")
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
	int n,m,v=0,c=0,i;
	cin>>n>>m;
	int a[n+1];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		v+=a[i];
	}
	double q=ceil((v*0.25)/m);
	//cout<<q<<endl;
	for(i=0;i<n;i++)
	{
		if(a[i]>=q)
		c++;
	}
	if(c>=m)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define gc getchar
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)
#define reb(i,u,z) for(rint i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

const int N=1e6+10;
ll n,p,ans=1;
ll cnt[N];

int main(){
	scanf("%lld%lld",&n,&p);
	if(n==1){
		printf("%lld",p);
		return 0;
	}
	ll emm=p;
	rep(i,2,sqrt(emm))while(emm%i==0)++cnt[i],emm/=i;
	rep(i,2,sqrt(p))rep(j,1,cnt[i]/n)ans*=(ll)i;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;
typedef long long int lli;
const int inf = numeric_limits<int>::max();




int main(){
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    if(m!=(n+1)){
        cout<<"No";
        return 0;
    }
    for(int i = 0;i<n;i++){
        if(s[i]!=t[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    
}




Measured memory_bytes: 3572
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())

if a1 < b1:
    a1,a2,b1,b2 = b1,b2,a1,a2
if a1*t1+a2*t2 == b1*t1+b2*t2:
    print("infinity")
    exit()
elif a1*t1+a2*t2 > b1*t1+b2*t2:
    print(0)
    exit()

q = a1*t1-b1*t1
w = (b1*t1+b2*t2) - (a1*t1+a2*t2)
we = int(q/w)
e = we*2-1
if q%w:
    e+=2
else:
    e+=1
print(e)

Measured memory_bytes: 38384
using System;
using System.Linq;
using static System.Console;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        int C = int.Parse(input[2]);
        int D = int.Parse(input[3]);
        if(A < C && B < D)
        {
            if(B - C <= 0)
            {
                Write(0);
            }
            else
            {
                Write(B - C);
            }
        }
        else if(A < C && B >= D)
        {
            Write(D - C);
        }
        else if(A >= C && B < D)
        {
            Write(B - A);
        }
        else
        {
            if(D - A <= 0)
            {
                Write(0);
            }
            else
            {
                Write(D - A);
            }
        }
    }
}

Measured memory_bytes: 11092
#include<stdio.h> 
int main() 
{
    int a,i,j; 
    for(i=1;i<=9;i++) 
    { 
    for(j=1;j<=9;j++) 
       { 
       printf("%dx%d=%d",i,j,i*j);
       printf("\n"); 
       } 
    } 
    return 0; 
 } 

Measured memory_bytes: 520
#include <stdio.h>
int main(void){

    int n;
    int i;
    scanf("%d",&n);
int a[n];

for (i = 0;i<n;i++){
scanf ("%d",&a[i]);
}
for (i = n-1;i > 0;i--){
printf("%d ",a[i]);
}
printf("%d\n",a[0]);
return 0;
}



Measured memory_bytes: 2068
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    ret = 0
    cnt = 0
    for s in S:
        if 'A' in s: cnt += 1
        elif 'C' in s: cnt += 1
        elif 'G' in s: cnt += 1
        elif 'T' in s: cnt += 1
        else: cnt = 0
        ret = max(ret, cnt)

    print(ret)


if __name__ == '__main__':
    main()


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N, M; cin >> N >> M;
  set<pair<int, int>> st;
  rep (i, M) {
    int a, b; cin >> a >> b;
    st.emplace(a, b);
  }

  REP (i, 2, N) {
    if (st.count({1, i}) && st.count({i, N})) {
      std::cout << "POSSIBLE\n";
      return 0;
    }
  }

  std::cout << "IMPOSSIBLE\n";
}

Measured memory_bytes: 9600
import java.util.*;
public class Main{
  public static void main(String[] args){
  	Scanner stdIn = new Scanner(System.in);
    	int a = stdIn.nextInt();
    	int kisuu = 0;
    		for(int i = 1; i <= a; i++){
              if(i%2!=0){
                kisuu++;
              }
            }
         System.out.println((double)kisuu/a);
            }
  }
           

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

    while (true)
    {
        int n, m;
        cin >> n >> m;
        if (n == 0 && m == 0)
            break;
        VVI dp(n + 1, vector<ll>(256, INF));
        std::vector<int> c(m), x(n + 1);
        for (int i = 0; i < m; i++)
            cin >> c[i];
        for (int i = 1; i <= n; i++)
            cin >> x[i];
        //ll dp[n+1][256];
        for (int i = 0; i < n + 1; i++)
            for (int j = 0; j < 256; j++)
                dp[i][j] = INF;
        dp[0][128] = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < 256; j++)
            {
                for (int k = 0; k < m; k++)
                {
                    if (j + c[k] > 255)
                        dp[i + 1][255] = min(dp[i + 1][255], dp[i][j] + (255 - x[i + 1]) * (255 - x[i + 1]));
                    else if (j + c[k] < 0)
                        dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + (x[i + 1]) * (x[i + 1]));
                    else
                        dp[i + 1][j + c[k]] = min(dp[i + 1][j + c[k]], dp[i][j] + (j + c[k] - x[i + 1]) * (j + c[k] - x[i + 1]));
                }
            }
        ll res = INF;
        for (int i = 0; i < 256; i++)
            res = min(res, dp[n][i]);
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 43792
import sys
input = sys.stdin.readline
from collections import *

N, A, B, C = map(int, input().split())
s = [input()[:-1] for _ in range(N)]
ans = []

if A+B+C<=1 or A+B+C>=3:
    for si in s:
        if si=='AB':
            if A==0 and B==0:
                print('No')
                exit()
                
            if A<B:
                A += 1
                B -= 1
                ans.append('A')
            else:
                A -= 1
                B += 1
                ans.append('B')
        elif si=='AC':
            if A==0 and C==0:
                print('No')
                exit()
                
            if A<C:
                A += 1
                C -= 1
                ans.append('A')
            else:
                A -= 1
                C += 1
                ans.append('C')
        else:
            if B==0 and C==0:
                print('No')
                exit()
                
            if B<C:
                B += 1
                C -= 1
                ans.append('B')
            else:
                B -= 1
                C += 1
                ans.append('C')

    print('Yes')
    
    for ans_i in ans:
        print(ans_i)

    exit()
    
for i in range(N):
    if s[i]=='AB':
        if A==0 and B==0:
            print('No')
            exit()
            
        if A==0:
            A += 1
            B -= 1
            ans.append('A')
        elif B==0:
            A -= 1
            B += 1
            ans.append('B')
        else:
            if i<N-1 and s[i+1]=='AC':
                A += 1
                B -= 1
                ans.append('A')
            else:
                A -= 1
                B += 1
                ans.append('B')
    elif s[i]=='AC':
        if A==0 and C==0:
            print('No')
            exit()
            
        if A==0:
            A += 1
            C -= 1
            ans.append('A')
        elif C==0:
            A -= 1
            C += 1
            ans.append('C')
        else:
            if i<N-1 and s[i+1]=='AB':
                A += 1
                C -= 1
                ans.append('A')
            else:
                A -= 1
                C += 1
                ans.append('C')
    else:
        if B==0 and C==0:
            print('No')
            exit()
            
        if B==0:
            B += 1
            C -= 1
            ans.append('B')
        elif C==0:
            B -= 1
            C += 1
            ans.append('C')
        else:
            if i<N-1 and s[i+1]=='AB':
                B += 1
                C -= 1
                ans.append('B')
            else:
                B -= 1
                C += 1
                ans.append('C')

print('Yes')
    
for ans_i in ans:
    print(ans_i)

Measured memory_bytes: 80492