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

#define bug(x) cout << #x << " = " << x << endl;
#define fr(a) freopen(a,"r",stdin);
#define fw(a) freopen(a,"w",stdout);
#define tc() int tc;cin >> tc; for (int _tc=1;_tc<=tc;_tc++)
#define up(i,l,r) for (int i=l;i<=r;i++)
#define down(i,r,l) for (int i=r;i>=l;i--)
#define pb push_back
#define mp make_pair
#define ins insert;
typedef long long int ll;
typedef unsigned long long int llu;
using namespace std;

void printArr(int a[], int l, int r)
{
    up(i,l,r) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void printMtx(int a[][1010],int n, int m)
{
    up(i,1,n) {
        up(j,1,m) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n, sum = 0, a[110], minn = INT_MAX;

    cin >> n;
    up(i,1,n) {
        cin >> a[i];
        sum += a[i];
        if ((a[i] % 10!=0) && (a[i] < minn)) {
            minn = a[i];
        }
    }
    if (minn == INT_MAX) cout << 0 << endl;
    else {
        if (sum % 10 != 0) cout << sum << endl;
        else cout << sum - minn << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int n,ans;


int main(){

  int r,g,b,n;
  int ans=0;
  
  cin >> r >> g >> b >> n;
  
  for( int i=0; i<=n; i++){
    for( int j=0; j<=n; j++){
      //cout << i*r+j*g << endl;
      if( i*r + g*j <= n && (n - i*r - j*g)%b == 0) ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

void err()
{
    cout << -1 << '\n';
    exit(0);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = (int)s.size();
    if (s[n - 1] != '0')
    {
        err();
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] != s[n - 2 - i])
        {
            err();
        }
    }
    if (s[0] != '1')
    {
        err();
    }
    int last = 0;
    for (int i = 0; i < n-1; i++)
    {
        cout << last+1 << ' ' << i+2 << endl;
        if(s[i] == '1') last = i+1;
    }
    return 0;
}

Measured memory_bytes: 1744
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		int n = 0;
		for(int i=0; i<S.length()/2; i++) {
			if(S.charAt(i) != S.charAt(S.length()-1-i)) {
				n++;
			}
		}
		System.out.println(n);
	}

}

Measured memory_bytes: 23636
#include <cstdio>
#include <cstring>
#define  fr(i,x,y) for(i=x;i<=y;i++)
#define  frd(i,x,y) for(i=x;i>=y;i--)
const int maxn=310;
const int maxm=(int)2e5+10;
int n,m,T,p;
int have[maxn],a[maxn],left[maxn];
int want[maxn][maxn],ori[maxn][maxn];
int list[maxm][2];
int fa[maxn],sta[maxn];
void Read()
{	
	int i,j;
	scanf("%d%d%d",&n,&m,&T);
	fr(j,1,m)scanf("%d",&have[j]);
	memset(left+1,0,n*sizeof(int));
	fr(i,1,n)
	fr(j,1,m)
	{
		scanf("%d",&want[i][j]),ori[i][j]=want[i][j];
		if(want[i][j])left[i]++;
	}
	fr(i,1,T)scanf("%d%d",&list[i][0],&list[i][1]);
}
void Go_up(int low,int high)
{
	int i,j,p,r;
	fr(i,low+1,high)
	{
		p=list[i][0],r=list[i][1];
		have[r]--;
		want[p][r]--;
		if(!want[p][r])
		{
			left[p]--;
			if(!left[p])fr(j,1,m)have[j]+=ori[p][j];
		}
	}
}
void Go_down(int high,int low)
{
	int i,j,p,r;
	frd(i,high,low+1)
	{
		p=list[i][0],r=list[i][1];
		have[r]++;
		if(!want[p][r])
		{
			if(left[p]==0)fr(j,1,m)have[j]-=ori[p][j];
			left[p]++;
		}
		want[p][r]++;
	}
}
int Get_fa(int x)
{
	while(fa[x]!=x)sta[++sta[0]]=x,x=fa[x];
	while(sta[0])fa[sta[sta[0]--]]=x;
	return x;
}
bool Check()
{
	int i,j,cnt;
	bool bo;
	fr(i,1,n+1)fa[i]=i;
	memcpy(a+1,have+1,m*sizeof(int));
	cnt=0;
	bo=true;
	while(bo)
	{
		bo=false;
		for(i=Get_fa(1);i<=n;i=Get_fa(i+1))
		{
			fr(j,1,m)if(want[i][j]>a[j])break;
			if(j<=m)continue;
			cnt++;
			if(left[i]!=0)
				fr(j,1,m)a[j]+=ori[i][j]-want[i][j];
			bo=true;
			fa[i]=Get_fa(i+1);
			break;
		}
	}
	return cnt==n;
}
void Solve()
{
	int le,ri,mi;
	le=0,ri=T;
	p=0;
	while(le<=ri)
	{
		mi=(le+ri)>>1;
		if(mi>p)Go_up(p,mi);
		else Go_down(p,mi);
		p=mi;
		if(Check())le=mi+1;
		else ri=mi-1;
	}
	if(le>T)le=-1;
	printf("%d\n",le);
}
int main()
{
	Read();
	Solve();
}

Measured memory_bytes: 3352
S = input()
S = S.replace('><','> <').split()

ans = 0
for i in S:
    j = max(i.count('>'),i.count('<'))
    k = min(i.count('>'),i.count('<'))-1
    for a in range(1,j+1):
        ans += a
    for b in range(1,k+1):
        ans += b

print(ans)

Measured memory_bytes: 19380
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(void){
  int n;
  cin>>n;
  int used = 0;
  bool ans = true;
  while(n--){
    char in;
    int num;
    cin>>in>>num;

    if(in=='('){
      used += num;
    }else if(in==')'){
      used -= num;
    }
    if(used < 0){
      ans = false;
      break;
    }
  }
  if(ans && used == 0){
    cout<<"YES"<<endl;
  }else 
    cout<<"NO"<<endl;
}

Measured memory_bytes: 1160
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    k = int(input())
    S = input()
    if len(S) <= k:
        print(S)
    else:
        print(S[:k] + "...")
resolve()

Measured memory_bytes: 61680
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
pll dat[800010];
ll u;
void seginit(ll n){
    ll y=1;
    for(int i=0;;i++){
        
        if(y>=n){
            u=y;
            break;
        }
        y*=2;
    }
    fill(dat,dat+2*u,make_pair(-inf,-inf));
}
void add(ll n,ll x){
    ll i=n+u-1;
    dat[i]=make_pair(x,n);
    while(i>0){
        i=(i-1)/2;
        dat[i]=max(dat[2*i+1],dat[i*2+2]);
    }
}
pll que(ll a,ll b,ll k,ll l,ll r){
    if(a>=r||b<=l)return make_pair(-inf,-inf);
    if(a<=l&&b>=r)return dat[k];
    pll m1=que(a,b,2*k+1,l,(l+r)/2);
    pll m2=que(a,b,2*k+2,(l+r)/2,r);
    return max(m1,m2);
}
int main(){
    ll n;cin>>n;
    seginit(n+1);
    ll a[n],b[n];
    int c=0;
    ll cnt=0;
    rep(i,0,n){
        cin>>a[i];
    }
    rep(i,0,n){
        cin>>b[i];
        add(i,b[i]);
        if(a[i]>b[i])c=1;
        if(a[i]==b[i]){
            add(i,-inf);
            cnt++;
        }
    }
    if(c==1){
        cout<<-1<<endl;
        return 0;
    }
    ll ans=0;
    
    for(;;){
        
        if(cnt==n)break;
        pll p=que(0,u,0,0,u);
        ll num=p.second;
        ll f=(p.second-1+n)%n;
        ll g=(p.second+1)%n;
        ll wa=b[f]+b[g];
        //cout<<wa<<" ";
        if(wa+a[num]>b[num]){
            cout<<-1<<endl;
            return 0;
        
        }
        ll t=(b[num]-a[num])/wa;
        ll r=max(b[f],b[g]);
        ll tt=ceil((double)(b[num]-r)/wa);
        t=min(t,tt);
        b[num]-=t*wa;
        ans+=t;
        if(b[num]==a[num]){
            cnt++;
            add(num,-inf);
        }
        else add(num,b[num]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
int main() {
     string a,b,c;
     cin >> a >> b >> c;
     if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) cout << "YES" << endl;
     else cout << "NO" << endl;
}

Measured memory_bytes: 256
primes = [2]

X = int(input())


def is_prime(n):
    for p in primes:
        if n < p * p:
            break
        if n % p == 0:
            return False
    return True


for i in range(3, X, 2):
    if is_prime(i):
        primes.append(i)

while True:
    if is_prime(X):
        print(X)
        break
    X += 1


Measured memory_bytes: 3392
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    List<int>[] G;
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        G = new List<int>[N];
        for(int i=0;i<N;i++){
            G[i] = new List<int>();
        }
        for(int i=0;i<N-1;i++){
            string[] str = Console.ReadLine().Split(' ');
            int x = int.Parse(str[0])-1;
            int y = int.Parse(str[1])-1;
            G[x].Add(y);
            G[y].Add(x);
        }
        int count = dfs(0,-1);
        if(count == 0){
            sb.Append("Bob\n");
        }
        else{
            sb.Append("Alice\n");
        }
    }
    int dfs(int v,int f){
        int x = 0;
        for(int i=0;i<G[v].Count;i++){
            int t = G[v][i];
            if(t != f){
                x ^= dfs(t,v)+1;
            }
        }
        return x;
    }
}

Measured memory_bytes: 32776
a, b, c, x, y = map(int, input().split())
if a + b < c * 2:
    ans = a * x + b * y
else:
    p1_cnt = max(x, y)
    p1_price = p1_cnt * c * 2
    p2_cnt = min(x, y)
    if p2_cnt == x:
        p2_price = p2_cnt * c * 2 + (y - x) * b
    else:
        p2_price = p2_cnt * c * 2 + (x - y) * a
    ans = min(p1_price, p2_price)
print(ans)

Measured memory_bytes: 3064
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

int main() {
  ll n;
  cin >> n;
  map<ll, bool> mp;
  rep(i, n) {
    ll t;
    cin >> t;
    mp[t] = true;
  }

  if ((ll)mp.size() == n)
    puts("YES");
  else
    puts("NO");

  //cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    double w,h,x,y;
    int ans = 0;
    vector<int> l;

    cin >> w >> h >> x >> y;
   
    cout << w*h/2 << " ";

    if (x == w/2 && y == h/2) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <math.h>

using namespace std;

string w[41];
int n,ans;
int d=0;
int solve(){
    for(int i=0;i<n;i++){
    int a=0;
    d=0;
        for(int j=i;j<n;j++){
            a+=w[j].length();
            if(d==0&&a==5){
            d++;
            a=0;
            }
            if(d==1&&a==7){
             d++;
            a=0;
            }
            if(d==2&&a==5){
             d++;
            a=0;
            }
            if(d==3&&a==7){
             d++;
            a=0;
            }
            if(d==4&&a==7){
            ans=i+1;
            return i;
            }
            if(a>7)break;
        }
    }
    return 0;
}
int main()
{
    while(1){
    cin>>n;
    if(n==0)return 0;
    for(int i=0;i<n;i++)
    cin>>w[i];
    
    d=0;
    solve();
    cout<<ans<<endl;
    }
}



Measured memory_bytes: 3212
N,Q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for _ in range(Q)]

c = [0] * (N+1)
for i in range(0, N):
    if i+1 < N and S[i] == 'A' and S[i+1] == 'C':
        c[i+1] = c[i] + 1
    else:
        c[i+1] = c[i]

for i in range(Q):
    print(c[lr[i][1]-1] - c[lr[i][0]-1])



Measured memory_bytes: 30728
#include <bits/stdc++.h>
using namespace std;
int n, a, b, z;
char s[300020];
int main() {
	scanf("%d%s", &n, s);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'E') {
			b++;
		}
	}
	z = n;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'E') {
			b--;
		}
		z = min(z, a + b);
		if (s[i] == 'W') {
			a++;
		}
	}
	printf("%d\n", z);
	return 0;
}

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

