akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt");
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        int n = int.Parse(input.ReadLine());
        int[] bb = ToIntArray(input.ReadLine(), n-1);

        int[] aa = new int[n];

        for(int i=0; i<n; i++) {
            int b1 = i==0 ? int.MaxValue : bb[i-1];
            int b2 = i==n-1 ? int.MaxValue : bb[i];

            aa[i] = Math.Min(b1, b2);
        }

        long count = aa.Sum();
        return count;
    }

    static int[] ToIntArray(string strs, int n) {
        int[] ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++) ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13268
# include <bits/stdc++.h>
# define rr register
const int N=100010,INF=0x3f3f3f3f;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
int main(void){
	int k=read();
	int ans=0;
	for(rr int i=1;i<=k;++i){
		for(rr int j=1;j<=k;++j){
			for(rr int l=1;l<=k;++l){
				ans+=std::__gcd(std::__gcd(i,j),l);
			}
		}
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, A, B, C);
  int m = max({A, B, C}) * 3 - (A + B + C);
  print(m / 2 + (m % 2) * 2);
}


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

s = [a[i] for i in range(0,n,2)]
t = [a[i] for i in range(1,n,2)[::-1]]
if n % 2 == 0:
    print(*t, end=' ')
    print(*s)
else:
    # print(s,t)
    print(*s[::-1], end=' ')
    print(*t[::-1])


Measured memory_bytes: 26020
#include <cstdio>
#include <algorithm>
using namespace std;
int n, m, x, a[20009]; long long dp[20009];
int main() {
	scanf("%d%d%d", &n, &m, &x);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) {
		int l = 1999999999, r = -1; dp[i] = 1LL << 60;
		for (int j = 1; j <= m && i - j >= 0; j++) {
			l = min(l, a[i - j]);
			r = max(r, a[i - j]);
			dp[i] = min(dp[i], dp[i - j] + x + 1LL * j * (r - l));
		}
	}
	printf("%lld\n", dp[n]);
	return 0;
}

Measured memory_bytes: 2980
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vector<P>vec(n);
  rep(i,n){
    ll a,b;cin>>a>>b;
    vec[i].first=b;vec[i].second=a;
  }
  sort(vec.begin(),vec.end());
  ll sum=0;
  bool ans=true;
  rep(i,n){
    sum+=vec[i].second;
    if(sum>vec[i].first)ans=false;
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

l = [1,]
a = 1
ans = 0
while a <= 100000:
    a *= 2
    l.append(a)

# print(l)
for i in range(1,n+1):
    tmp = k/i
    if tmp <= 1:
        ans += (n-i+1)/n
        break
    for j in l:
        if j >= tmp:
#            print(j,1/j)
            ans += 1/j/n
            break

# ans /= n
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

void ans(lol n){
  if(n == 0){
    return;
  }
  ans((n - 1) / 26);
  cout << (char)((n - 1) % 26 + 'a');
  return;
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  lol n;
  cin >> n;
  ans(n);
  cout << '\n';
  return 0;
}


Measured memory_bytes: 3556
from collections import Counter
n,p = [int(i) for i in input().split()]
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
        
    
    return a


c = Counter(prime_factorize(p))

ans = 1
for k,v in c.items():
    if v >= n:
        ans *= k ** (v//n)
        
print(ans)


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

using namespace std;

int main()
{
	long long int  A, B, C;
	cin >> A >> B >> C;
	bool check = false;
	for (int i = 1; i < 101; i++){
		if ((A*i) % B == C) {
			check = true;
		}
	}

	if (check) cout << "YES" << endl;
	else cout << "NO" << endl;


	return 0;
}

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

public class Main {
    void run() {
        int N = readInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = readInt();
        }
        int[] B = new int[N];
        for (int i = 0; i < N; i++) {
            B[i] = readInt();
        }
        {
            double sum = 0.0;
            for (int i = 0; i < N; i++) {
                sum += Math.abs(A[i] - B[i]);
            }
            sysout.println(sum);
        }
        {
            double sum = 0.0;
            for (int i = 0; i < N; i++) {
                sum += Math.pow(Math.abs(A[i] - B[i]), 2);
            }
            sysout.println(Math.sqrt(sum));
        }
        {
            double sum = 0.0;
            for (int i = 0; i < N; i++) {
                sum += Math.pow(Math.abs(A[i] - B[i]), 3);
            }
            sysout.println(Math.cbrt(sum));
        }
        {
            double max = 0.0;
            for (int i = 0; i < N; i++) {
                max = Math.max(max, Math.abs(A[i] - B[i]));
            }
            sysout.println(max);
        }
    }

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

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = null;

    String readLine() {
        buffer = null;
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    String read() {
        if (buffer == null || !buffer.hasMoreTokens()) {
            buffer = new StringTokenizer(readLine());
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }
}

Measured memory_bytes: 17144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//
int main(){
    char b; cin>>b;
    switch(b){
        
        case 'A': cout<<'T'<<endl; return 0;
        case 'T': cout<<'A'<<endl; return 0;
        case 'G': cout<<'C'<<endl; return 0;
        case 'C': cout<<'G'<<endl; return 0;

    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,x,r =1<<29;
  for(scanf("%d",&n);n--;){
    int r0 = 0;
    scanf("%d",&x);
    for(;x%2<1;x/=2)r0++;
      if(r > r0)r = r0;
  }
  printf("%d\n",r);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int k,n;
    cin>>k>>n;
    int a,a2,a1;
    cin>>a;
    a2=a;
    int ma=0;
    for(int i=1;i<n;i++)
    {
        cin>>a1;
        ma=max(ma,a1-a);
        a=a1;
    }
    ma=max(ma,a2+k-a1);
    //cout<<ma<<"\n";
    cout<<k-ma<<"\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++)
using ll = long long;

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

  int x[5];
  int ans = 0;
  rep(i,5) {
    cin >> x[i];
    if(x[i] == 0) ans = i + 1;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
using namespace std;
string a;
int n;
int main()
{
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]!=a[i-1]) n++;
	}
	cout<<n-1<<endl;
	return 0;
}

Measured memory_bytes: 512
n, m  = map(int, input().split())
cnt = [0]*m
for i in range(n):
    _ , *a_lis = list(map(int, input().split()))
    for a in a_lis:
        cnt[a-1] += 1
ans = 0
for j in cnt:
    if j == n:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
  int main()
  {
      int a,b,c;
      cin >> a >>b >> c;
      if(a==b)
        cout << c<< endl;
      else if (b==c)
        cout << a << endl;
      else
        cout << b<< endl;
      return 0;

  }

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

using namespace std;

int main(){
  int n, i, a[100], ali = 0, bob = 0;
  cin >> n;
  
  for(i=0; i<n; i++){
      cin >> a[i];
  }

  sort(a, a + n, greater<int>());
  
  for(i=0; i<n; i++){
      
      if(i % 2 == 0){
          ali += a[i];
          
      }else
      {
          bob += a[i];
          
      }
  }

    cout << (ali - bob) << endl;
  //cout << abs(ali - bob);
  //cout << bob;
  //cout << (ali - bob);
  return 0;
}

void swap(int a, int b){
    int temp;
    temp = a;
    b = a;
    a = temp;
}

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

int main(){
    long long X;
     long long a=0;
    long long b=100;
    cin>>X;
   while(true){
       b*=1.01;
       a++;
       if(b>=X){
           break;
       }
   }
cout<<a<<endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dp[201010][2];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll>a(n), b(m);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, m) {
		cin >> b[i];
	}
	rep(i, n - 1) {
		a[i + 1] += a[i];
	}
	rep(i, m - 1) {
		b[i + 1] += b[i];
	}
	ll ans = 0;
	ll left1 = -1;
	ll right1 = m;
	while (right1 - left1 > 1) {
		ll mid1 = (left1 + right1) / 2;
		if (b[mid1] <= k)left1 = mid1;
		else {
			right1 = mid1;
		}
	}
	ans = max(right1, ans);
	rep(i, n) {
		if (a[i] > k)break;
		ll res = i + 1;
		ll res2 = k - a[i];
		ll left = -1;
		ll right = m;
		while (right - left > 1) {
			ll mid = (left + right) / 2;
			if (b[mid] <= res2)left = mid;
			else {
				right = mid;
			}
		}
		ans = max(right+res, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
int main() {
 int a,b;

 
 cin>>a>>b;
 if(a==b)
	cout<<"Draw";
	else if(a==1)
	cout<<"Alice";
	else if(b==1)
	cout<<"Bob";
else  if((a>b))
	cout<<"Alice";
else if((a<b))
	cout<<"Bob";;;


 

	return 0;
}

Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;//1e9+7

int main() {
    int N;
    cin >> N;
    vector<int>A(N + 1), B(N + 1), C(N + 1);
    A[0] = -1;
    for (int i = 1; i <= N; i++)cin >> A[i];
    for (int i = 1; i <= N; i++)cin >> B[i];
    for (int i = 1; i <  N; i++)cin >> C[i];

    int ans = 0;
    for (int i = 1; i <=N ; i++) {
        ans += B[A[i]];
        if (A[i] - 1 == A[i - 1])ans += C[A[i - 1]];
    }
    cout << ans;
    
}

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

using i64 = long long int;

i64 digit_sum(i64 n){
    i64 res = 0;
    while(n > 0){
        res += n % 10;
        n /= 10;
    }
    return res;
}

i64 power(i64 a, i64 b){
    i64 res = 1;
    for(i64 i=0;i<b;++i)res *= a;
    return res;
}

int main(){
    i64 k;
    cin >> k;

    vector<i64> v;
    for(i64 i=1;i<1000000;++i){
        i64 tmp = i;
        for(i64 j=0;j<=10;++j){
            v.push_back(tmp);
            tmp *= 10;
            tmp += 9;
        }
    }

    sort(v.rbegin(), v.rend());
    auto result = unique(v.begin(), v.end());
    v.erase(result, v.end());

    vector<i64> space;
    long double mini = 1e15;
    for(auto e : v){
        long double tmp = (long double)e / (long double)digit_sum(e);
        if(tmp <= mini){
            space.push_back(e);
            mini = tmp;
        }
    }

    sort(space.begin(), space.end());

    for(i64 i=0;i<k;++i){
        cout << space[i] << endl;
    }

    return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m, k;
	cin >>n >>m >>k;
	VI a(n), b(m);
	rep(i, n) cin >>a[i];
	rep(i, m) cin >>b[i];
	
	VL smb(m+1);
	rep(i, m) smb[i+1]=smb[i]+b[i];
	
	ll ans = 0, sm = 0;
	int j = m;
	rep(i, n+1){
		if(sm > k) break;
		for( ; j>=0 && smb[j] + sm > k; j--);
		if(smb[j] + sm <= k) ans = max<ll>(ans, i + j);
		if(i<n)sm += a[i];
	}
	
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 6344
#include <stdio.h>

int main(int argc, const char * argv[]) {

    int N=0;
    int i=0;
    int cou=0;
    
    scanf("%d",&N);
    
    int a[N];
    
    for (i=1;i<=N;i++){
        scanf("%d",&a[i]);
    }
    
    for (i=1;i<=N;i++){
        if (a[i] % 2 == 1 && i % 2 == 1){
            cou++;
        }
    }
    printf("%d",cou);
    return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include<math.h>
#include <string.h>
using namespace std;
typedef long long int ll;

int main(void){
    ll n,W;
    cin>>n>>W;
    ll w[n+1],v[n+1],dp[n+1][W+1];//n番目までを使うaグラム以下の最大の価値
    for(int i=0;i<n;i++){
        cin>>w[i+1]>>v[i+1];
    }

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

    for(int i=1;i<n+1;i++){
        for(int j=0;j<W+1;j++){
            if(j>=w[i]&&dp[i-1][j-w[i]]+v[i]>dp[i-1][j]){
                dp[i][j]=dp[i-1][j-w[i]]+v[i];
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }

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

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n;
vd a;
ld ans;

int main(){
  cin >> n;
  a = vd(n);
  for(ll i = 0;i < n;i++){
    cin >> a[i];
  }
  for(ll i = 0;i < n;i++){
    ans += 1/a[i];
  }
  cout << setprecision(17);
  cout << 1/ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ABC
{
    //          int[] split = Console.ReadLine().Split().Select(int.Parse).ToArray();

    public static void Main()
    {
        string S = Console.ReadLine();
        int[] x = new int[27];
        string outputcheck = "";
        for (int i = 0; i < 4; i++)
        {
            x[S[i] - 'A']++;
        }
        for (int i = 0; i < x.Length; i++)
        {
            if (x[i] != 0) outputcheck += x[i];
        }

        if (outputcheck == "22")
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }


    }




}

public class Pairc
{
    public int a;
    public int b;
    public Pairc() { }
    public Pairc(int a, int b)
    {
        this.a = a;
        this.b = b;
    }

}


Measured memory_bytes: 11092
from itertools import permutations
import math

N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

A = []
for i in range(1,N+1):
    A.append(i)
#print(A)

B = []
for i in permutations(A,N):
    B.append(list(i))
#print(B)

a = b = 0
for i in range(len(B)):
    if P == Q:
        break
    elif B[i] == P:
        a = i
    elif B[i] == Q:
        b = i
print(abs(a-b))

Measured memory_bytes: 10356
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int maxn = 4020;
const int mod = 998244353;
char s[maxn];
int f[maxn][maxn];
int red[maxn];
int blue[maxn];
int len;
int solve(int r, int b){
	if(r + b == 2*len) return 1;
	if(f[r][b] != -1) return f[r][b];
	int i = min(r + b, len - 1);
	int bb = blue[i], rr = red[i];
	bb -= b; rr -= r;
	int ans = 0;
	if(bb) ans += solve(r, b + 1);
	if(rr) ans += solve(r + 1, b);
	if(ans >= mod) ans -= mod;
	return f[r][b] = ans;
}
int main(){
	scanf("%s", s);
	len = strlen(s);
	for(int i = 0; i < len; i++) {
		if(s[i] == '0') red[i] = 2;
		if(s[i] == '1') red[i] = 1, blue[i] = 1;
		if(s[i] == '2') blue[i] = 2;
	}
	for(int i = 1; i < len; i++){
		red[i] += red[i - 1];
		blue[i] += blue[i - 1];
	}
	memset(f, -1, sizeof(f));
	printf("%d\n", solve(0, 0));
	return 0;
}


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

int main(){
    ll N,W;
    cin >> N >> W;
    vector<vector<ll>> v(N+1,vector<ll> (2,0));
    vector<vector<ll>> res(N+1,vector<ll> (W+1,0));

    for (int i=1;i<=N;++i){
        cin >> v[i][0] >> v[i][1];
    }
    
    for (int i=1;i<=N;++i){
        for (int j=1;j<=W;++j){
            if (j-v[i][0]>=0) res[i][j] = max(res[i-1][j] , res[i-1][j-v[i][0]] + v[i][1]);
            else res[i][j] = res[i-1][j];
            //cout << res[i][j] << " ";
        }
        //cout << endl;
    }
    cout << res.at(N).at(W) << endl; 
    
}
    //sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,s;
ll dp[3001][3001];
ll pre[3001],mod=998244353,total=0;

ll solve(ll arr[],int i,int j)
{
  if(i>j) return 0;
  if(dp[i][j]!=-1) return dp[i][j];
  dp[i][j]=0;
  if(pre[j]-pre[i]+arr[i] ==s) dp[i][j]=1;
  dp[i][j]=(dp[i][j]+((solve(arr,i,j-1)+solve(arr,i+1,j))%mod))%mod;
  cout<<" dp "<<i<<' '<<j<<" = "<<dp[i][j]<<endl;
  return dp[i][j];
}

int main()
{
    cin>>n;
    bool found=false;
    while(n)
    {
      if((n%10)==7) found=true;
      n/=10;
    }
    if(found) cout<<"Yes";
    else cout<<"No";
    return 0;
  }

Measured memory_bytes: 3632
#!/usr/bin/env python3
# CGL_1_A: Points/Vectors - Projection


def proj(p1, p2, p):
    x1, y1 = p1
    x2, y2 = p2
    x, y = p

    if x1 == x2:
        return x1 * 1.0, y * 1.0
    elif y1 == y2:
        return x * 1.0, y1 * 1.0
    else:
        dx = x1 - x2
        dy = y1 - y2
        return (((dx*x + dy*y)*dx - (x1*y2 - x2*y1)*dy) / (dx*dx + dy*dy),
                ((dx*x + dy*y)*dy + (x1*y2 - x2*y1)*dx) / (dx*dx + dy*dy))


def run():
    px1, py1, px2, py2 = [int(v) for v in input().split()]
    q = int(input())

    for _ in range(q):
        x, y = [int(v) for v in input().split()]
        print("{:.10f} {:.10f}".format(*proj((px1, py1), (px2, py2), (x, y))))


if __name__ == '__main__':
    run()



Measured memory_bytes: 5644
import java.util.*;

public class Main {
    final static int MOD = 1000000007;
    
    public static void main(String[] args) {
        MyScanner in = new MyScanner();
        int a = in.nextInt();
        System.out.println((a + 2 -1) / 2);
        
    }
    
    static class MyScanner {
        static Scanner sc = new Scanner(System.in);
        
        String next() {
            return sc.next();
        }
        
        String nextLine() {
            return sc.nextLine();
        }
        
        int nextInt() {
            return Integer.parseInt(sc.next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextInt();
            }
            return array;
        }
        
        double[] nextDoubleArray(int n) {
            double[] array = new double[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextDouble();
            }
            return array;
        }
        
        long[] nextLongArray(int n) {
            long[] array = new long[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLong();
            }
            return array;
        }
        
        String[] nextLineArray(int n) {
            String[] array = new String[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLine();
            }
            return array;
        }
        
        int[][] nextIntMatrix(int n, int m) {
            int[][] matrix = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextInt();
                }
            }
            return matrix;
        }
        
        double[][] nextDoubleMatrix(int n, int m) {
            double[][] matrix = new double[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextDouble();
                }
            }
            return matrix;
        }
        
        long[][] nextLongMatrix(int n, int m) {
            long[][] matrix = new long[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextLong();
                }
            }
            return matrix;
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <string>

using namespace std;

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

		if (N == 0) {
				cout << "0" << endl;
				return 0;
		}

		string str = "";
		while(N != 0) {
				if (N % 2) {
						str = "1" + str;
						N = (N-1) / (-2);
				} else {
						str = "0" + str;
						N = N / (-2);
				}
		}

		cout << str << endl;
		return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  int ans=n;  
  for(int i=0;i<10;i++){
    int tmp=n-i*10,res=i;   
    if(tmp<0) continue;
    res+=tmp/25;tmp%=25;
    res+=tmp/5;tmp%=5;
    res+=tmp/1;tmp%=1;
    chmin(ans,res);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define double long double
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
 
const i64 MOD = 1000000007;
const i64 INF = 2e15;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
                 
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(n * a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {


	
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		
		int n = Integer.parseInt(br.readLine());
		
		int arr[] = new int [n];
		
		StringTokenizer st1 = new StringTokenizer(br.readLine());
		
		for(int i = 0 ; i < n ; i++)
		{
			arr[i] = Integer.parseInt(st1.nextToken());
		}
		
		int cnt[] = new int[n];
		
		int max = 0;
		
		for(int i = n-2; i >= 0 ; i--)
		{
			if(arr[i] >= arr[i+1])
			{
				cnt[i] = cnt[i+1]+1;
			}
		}
		
		for(int i = 0 ; i < n ; i++)
			max = Math.max(max, cnt[i]);
		
		out.println(max);
		
		
		out.flush();
		out.close();
	}
	
	
	


}


Measured memory_bytes: 40088
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  rep(i, N) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  vec.at(N - 1) /= 2;
  int ans = 0;
  rep(j, N) {
    ans += vec.at(j);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn abs(x:i64)-> i64{
    let z:i64;
    if x < 0{
	z = -1*x;
    }else {
	z =x;
    }
    z
}

//main function
fn main() {
    let number: i64 = 753;
    let mut x: i64 = read();
    let mut min: i64 = x;
    while x > 100 {
	if min > abs(x%1000-number) {
	    min = abs(x%1000-number);
	}
	x /= 10;
    }
    println!("{}",min);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            :oyhhhhhhyo:    
#define next         .sdNNNmNNNNNNNmds. 
#define y0          -hNNNNy`yNNNNNN`/Nh-
#define y1          mNNNNNd+dNNNNNN+sNNm
#define yn          mNNNNNNNNy--:smNNNms
#define tm          .+oooooosyysooooo+- 
#define read               :yhy/        
#define rank              :mNmo         
#define index              ... 
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 55;
double v[N];
int n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 1, n) {
        cin >> v[i];
    }
    sort(v + 1, v + n + 1);
    double ans = 0;
    rep(i, 1, n) {
        int p = min(n - 1, n - i + 1);
        double mult = 1;
        rep(j, 1, p) {
            mult /= 2;
        }
        ans += mult * v[i];
    }
    cout << fixed << setprecision(13) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define Max 2005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
LL C[Max][Max];
void Compare_C () {// play table
    C[0][0]=1;
    for(int i=1;i<Max;i++){
        C[i][0]=C[i][i]=1;
        for(int j=1;j<=i;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
}
int main()
{
    Compare_C();
    int b,r,c;
    scanf("%d%d",&c,&b);
    r=c-b+1;
    for(int i=1;i<=b;i++){
        printf("%lld\n",(C[b-1][i-1]*C[r][i])%mod);
    }
    return 0;
}



Measured memory_bytes: 26480
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N, K = map(int, readline().split())
    G = [[] for i in range(N)]
    for i in range(N-1):
        u, v = map(int, readline().split())
        G[u-1].append(v-1)
        G[v-1].append(u-1)
    P = [-1]*N
    vs = []
    que = deque([0])
    used = [0]*N
    used[0] = 1
    while que:
        v = que.popleft()
        vs.append(v)
        for w in G[v]:
            if used[w]:
                continue
            used[w] = 1
            que.append(w)
            P[w] = v
    sz = [0]*N; dp = [0]*N
    vs.reverse()
    ans = 0
    for v in vs:
        s = 1; d = 0
        p = P[v]
        ds = []
        for w in G[v]:
            if w == p:
                continue
            s += sz[w]
            if sz[w] >= K:
                d += 1
                ds.append(dp[w]-1)
            else:
                ds.append(dp[w])
        ds.sort(reverse=1)
        dp[v] = max(d, d + ds[0] if ds else 0)
        if ds:
            e = d + 1 if N-s >= K else d
            ans = max(ans, e + ds[0])
            if len(ds) > 1:
                ans = max(ans,  e + ds[0] + ds[1])
        sz[v] = s
    write("%d\n" % ans)
solve()


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

int main()
{
  int N, M;
  cin >> N >> M;

  int sum = 0;

  vector<int> A(M);
  for(int i = 0; i < M; i++){
    cin >> A.at(i);
    sum += A.at(i);
  }
  if(N - sum  < 0){
    cout << "-1" << endl; 
  }
  else{
    cout << N - sum << endl;
  }

  return 0;

}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

int main(){
  int n;cin >> n;
  string al[26],sum;string s;string tmp = "";
  for(int i = 0;i<50;i++) tmp += "a";
  for(int i = 0;i<26;i++) al[i] = tmp;
  //すべての文字列についてアルファベットを数えて上書き　最後に辞書順出力
  rep{
      cin >> s;
      for(int j = 0;j<26;j++){
          tmp ="";
          for(int k = 0;k<s.size();k++){
              if(s.at(k) - 'a' == j ) tmp += s.at(k);
          }
          if(tmp.size() < al[j].size()) al[j] = tmp;
      }
  }
  for(int i = 0;i<26;i++){
      cout << al[i];
  }
  cout << endl;
} 

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

const int MAXN = 10;
const int MAXM = 20;

struct Edge {
  int to, cost, id;
};

int N, M;
vector<Edge> E[MAXN];
vector<int> now;
vector<int> ans;

void addEdge(int a, int b, int cost, int id) {
  E[a].push_back((Edge){b, cost, id});
  E[b].push_back((Edge){a, cost, id});
}

void rec(int v, int bit, int sum) {
  now.push_back(v);
  bool move = false;
  for(int i = 0; i < E[v].size(); ++i) {
    Edge &e = E[v][i];
    if(bit & (1<<e.id)) continue;
    move = true;
    int nbit = (bit | (1<<e.id));
    rec(e.to, bit|(1<<e.id), sum + e.cost);
  }
  if(!move) {
    now[0] = -sum;
    ans = min(ans, now);
  }
  now.pop_back();
}

int main() {
  while(cin >> N >> M && (N|M)) {
    for(int i = 0; i < MAXN; ++i) E[i].clear();
    for(int i = 0; i < M; ++i) {
      int a, b, d;
      cin >> a >> b >> d;
      --a; --b;
      addEdge(a,b,d,i);
    }

    ans.resize(1);
    ans[0] = 0;
    for(int i = 0; i < N; ++i) {
      now.resize(1);
      now[0] = 0;
      rec(i, 0, 0);
    }

    cout << -ans[0] << endl;
    for(int i = 1; i < ans.size(); ++i) {
      if(i-1) cout << " ";
      cout << ans[i]+1;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define N 400005
using namespace std;
int n,fa[N],rd[N],fl[N],a[N];
vector<int>s[N];
void OK()
{
	puts("POSSIBLE");
	exit(0);
}
void dfs(int x)
{
	//cout<<x<<endl;
	rd[x]=-1;
	for (int i=0;i<s[x].size();i++)
		fl[a[s[x][i]]]=x;
	for (;fl[a[x]]==x;a[x]++);
	rd[fa[x]]--;
	s[fa[x]].push_back(x);
	if (!rd[fa[x]]) dfs(fa[x]);
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&fa[i]);
		rd[fa[i]]++;
	}
	for (int i=1;i<=n;i++)
		if (rd[i]==0) dfs(i);
	//puts("ok");
	for (int i=1;i<=n;i++)
		if (rd[i]>0)
		{
			for (int j=0;j<s[i].size();j++)
				fl[a[s[i][j]]]=i;
			for (;fl[a[i]]==i;a[i]++);
			//cout<<a[i]<<endl;
			int t=fa[i],lst=i;
			while(t!=i)
			{
				for (int j=0;j<s[t].size();j++)
					fl[a[s[t][j]]]=t;
				fl[a[lst]]=t;
				for (;fl[a[t]]==t;a[t]++);
				lst=t;t=fa[t];
			}
			if (a[lst]!=a[i])OK();
			a[i]=a[i]+1;
			t=fa[i],lst=i;
			while(t!=i)
			{
				for (int j=0;j<s[t].size();j++)
					fl[a[s[t][j]]]=t+n;
				fl[a[lst]]=t+n;
				for (a[t]=0;fl[a[t]]==t+n;a[t]++);
				lst=t;t=fa[t];
			}
			if (a[lst]==a[i]-1)OK();
			puts("IMPOSSIBLE");return 0;
		}
}

Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (ll i = (a); i < (n); i += (s))
#define rep(...) _overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void chmax(T& a, const T& b) {if (a < b) a = b;}
template<typename T> inline void chmin(T& a, const T& b) {if (a > b) a = b;}
template<typename T> inline void print(const T& x) {cout << x << "\n";}
struct Init {Init() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} init;

int main() {
    ll n;
    cin >> n;
    ll s = 0;
    // m[i] = (数列Aに含まれるiの個数)
    vi m(100010, 0);
    // s = 数列の和
    rep(n) {
        ll a;
        cin >> a;
        s += a;
        m[a]++;
    }
    ll q;
    cin >> q;
    rep(q) {
        ll b, c;
        cin >> b >> c;
        s += m[b] * (c - b);
        print(s);
        m[c] += m[b];
        m[b] = 0;
    }
}

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

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

int n,ans=0;
int a[114514];

void bubbleSort(int n){
  bool flag=1;
  while(flag){
    flag=0;
    for(int j=n-1;j>=1;j--){
      if(a[j]<a[j-1]){
	swap(a[j], a[j-1]);
	flag=1;
	ans++;
      }
    }
  }
}

int main(){
  int n;
  cin>>n; 
  for(int i=0;i<n;i++)cin>>a[i];
  bubbleSort(n);
  for(int i=0;i<n;i++){
      if(i!=n-1)cout<<a[i]<<" ";
      else cout<<a[i]<<endl;
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define bitCount(num)  __builtin_popcount(num)
#define pb push_back
#define ll long long
#define bye return 0;
#define f(i,a,b) for( long long i=a;i<b;i++)
#define testCases long long t;cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define newLine <<"\n"
#define all(x) (x).begin(), (x).end()
#define vll vector<long long>

int main()
{
    fast
    ll n,k,t;
    cin>>n>>k>>t;
    ll ans= n/k;
    // if(n<=k) cout<<t<<endl;
    if(n%k!=0) ans++;
    cout<<ans*t<<endl;

    bye
}

Measured memory_bytes: 3636
#include <stdio.h>
int main(){
  int arr[26]={0}, i;
  int c;

  while ((c=getc(stdin))!=EOF){
    if (c>='A' && c<='Z') arr[c-65]++;
    else if (c>='a' && c<='z') arr[c-97]++;
  }
  for (i=0; i<26; i++) printf("%c : %d\n",i+97 , arr[i]);
}


Measured memory_bytes: 2656
N = int(input())
S = input()

def Z_algo(string):
    n = len(string)
    A = [0] * n
    A[0] = n
    i = 1
    j = 0
    while i < n:
        while i+j < n and string[j] == string[i+j]:
            j += 1
        A[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < n and k+A[k] < j:
            A[i+k] = A[k]
            k += 1
        i += k
        j -= k
    return A

ans = 0

for i in range(N):
    A = Z_algo(S[i:])
    res = 0
    for j, a in enumerate(A):
        res = max(res, min(a, j))
    ans = max(ans, res)
    
print(ans)

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

char s[302][302];
int ans[302][302];

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++){
        cin >> s[i][j];
    }
    k = 1;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                int l = j;
                while(l >= 0 && ans[i][l] == 0){
                    ans[i][l] = k;
                    l--;
                }
                k++;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(ans[i][j] == 0 && ans[i][j - 1] != 0){
                int c = ans[i][j - 1];
                while(j < w){
                    ans[i][j] = c;
                    j++;
                }
            }
        }
    }
    for(int i = 0; i < w; i++){
        for(int j = 0; j < w; j++){
            if(ans[i][j]){
                int l = i + 1;
                while(ans[l][j] == 0 && l < h){
                    ans[l][j] = ans[i][j];
                    l++;
                }
            }
        }
    }
    for(int i = h - 1; i >= 0; i--){
        for(int j = 0; j < w; j++){
            if(ans[i][j]){
                int l = i - 1;
                while(ans[l][j] == 0 && l >= 0){
                    ans[l][j] = ans[i][j];
                    l--;
                }
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++) cout << ans[i][j] << " ";
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
typedef long long ll;
using namespace std;

int main(void){

  int a,b;
  cin>>a>>b;
  if(a>b){
    cout<<a+a-1;
  }
  else if(b>a){
    cout<<b+b-1;
  }
  else{
    cout<<a+b;
  }
  cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	vector<int> data(N);
	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
		sum += data[i];
	}

	if (sum % 10 != 0)
	{
		cout << sum << endl;
		return;
	}
	sort(all(data));
	for (int i = 0; i < N; i++)
	{
		if (data[i] % 10 != 0)
		{
			cout << sum - data[i] << endl;
			return;
		}
	}
	cout << 0 << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

string s;
int res;

int main() {
	cin >> s;
	res = 0;
	for(int i = 1; i < s.length(); i++) {
		if (s[i] != s[i - 1]) res++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
	

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int HP1 = sc.nextInt();
		int ATK1 = sc.nextInt();
		int HP2 = sc.nextInt();
		int ATK2 = sc.nextInt();
		
        while(true){
          	HP2 -= ATK1;
			if(HP2<1){
				System.out.println("Yes");
        		return;
			}
          
			HP1 -= ATK2;
			if(HP1<1){
				System.out.println("No");
        		return;
			}
			
        }
	}


}


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

void addAll(std::vector<int> &addV, int newNum)
{
    std::vector<int> tempV;
    for (int v : addV) tempV.push_back(newNum + v);

    addV.push_back(newNum);
    std::copy(tempV.begin(), tempV.end(), std::back_inserter(addV));
}

int main()
{
    int aNum;
    std::cin >> aNum;

    int *aArray = new int[aNum];
    for (int i = 0; i < aNum; i++) std::cin >> aArray[i];

    int qNum;
    std::cin >> qNum;

    int *qArray = new int[qNum];
    for (int i = 0; i < qNum; i++) std::cin >> qArray[i];

    if (aNum <= 2)
    {
        std::cout << "no" << std::endl;
        return 0;
    }

    std::vector<int> addVector;
    for (int i = 0; i < aNum; i++) addAll(addVector, aArray[i]);

    std::sort(addVector.begin(), addVector.end());
/*
    for (int a : addVector)
    {
        std::cout << a << " ";
    }
    std::cout << std::endl;
*/
    bool detected;
    for (int q = 0; q < qNum; q++)
    {
        detected = false;
        for (int a : addVector)
        {
            if (a == qArray[q]) detected = true;
            else if (a > qArray[q]) break;
        }

        if (detected) std::cout << "yes" << std::endl;
        else          std::cout << "no"  << std::endl;
    }
}


Measured memory_bytes: 9020
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((LL) (r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, system("pause")
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, system("pause")
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, system("pause")
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, system("pause")

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

int main() {
    FASTIO;
    int a, b;
    while (cin >> a >> b) cout << 6 - a - b << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
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;
}

int n, v[100010];
pair<int, int> ta[100010], mu[100010];

signed main() {
	cin >> n;
	rep(i, n) {
		cin >> v[i];
		if (i % 2 == 0) {
			ta[v[i]].first++;
			ta[v[i]].second = v[i];
		}
		else {
			mu[v[i]].first++;
			mu[v[i]].second = v[i];
		}
	}
	sort(ta, ta + 100010);
	reverse(ta, ta + 100010);
	sort(mu, mu + 100010);
	reverse(mu, mu + 100010);
	if (ta[0].second != mu[0].second)cout << n - (ta[0].first + mu[0].first) << endl;
	else if ((ta[0].first - ta[1].first) < (mu[0].first - mu[1].first))cout << n - (ta[1].first + mu[0].first) << endl;
	else cout << n - (ta[0].first + mu[1].first) << endl;
	ggr
}

Measured memory_bytes: 4096
# -*- coding: utf-8 -*-
N, A, B = map(int, input().split())

# 出力
# 奇数を取得
i = 0
num_loop = int(N / (A+B))
tmp = num_loop * A

mod = N % ((A+B))

if mod > A:
    tmp2 = A
else:
    tmp2 = mod

print(tmp + tmp2)


Measured memory_bytes: 3064