using namespace std;

#define N 100000

int n, L, a[N + 5];

int main() {
    scanf("%d%d", &n, &L);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    int pos = 0;
    for (int i = 1; i < n; ++i)
        if (a[i] + a[i + 1] >= L) {
            pos = i;
            break;
        }
    if (!pos)
        printf("Impossible\n");
    else {
        printf("Possible\n");
        for (int i = 1; i < pos; ++i)
            printf("%d\n", i);
        for (int i = n - 1; i > pos; --i)
            printf("%d\n", i);
        printf("%d\n", pos);
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

void find_divisor(ll N, vector<ll>& divisor) {
  for(int i=1; i<=sqrt(N); i++) {
    if(N % i == 0)
      divisor.push_back(i);
  }
  int n = divisor.size();
  for(int i=n-1; i>=0; i--) {
    if(N != (ll)pow(divisor[i], 2))
      divisor.push_back(N / divisor[i]);
  }
}
ll extGCD(ll a, ll b, ll &x, ll &y) {
  if(b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  ll d = extGCD(b, a%b, y, x);
  y -= a/b * x;
  return d;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n; cin >> n;
  vector<ll> div;
  find_divisor(n*2, div);
  ll ans = n*2-1;
  for(ll d1: div) {
    ll d2 = n*2/d1;
    if(__gcd(d1, d2) != 1) continue;
    auto ret = crt({0, -1}, {d1, d2});
    if(ret.first == 0) continue;
    chmin(ans, ret.first);
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3796
/***************************************** 
****       Solution by SlavicG        ****
*****************************************/
 
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm> 
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define vair <vector<pair<int,int>>
#define vi vector<int>
#define mp make_pair
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI   3.14159265
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n) 
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool isPrime(ll n)
{
    if(n<2) return false;
    for(ll x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
int binary_Search_Classic(int n, int arr[],int target){
	int l,r,mid;
	l=0;
	r=n-1;
	while(l<=r){
		mid= l+(r-l)/2;
		if(arr[mid] == target){
			return mid;
		}
		if(arr[mid] < target){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return -1;
	
}
vector<int> Two_PointerSumOfTwo(vector<int> arr, int target)
{
	int l = 0, r = arr.size()-1;
	vector<int> ans;
	while(l<r){
		if(arr[l] + arr[r] == target)
		{
			ans.push_back(l);
			ans.push_back(r);
			break;
		}else if(arr[l] + arr[r] > target){
			r--;
		}else{
			l++;;
		}
	}
	return ans;
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m; 
    for (int i = 0; i <(int)s.length(); i++) { 
        m[s[i]]++; 
    }
    return m.size(); 
}
int f(int x)
{
	x++;
	while(x % 10 == 0)
	{
		x  = x/10;
	}
	return x;
}
int main()
{
	int n;
	cin >> n;
	int first1000 = n;
	while(first1000%1000 != 0)
	{
		first1000++;
	}
	cout << first1000 - n << endl;
}

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

int dig (int X) {
	int R = 0;
	for(int i=X;i;i/=10) {
		R += i%10;
	}
	return R;
}

int main()
{
	scanf("%d",&n);
	int ans = 1e9;
	for(int i=1;i<n;i++) {
		ans = min(ans, dig(i) + dig(n-i));
	}
	printf("%d\n",ans);
}


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

dp = [0 for _ in range(n+1)]

def ans(dp, n, m) -> list:
    if m == 0:
        return [0, 0]

    ac = 0
    wa = 0
    i = 0
    while i < m:
        q, r = input().split()
        q = int(q)

        if dp[q] == None:
            pass
        elif r == 'WA':
            dp[q] += 1
        elif r == 'AC':
            ac += 1
            wa += dp[q]
            dp[q] = None

        i += 1

    return [ac, wa]

a = ans(dp, n, m)

print(*a)

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
int main() {
  string s,t;
  cin>>s>>t;
  int count=0;
  for(int i=0;i<3;i++){
    if(s.at(i)==t.at(i)){
      count++;
    }
  }
cout<<count;
  
}

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

int main() {
    int h,w,k; cin >> h >> w >> k;
    vector<string> s(h);
    for (int i = 0; i < h; i++) cin >> s[i];

    int answer = h + w;
    for (int mask = 0; mask < (1 << (h - 1)); mask++) {
        int block = __builtin_popcount(mask) + 1;
        int cut = block - 1;
        vector<int> count(block, 0);
        for (int i = 0; i < w; i++) {
            int block_num = 0;
            vector<int> count_new(block, 0);
            for (int j = 0; j < h; j++) {
                count_new[block_num] += s[j][i] - '0';
                block_num += (mask & 1 << j) > 0 ? 1 : 0;
            }
            bool possible = true;
            for (int j = 0; j < block; j++) {
                if (count_new[j] > k) {
                    possible = false;
                    break;
                }
            }
            if (!possible) {
                cut = h + w;
                break;
            }
            bool pass = true;
            for (int j = 0; j < block; j++) {
                if (count[j] + count_new[j] > k) {
                    pass = false;
                    break;
                }
            }
            if (pass) {
                for (int j = 0; j < block; j++)
                    count[j] += count_new[j];
            } else {
                if (i == 0) {
                    cut = h + w;
                    break;
                }
                count = count_new;
                cut += 1;
            }
        }
        answer = min(answer, cut);
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  int mx = 0;
  rep(i, s.size()) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      cnt++;
    } else {
      mx = max(mx, cnt);
      cnt = 0;
    }
  }
  mx = max(mx, cnt);
  cout << mx;
  return 0;
}


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

int main()
{   
	int k, a, b;
	cin >> k >> a >> b;
	bool f = false;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			f = true;
		}
	}
	if (f) {
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[10000005];
ll dp[20005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;
double q[200005];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
string s[2000005];
P p[2000005];
int main() {
	int n, k;
	cin >> n >> k;
	if (n < 10) {
		cout << k + 100 * (10 - n) << endl;
		return 0;
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 16640
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>
#include<map>

using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
  int k, t;cin>>k>>t;
  int ans=0;
  for(int i=0;i<t;i++){
  	int a;cin>>a;
    ans+=max(0, a*2-k-1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import queue
H,W = map(int,input().split())
maze = [0]*H
for i in range(H):
    maze[i] = input()
inf = float('inf')
d = [[inf for i in range(W)] for i in range(H)]
dx = [1,0,-1,0]
dy = [0,1,0,-1]


def bfs():
    que = queue.Queue()
    que.put((0,0))
    d[0][0] = 0
    while que.qsize():
        p = que.get()
        if p == (H-1,W-1):
            break
        for i in range(4):
            nx = p[0]+dx[i]
            ny = p[1]+dy[i]
            if 0 <= nx and nx <= H-1 and 0 <= ny and ny <= W-1 \
            and maze[nx][ny] != '#' and d[nx][ny] == inf:
                d[nx][ny] = d[p[0]][p[1]] + 1
                que.put((nx,ny))

bfs()

count = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            count += 1

ans = -1
if d[H-1][W-1] != inf:
    ans = H*W-count-1-d[H-1][W-1]
print(ans)


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

using namespace std;

#define UP 1
#define LEFT 2
#define DIAG 3

int dp[3011][3011];
int movs[3011][3011];

int main() {
	string s,t;

	cin >> s >> t;

	for(int i = 0; i < 3010; i++) {
		dp[0][i] = 0;
		dp[i][0] = 0;
	}

	for(int i = 0; i < s.size(); i++) {
		for(int j = 0; j < t.size(); j++) {
			if (s[i] == t[j]) {
				dp[i+1][j+1] = dp[i][j] + 1;
				movs[i+1][j+1] = DIAG;
			} else if (dp[i+1][j] > dp[i][j+1]){
				dp[i+1][j+1] = dp[i+1][j];
				movs[i+1][j+1] = LEFT;
			} else {
				dp[i+1][j+1] = dp[i][j+1];
				movs[i+1][j+1] = UP;
			}
		}
	}
	string r = "";
	int i = s.size();
	int j = t.size();
	while(i > 0 and j > 0) {
		switch(movs[i][j]){
			case DIAG:
				i--; j--;
				r = s[i] + r;
				break;
			case UP:
				i--;
				break;
			case LEFT:
				j--;
				break;
		}
	}
	cout << r << endl;
}


Measured memory_bytes: 71040
<?php
	fscanf(STDIN,"%d%d",$n,$T);
	$c=2000;
	for($i=0;$i<$n;$i++){
		fscanf(STDIN,"%d%d",$a,$t);
		if($t<=$T&&$a<$c)$c=$a;
	}
	echo $c<2000?$c:TLE;


Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int r;

signed main() {
	cin >> r;
	cout << 3 * r*r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=3009;
int main()
{
    FASTINOUT;
    ll x;
    cin>>x;
    ll y[x];
    ll r=0;
    for (int i=0;i<x;i++){
        cin>>y[i];
        r^=y[i];
    }
    for (int i=0;i<x;i++){
        cout<<(r^y[i])<<" ";
    }
    return 0;
}


Measured memory_bytes: 5032
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,M;
  string S;
  cin >> N >> M >> S;

  vector<int> dp(N+1,1e9);
  dp.at(0)=0;
  int r=0;
  int nr=-1;
  for(int i=1;i<N+1;i++){
    if(r+M<i){
      if(nr==-1){
        cout << -1 << endl;
        return 0;
      }
      r=nr;
      nr=-1;
    }
    if(S.at(i)=='1')  continue;
    dp.at(i)=dp.at(r)+1;
    nr=i;
  }
  vector<int> ans;
  int now=N;
  int nnow=-1;
  for(int i=N;i>=0;i--){
    if(now-M>i){
      ans.p_b(now-nnow);
      now=nnow;
      nnow=-1;
    }
    if(S.at(i)=='1')  continue;
    nnow=i;
  }
  if(nnow!=-1)  ans.p_b(now-nnow);
  reverse(all(ans));
  for(int i=0;i<sz(ans);i++)  cout << ans.at(i) << " ";
  cout << endl;

  return 0;
}

Measured memory_bytes: 4392
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n, a[100001] = {0}, b, amax = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> b;
        a[b] += 1;
    }
    for(int i = 1; i < 99999; i++){
        amax = max(amax, a[i-1] + a[i] + a[i+1]);
    }
    cout << amax << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};
template <typename T>
class SegmentTree
{
private:
  using Fn = function<T(T, T)>;
  int N;
  vector<T> dat;
  const T unit; //単位元 a * e = a
  Fn func;

public:
  SegmentTree(int n_, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    while (N < n_)
      N *= 2;
    dat.assign(2 * N - 1, unit);
  }

  void update(int k, T a)
  {
    k += N - 1;
    dat[k] = a;
    while (k > 0)
    {
      k = (k - 1) / 2;
      dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]); //
    }
  }

  T query(int a, int b, int k = 0, int l = 0, int r = -1)
  {
    if (r < 0)
      r = N;
    if (r <= a || b <= l)
      return unit;
    if (a <= l && r <= b)
      return dat[k];
    else
    {
      T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return func(vl, vr);
    }
  }
};

int main()
{
  string s, t;
  cin >> s >> t;
  auto add_mod = [](int a, int b) { return (a + b) % 3; };
  SegmentTree<int> sg_s(s.length(), add_mod, 0), sg_t(t.length(), add_mod, 0);
  rep(i, s.length())
  {
    sg_s.update(i, (s[i] == 'A' ? 1 : 2));
  }
  rep(i, t.length())
  {
    sg_t.update(i, (t[i] == 'A' ? 1 : 2));
  }
  int q;
  cin >> q;
  rep(qi, q)
  {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--, c--;
    YES(sg_s.query(a, b) == sg_t.query(c, d));
  }
  return 0;
}


Measured memory_bytes: 2944
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    int t[n];
    for(int i=0;i<n;i++)    cin>>t[i];
    int m;
    cin>>m;
    while(m--){
        int p,x;
        cin>>p>>x;
        p--;
        int sum=0;
        for(int i=0;i<n;i++){
            if(i==p)    sum +=x;
            else        sum +=t[i];
        }
        cout<<sum<<endl;
    }
    return 0;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  vector<int> v(3, 0);
  cin >> v[0] >> v[1] >> v[2];
  sort(all(v));
  cout << v[0] + v[1] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define NUM 100

int main(){
  char c;
  int i,stack[NUM];

  for(i=0;i<NUM;i++){
    stack[i]=0;
  }
  i=0;
  
  while((c=getchar())!='\n'){
    if(c>='0'&&c<='9'){
      stack[i]=10*stack[i]+(c-'0');
    }
    if(c==' '){
      i++;
    }
    if(c=='+'){
      i--;
      stack[i-1]+=stack[i];
      stack[i]=0;
      i--;
    }
    if(c=='-'){
      i--;
      stack[i-1]-=stack[i];
      stack[i]=0;
      i--;
    }
    if(c=='*'){
      i--;
      stack[i-1]*=stack[i];
      stack[i]=0;
      i--;
    }
  }
  
  printf("%d\n",stack[0]);
  return 0;
}



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

int main(){
  long N,K;
  cin  >> N >> K;
  vector<int> h(N);
  int ans=0;
  for(int i=0;i<N;i++){
    cin >> h.at(i);
    if(h.at(i) >= K){
      ans++;
    }
  }
  cout << ans << endl;
  
}



Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
   static int n, k;
	static int[] w;
	
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		n = Integer.parseInt(str[0]);
		k = Integer.parseInt(str[1]);
		w = new int[n];
		
		for(int i = 0; i < n; i++){
			w[i] = Integer.parseInt(br.readLine());
		}
		
		long answer = BinarySearch();
		
		System.out.println(answer);
	}
	
	static long BinarySearch(){
		
		long min = 0;
		long max = 100000 * 10000;
		
		while(max - min >1){
			long middle = (min + max) / 2;
			if(check(middle)) max = middle;
			else min = middle;
		}
		return max;
	}
	
	static boolean check(long m){
		long sum = 0;
		int idx = 0;
		
		for(int i = 0; i < k; i++){
			sum = 0;
			while(w[idx] + sum <= m){
				sum += w[idx];
				idx++;
				if(idx == n) return true;
			}
		}
		return false;
	}
}

Measured memory_bytes: 35336
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long a,b,t=1000000001,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a,&b);
		ans+=a;
		if(a>b)
		t=min(t,b);
	}
	if(t==1000000001)
		printf("0");
	else printf("%lld",ans-t);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
ll xy[4040];
ll yz[4040];
ll xz[4040];
ll solve(string x,string y,string z){
    rep(i,4040){
        xy[i]=0;
        yz[i]=0;
        xz[i]=0;
    }
    ll NX=x.size();
    ll NY=y.size();
    ll NZ=z.size();
    rep(i,4040){
        bool ok=true;
        rep(j,min(NX-i,NY)){
            if(x[i+j]!='?' and y[j]!='?' and x[i+j]!=y[j]){
                ok=false; break;
            }
        }
        if(!ok) continue;
        xy[i]=1;
    }
    rep(i,4040){
        bool ok=true;
        rep(j,min(NX-i,NZ)){
            if(x[i+j]!='?' and z[j]!='?' and x[i+j]!=z[j]){
                ok=false; break;
            }
        }
        if(!ok) continue;
        xz[i]=1;
    }
    rep(i,4040){
        bool ok=true;
        rep(j,min(NY-i,NZ)){
            if(y[i+j]!='?' and z[j]!='?' and y[i+j]!=z[j]){
                ok=false; break;
            }
        }
        if(!ok) continue;
        yz[i]=1;
    }

    ll res=INF2;
    rep(i,4020){
        if(!xz[i]) continue;
        bool ok=false;
        ll mi=-1;
        rep(j,i+1){
            if(xy[j] and yz[i-j]) {
                ok=true;
                mi=j;
                break;
            }
        }
        if(!ok) continue;
        mini(res,max({NX,i+NZ,mi+NY}));
    }
    return res;
}
//--MAIN-----------------------------------
void Main() {
    string a,b,c; cin>>a>>b>>c;
    ll ans=INF2;
    mini(ans,solve(a,b,c));
    mini(ans,solve(a,c,b));
    mini(ans,solve(b,a,c));
    mini(ans,solve(b,c,a));
    mini(ans,solve(c,a,b));
    mini(ans,solve(c,b,a));
    cout<< ans<<"\n";
}

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
vector<int> rel[1000000];
bool checked[1000000];

void dfs(int i){
    checked[i] = true;
    for (int j : rel[i])
    {
        if(!checked[j]){
            dfs(j);
        }
    }    
}

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

    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin>> a >> b >> c;
        rel[a-1].push_back(b-1);
        rel[b-1].push_back(a-1);
    }
    memset(checked,false, sizeof(checked));
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        if(!checked[i]){
            dfs(i);
            sum ++ ;
        }
    }
    cout << sum << endl; 
}


Measured memory_bytes: 34164
def main():
    N = int(input())
    tot = 0
    conv_rate = 380000.0
    for i in range(N):
        x, u = input().split()
        x = float(x)
        if u == "JPY":
            tot += x
        else:
            tot += x * conv_rate

    return tot

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

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

vec x(15), y(15), p(15), ans(16, INF);

void dfs(vec &choose, vec &see, int now){
    ll sz = choose.size();
    if(now == N){
        ll res = 0;
        for(ll v : see){
            ll dist = min(abs(x[v]), abs(y[v]));
            for(ll to : choose){
                chmin(dist, to >= N ? abs(y[to - N] - y[v]) : abs(x[to] - x[v]));
            }
            res += dist * p[v];
        }
        chmin(ans[sz], res);
    }else{
        see.push_back(now);
        dfs(choose, see, now + 1);
        see.pop_back();
        choose.push_back(now);
        dfs(choose, see, now + 1);
        choose.pop_back();
        choose.push_back(now + N);
        dfs(choose, see, now + 1);
        choose.pop_back();

    }
}

int main() {
    cin>>N;
    rep(i,N) cin>>x[i]>>y[i]>>p[i];
    vec choose(0), see(0);
    dfs(choose, see, 0);
    rep(i,N + 1) cout<<ans[i]<<endl;
}


Measured memory_bytes: 3552
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var NAB = ReadLongArray();
            var div = NAB[0] / (NAB[1] + NAB[2]);
            var lastBlue = NAB[0] % (NAB[1] + NAB[2]);
            lastBlue = lastBlue >= NAB[1] ? NAB[1] : lastBlue;
            Console.WriteLine(div * NAB[1] + lastBlue);
        }
        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 13396
s = input()[:-2]
l = len(s) // 2
s1 = s[:l]
s2 = s[l:]
while s1 != s2:
   s = s[:-2]
   l = len(s) // 2
   s1 = s[:l]
   s2 = s[l:]  
print(len(s1 + s2))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll d,t,s;cin>>d>>t>>s;
  if(d <= t*s)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    int list[100010]={};
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        list[a]++;list[a+1]++;list[a-1]++;
    }
    int max1 = 0;
    for(int i=0;i<100010;i++){
        if(max1<list[i])max1 = list[i];
    }
    cout << max1 << endl;
}

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

namespace abc161a
{
    class Program
    {
        static void Main(string[] args)
        {

            //1) input
            List<int> input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();



            //2) output
            string output = input[2] + " " + input[0] + " " + input[1];
            Console.WriteLine(output);

        }
    }
}


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

int main(){
  int A,B;
  cin>>A>>B;
  int a;
  
  while(A<=B){
    int i;
    int S;
    S=A;
    int A2=0;
    for(i=1;i<=5;i++){
      int x;
      int o;
      x=S%10;
      S=S/10;
      o=A2*10;
      A2=x+o;
    }
    if(A2==A){
      a=a+1;
    }
    A=A+1;
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(){
  int i, j, n, u, k, temp;
  int Adj[101][101];

  scanf("%d", &n);

  for(i=1; i<=n; i++){
    for(j=1; j<=n; j++){
      Adj[i][j] = 0;
    }
  }

  for(i=0; i<n; i++){
    scanf("%d%d", &u, &k);
    for(j=0; j<k; j++){
      scanf("%d",&temp);
      Adj[u][temp] = 1;
    }
  }

  for(i=1; i<=n; i++){
    for(j=1; j<=n; j++){
      if(j == 1) printf("%d", Adj[i][j]);
      else printf(" %d", Adj[i][j]);
    }
    printf("\n");
  }

  return 0;

}

Measured memory_bytes: 640
from fractions import gcd

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(numbers):
    t = 1
    for n in numbers:
        t = lcm_base(t, n)
    return t

N = int(input())
A = [int(x) for x in input().split()]

mod = 10**9+7
ans = 0
t = lcm(A)
t %= mod
for i in range(N):
    ans = (ans + t*pow(A[i],mod-2, mod))%mod

print(ans)


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

int main() {
  int N, total;
  cin >> N;
  
  bool y = false;
  
  for (int c = 0; c <= N/4; c++) {
    for (int d = 0; d <= N/7; d++) {
      total = 4*c + 7*d;
      if (total == N) {
        y = true;
        break; }
    }
  }
  if (y == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){
  ll T1, T2; cin >> T1 >> T2;
  ll A1, A2; cin >> A1 >> A2;
  ll B1, B2; cin >> B1 >> B2;

  if (A1 < B1){
    ll K1 = B1, K2 = B2;
    B1 = A1; B2 = A2;
    A1 = K1; A2 = K2;
  }

  if (A1 * T1 + A2 * T2 == B1 * T1 + B2 * T2){
    cout << "infinity" << endl;
  }else if(A1 * T1 + A2 * T2 > B1 * T1 + B2 * T2){
    cout << 0 << endl;
  }else{
    ll D = (A1 - B1) * T1;
    ll d = (B1 * T1 + B2 * T2) - (A1 * T1 + A2 * T2);

    ll ans;
    if (D % d != 0) ans = D / d * 2  + 1;
    else ans = D / d * 2;
    cout << ans << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <map>
#include <cstdio>
using namespace std;
#define rep(i,n) for(i = 0; i < n; i++)
#define repe(i,n) for(i = 0; i <= n; i++)
#define repr(i,n) for(i = n; i >= 0; i--)
#define INF = 999999999
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD = 1000000007;

int main(){
   int n,i;
   cin >> n;
   vector<int> a(n + 2, 0);
   for(i = 1; i <= n; i++) cin >> a[i];
   int d = 0;
   rep(i, n + 2){
      if(i == 0) continue;
      d += abs(a[i] - a[i - 1]);
   }
   for(i = 1; i < n + 1; i++)
    cout << d - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]) << endl;


   return 0;  
}

       


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char S[4]; rep(i, 4) cin >> S[i];
  int N[4]; rep(i, 4) N[i] = S[i] - '0';
  bool yymm = false, mmyy = false;
  if((N[0] == 0 && N[1] != 0) || (N[0] == 1 && (N[1] == 0 || N[1] == 1 || N[1] == 2))) mmyy = true;
  if((N[2] == 0 && N[3] != 0) || (N[2] == 1 && (N[3] == 0 || N[3] == 1 || N[3] == 2))) yymm = true;

  if(mmyy && yymm) {
      cout << "AMBIGUOUS\n";
  }
  if(mmyy && (!(yymm))) cout << "MMYY\n";
  if(yymm && (!mmyy)) cout << "YYMM\n";
  if((!yymm) && (!mmyy)) cout << "NA\n";
  return 0;
}

Measured memory_bytes: 384
import math
import time

X = int(input())
K = 0
a = X
E = 0.1 ** 5

now = [0.0, 0.0]
while True:
    if now[0] <= E and now[0] >= -E and now[1] >= -E and now[1] <= E and K:
        print(K)
        break

    now[0] += math.cos(math.radians(a))
    now[1] += math.sin(math.radians(a)) 

    a += X
    K += 1
        


Measured memory_bytes: 9572
N = int(input())
C = [[0 for i in range(9)] for j in range(9)]


def top(n):
    while 10 <= n:
        n = n // 10
    return n


for n in range(N):
    c = n + 1
    i = c % 10
    j = top(c)
    if i and j:
        C[i - 1][j - 1] += 1

ans = 0
for i in range(9):
    for j in range(9):
        ans += C[i][j] * C[j][i]

print(ans)

Measured memory_bytes: 40684
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2510

#include<iostream>

#define N 1001//データの最大個数
#define ami 0
#define mami 1

int n = 0;
int wTime[N] = {};

int sum(int a[]){
	int ans = 0;
	for (int i = 0; a[i] != 0; i++)
		ans += a[i];
	return ans;
}

int timeCalc(int differ){
	bool dp[1001] = {true,};

	//wTime[0 ? n-2]はsort済み
	int time = 0;

	for (int i = 0; i <= n - 2; i++){//各wTimeごとに
		for (int j = differ; j >= wTime[i]; j--){//wTime[i] < j < differ
			if (dp[j - wTime[i]]){
				dp[j] = true;//DP的な。
				if (time < j)time = j;//大きい方を選択
			}
		}
	}
	return time;
}

int main(){
	using namespace std;

	int rTime[N] = {};
	int allTime[2] = {0, 0};

	while (true){

		cin >> n;
		if (n == 0)break;//終了条件

		for (int i = 0; i < N; i++){//初期化
			rTime[i] = wTime[i] = 0;
		}

		for (int i = 0; i < n; i++)
			cin >> rTime[i] >> wTime[i];

		if (n == 1){
			cout << 2 * rTime[0] + wTime[0] << endl;
			continue;
		}

		//読書時間でbubble sort
		for (int i = n - 1; i >= 0; i--){
			for (int j = 0; j < i; j++){
				if (rTime[j] > rTime[j + 1]){
					int tmp[2] = { rTime[j], wTime[j] };
					
					rTime[j] = rTime[j + 1];
					wTime[j] = wTime[j + 1];

					rTime[j + 1] = tmp[0];
					wTime[j + 1] = tmp[1];
				}
			}
		}
		//計算開始

		//read
		//最も読む時間のかかる一つと、その他の全ての和を比較

		//max <= sum
		if (sum(rTime) >= 2 * rTime[n - 1]){
			cout << sum(rTime) + sum(wTime) << endl;
		}

		//max > sum
		else if (sum(rTime) < 2 * rTime[n - 1]){

			allTime[ami] = rTime[n - 1];
			allTime[mami] = sum(rTime) - rTime[n - 1];

			int differ = allTime[ami] - allTime[mami];
			
			int writingTime = timeCalc(differ);

			cout << sum(rTime) + sum(wTime) + differ - writingTime << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1168