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

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
struct Area{
  vector<int> color;
};
signed main(){
  int n,c;cin>>n>>c;
  vector<Area> area(3);
  rep(i,3){
    area[i].color.resize(c+1,0);
  }
  vector<vector<int>> d(c+1,vector<int>(c+1));
  rep1(i,c){
    rep1(j,c){
      cin>>d[i][j];
    }
  }
  rep1(i,n){
    rep1(j,n){
      int buf;cin>>buf;
      area[(i+j)%3].color[buf]++;
    }
  }
  int res=inf;
  rep1(i,c){
    rep1(j,c){
      if(i==j)continue;
      rep1(k,c){
        if(i==k||j==k)continue;
        int buf=0;
        rep1(l,c){
          buf+=d[l][i]*area[0].color[l];
          buf+=d[l][j]*area[1].color[l];
          buf+=d[l][k]*area[2].color[l];
        }
        res=min(buf,res);
      }
    }
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 256
N = int(input())

A = [list(0 for i in range(9)) for _ in range(9)]

for i in range(1,N+1):
    new = [int(d) for d in str(i)]
    if  new[-1]!=0:
        A[new[0]-1][new[-1]-1]+=1

cnt=0
for i in range(9):
    for j in range(9):
        cnt+=A[i][j]*A[j][i]

print(cnt)


Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val k = sc.nextLong()
    println(problem106c(s, k))
}

fun problem106c(s: String, k: Long): Int {
    for (i in s.indices) {
        if (s[i] == '1' && i + 1 >= k) return 1
        val si = s[i]
        if (si != '1') return si.toString().toInt()
    }
    return 1
}

Measured memory_bytes: 31268
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int a,b;
  cin >> a >> b;
  int ju = 1, temp = b;
  while (temp > 0) {
    temp /= 10;
    ju *= 10;
  }
  int res = a*ju + b;
  int rr = sqrt(res);
  auto yes = [&]() {
    cout << "Yes\n";
  };
  auto no = [&]() {
    cout << "No\n";
  };
  if (rr*rr == res) yes();
  else no();
  debug(res);
  return 0;
}

Measured memory_bytes: 256
h,w = gets.split.map(&:to_i)
squares = []
h.times do
  squares << gets.chomp.split("")
end
dp = Array.new(h){[1]*w}

squares.each_with_index do |line,i|
  line.each_with_index do |a,j|
    dp[i][j] = 0 if i == 0 && j > 0 && dp[i][j-1] == 0
    dp[i][j] = 0 if j == 0 && i > 0 && dp[i-1][j] == 0
    if a == "#"
      dp[i][j] = 0
      next
    end
    next if i == 0 || j == 0
    dp[i][j] = dp[i-1][j] + dp[i][j-1]
  end
end
p dp[h-1][w-1] % (10**9+7)


Measured memory_bytes: 246808
const BTC_RATE : f64 = 380000.0;

fn main () {
    let input = get_read_line();
    let gift_presenter_count = input
                                .trim()
                                .parse::<i32>()
                                .unwrap();

    let mut money_list : Vec<f64> = Vec::new();

    for _ in 0..gift_presenter_count {
        let input = get_read_line();
        let mut result : Vec<String> = input
                                    .split(" ")
                                    .map(|value| value.trim().to_string())
                                    .collect();
        let price = &result[0];
        let currency = &result[1];

        match currency.as_str() {
            "JPY" => money_list.push(price.parse::<f64>().unwrap()),
            "BTC" => money_list.push(price.parse::<f64>().unwrap() * BTC_RATE),
            _ => panic!("error.")
        }
    }

    let total : f64 = money_list
                        .iter()
                        .fold(0.0, |sum, i| sum + i);

    println!("{:?}", total);
}

fn get_read_line() -> String {
    let mut result = String::new();
    std::io::stdin().read_line(&mut result).unwrap();
    result
}


Measured memory_bytes: 4352
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n, a, b, c, d;

	void run(){
		n=sc.nextInt();
		a=sc.nextInt()-1;
		b=sc.nextInt()-1;
		c=sc.nextInt()-1;
		d=sc.nextInt()-1;
		solve();
	}

	void solve(){
		int min=INF;
		for(int w=1; w<=n; w++){
			min=min(min, abs(a%w-b%w)+abs(a/w-b/w)+abs(c%w-d%w)+abs(c/w-d/w));
		}
		println(min+"");
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 17308
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+15+7;
ll n,m,l;
string s,t;
ll d[100],dp[100][100];

int main(){
  vi vec;
  ll ans = 0;
  cin >> n;
  rep(i,0,n){
    cin >> m;
    vec.pb(m);
    ans += m;
  }
  sort(all(vec));
  rep(i,0,vec.sz){
    if(ans % 10 != 0)break;
    else{
      if(vec[i] % 10 == 0)continue;
      ans -= vec[i];
    }
  }
  if(ans % 10 != 0)print(ans);
  else puts("0");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int x,y,z,loop,xr,yr,zr,i,data;
	
	while(1){
		
		scanf("%d %d %d",&x,&y,&z);
		
		if(x==0 && y==0 && z==0){
			break;
		}
		xr=sqrt(x*x+y*y);
		yr=sqrt(y*y+z*z);
		zr=sqrt(z*z+x*x);
		
		scanf("%d",&loop);
		
		for(i=0;i<loop;i++){
			
			scanf("%d",&data);
			
			data=data*2;
			
			if(xr<data || yr<data || zr<data){
				printf("OK\n");
			}
			else{
				printf("NA\n");
			}
			
		}
		
	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
#define P(a,b) make_pair(a,b);
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
  string S;
  cin >> S;
  string T = "CODEFESTIVAL2016";
  ll ans = 0;
  rep(i,S.size()) if(S[i] != T[i]) ans++;
  cout << ans << endl;
}


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

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

int main(void)
{
  int n, a, b;
  cin >> n >> a >> b;

  int ans = 0;
  REP (i, 1, n+1)
  {
    int sum = 0;
    int num = i;
    while (num > 0)
    {
      sum += num % 10;
      num /= 10;
    }
    if (sum >= a && sum <= b)
    {
      ans += i;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
/* HARDWORK IS THE KEY TO SUCCESS.
   RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.
   PREFER CODING RATHER THAN MEDITATION !!!*/
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define vin ll n; cin>>n; vector<ll>x(n); for(ll i=0; i<n; i++) cin>>x[i]
#define vout for(ll i=0; i<n; i++) cout<<x[i]<<" "
#define T ll t = 1; cin>>t; while(t--)
#define ain ll n,k,i; cin>>n; ll a[n]; for( i=0; i<n; i++) cin>>a[i]
#define aout for(ll i=0; i<n; i++) cout<<a[i]<<" "
#define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1] ; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
#define matout for(ll i=0;i<m;i++){for(ll j=0;j<n;j++) cout<<a[i][j]<<" "; cout<<"\n";}
#define F first
#define S second
#define I insert
#define sin set<ll>s; ll n; cin>>n; ll tmp; for(ll i=0;i<n;i++){cin>>tmp; s.I(tmp);}
#define sout for(auto it=s.begin();it!=s.end();++it) cout<<*it<<" "
#define AISORT sort(a,a+n)
#define ADSORT sort(a,a+n,greater<ll>())
#define VISORT sort(x.begin(),x.end())
#define VDSORT sort(x.begin(),x.end(),greater<ll>())
#define pb push_back
#define ppb pop_back

 
const ll maxs = 1e6+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;
//MODULO OPEARTIONS
inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
ll fastpow(ll x,ll y)
{ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}
//MODULAR INVERSE
ll inv(ll x){ return pow(x , mod - 2);}


bool vis[maxs];
vector<ll>graph[maxs];


int main()
{
   
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin >> x;
    ll q = x / 500;
    ll happ = q * 1000;
    ll r = x % 500;
    q = r / 5;
    happ += q * 5;
    cout << happ;
       
   
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    ll cnt = 0;
    rep(i, n) {
        ll d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2) {
            cnt++;
        }
        else {
            cnt = 0;
        }
        if (cnt >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  if( (r*100 + g*10 + b) % 4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
s = input()
if len(s) == 2:
    if s[0] == s[1]:
        print(1, 2)
    else:
        print(-1, -1)
else:
    for i in range(len(s) - 2):
        seg = s[i:i+3]
        if seg.count(seg[0]) >= 2 or seg.count(seg[1]) >= 2:
            print(i + 1, i + 3)
            break
    else:
        print(-1, -1)
 

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

t = [0] * (N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i: i+2] == 'AC' else 0)
ans = [t[LR[i][1] - 1] - t[LR[i][0] - 1] for i in range(Q)]    

print(*ans, sep='\n')

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

using namespace std;

long long int gcd(long long int a,long long int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long long int lcm(long long int a,long long int b)
{
   return a * b / gcd(a, b);
}
int main(){
   long long int A,B,C,D,ans;
   cin >> A >> B >> C >> D;
    ans = 0;
    ans += B;
    ans -= (B / C + B / D - B / lcm(C,D));
    long long int cnt = A - 1 - (A - 1) / C - (A - 1) / D + (A - 1) / lcm(C,D);
    ans -= cnt; 

    cout << ans;
 return 0;
}

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

using namespace std;

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

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

    bool flag = true;
    int i = 1;
    int counter = 0;
    while (flag) {
        if(i == 0){
            flag = false;
            counter = -1;
            break;
        }
        if (i == 2) {
            flag = false;

            --counter;

        }

        int temp = A[i];
        A[i] = 0;
        i = temp;

        ++counter;

    }
    cout << counter << endl;
}



Measured memory_bytes: 1272
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
	#define N 100000

	int fac[N+100],invfac[N+100];

	int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
	int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
	int mul(int x,int y) {return 1ll*x*y%maxd;}
	ll qpow(ll x,int y)
	{
		ll ans=1;
		while (y)
		{
			if (y&1) ans=mul(ans,x);
			x=mul(x,x);y>>=1;
		}
		return ans;
	}
	int inv(int x) {return qpow(x,maxd-2);}

	int C(int n,int m)
	{
		if ((n<m) || (n<0) || (m<0)) return 0;
		return mul(mul(fac[n],invfac[m]),invfac[n-m]);
	}

	int math_init()
	{
		fac[0]=invfac[0]=1;
		rep(i,1,N) fac[i]=mul(fac[i-1],i);
		invfac[N]=inv(fac[N]);
		per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
	}
	#undef N
}
using namespace My_Math;

int n;
ll ans[100100];
pii a[100100];

int main()
{
	n=read();
	rep(i,1,n) 
	{
		a[i].fir=read();a[i].sec=i;
	}
	sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	int mn=n+1;
	rep(i,1,n)
	{
		mn=min(mn,a[i].sec);
		if (a[i].fir!=a[i+1].fir) ans[mn]+=1ll*(a[i].fir-a[i+1].fir)*i;
	}
	rep(i,1,n) printf("%lld\n",ans[i]);
	return 0;
}



Measured memory_bytes: 2688
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
def insertionSort(a, n)
  puts a.join(" ")
  (1..n-1).each do |i|
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v
      a[j+1] = a[j]
      j -= 1
    end
    a[j+1] = v
    puts a.join(" ")
  end
end

insertionSort(a, n)

Measured memory_bytes: 8808
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String str = input.readLine();
		String[] hw = str.split(" ");
		int h = Integer.parseInt(hw[0]);
		int w = Integer.parseInt(hw[1]);
		int count = 0;
		for(int i=0; i<h; i++){
			str = input.readLine();
			count += str.length()-str.replace("#", "").length();
		}

		if(h+w-1==count){
			System.out.println("Possible");
		}else{
			System.out.println("Impossible");
		}


	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll GCD(ll a, ll b)
{
    return b ? GCD(b, a%b) : a;
}

ll LCM(ll a, ll b)
{
    return a = a / GCD(a, b) * b;
}

int main()
{
    int n; cin >> n;
    cout << LCM(2, n) << endl;
}

Measured memory_bytes: 3600
S = int(input())

S_m = S - 3

import math


num_set = S_m // 3
h = 3
result = 0
for h in range(int(S_m / 3) +1):
    
    
    
    if num_set < h:
        continue
    else:

        rest = S_m - (h * 3)  
        A = math.factorial(h + rest) // (math.factorial(h) * math.factorial(rest)) 
        
        result += A


print(result% (10**9+7))

Measured memory_bytes: 9188
program-id. abc169c.

data division.
  working-storage section.
  77 ab   pic x(21).
  77 a    pic 9(16).
  77 b    pic 9v99.
  77 ans  pic z(16)9.

procedure division.
  accept ab.
  unstring ab delimited by space into a b.
  compute ans = a * b.
  display ans.
  stop run.


Measured memory_bytes: 3904
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  readln.chomp.count!(x=>x=='1').writeln;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int l = s.length();
    
    for (int i = 0; i < l; i++) {
        s = s[l - 1] + s.substr(0, l - 1);
        
        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}

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


int main() {
  int A, B;
  cin >> A >> B;
  if(A > B){
    cout << -1;
  }
  else{
    int a, b, c, d;
    a = A * 12;
    b = B * 10;
    c = (A + 1) * 13;
    d = (B + 1) * 10;
    bool have = true;
    for(int i = max(a, b); i < min(c, d); i++){
      int x, y;
      x = i * 0.08;
      y = i * 0.1;
      if(x == A && y == B){
        cout << i;
        return 0;
        bool have = false;
      }
    }
    
  if(have){
    cout << -1;
  }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int dp[60];
  int line[60];
  string buf;
  int a = 1;
  char dummy;
  bool f = true;
  memset(dp, 0, sizeof(int)*60);
  while (getline(cin, buf)) {
    istringstream iss(buf);
    iss >> line[0];
    for (int i=1; i<a; i++) {
      iss >> dummy >> line[i];
    }
    if (iss.fail()) {
      f = false;
      a -= 2;
    }
    if (f) {
      for (int i=a-1; i; i--) {
        dp[i] = line[i] + max(dp[i-1], dp[i]);
      }
      dp[0] += line[0];
      ++a;
    } else {
      for (int i=0; i<a; i++) {
        dp[i] = line[i] + max(dp[i], dp[i+1]);
      }
      --a;
    }
  }
  cout << dp[0] << endl;
  return 0;
}

Measured memory_bytes: 1224
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll h,w;
  cin >> h >> w;
  vector<string> s(h),ans(h);
  for(int i=0;i<h;i++){
    cin >> s[i];
    ans[i] = s[i];
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      ll c = 0;
      for(int dx=-1;dx<=1;dx++){
        for(int dy=-1;dy<=1;dy++){
          ll x = i + dx;
          ll y = j + dy;
          if(x>=0&&y>=0&&x<h&&y<w){
            if(s[x][y]=='#') c++;
          }
        }
      }
      if(s[i][j]!='#'){
        ans[i][j] = '0' + c;
      }
    }
  }
  for(int i=0;i<h;i++){
    cout << ans[i] << endl;
  }
}


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


void solve(long long N){
    vector<int> digs;
    do{
        if(N%2==0){
            digs.push_back(0);
            N = N/(-2);
        }else{
            digs.push_back(1);
            N = (N-1)/(-2);
        }
    }while(abs(N)>0);
    for(auto it=digs.rbegin(); it<digs.rend(); it++)
        cout << *it;
    cout << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
s = input()

chain = 0
max_chain = 0
for i in range(len(s)):
    if (s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T'):
        chain += 1
    else:
        if(chain > max_chain):
            max_chain = chain
            chain = 0
    if (i == len(s)-1):
        if(chain > max_chain):
            max_chain = chain
            chain = 0
            
print(max_chain)

Measured memory_bytes: 38256
from itertools import combinations

N, M, X = map(int, input().split())
books = [list(map(int, input().split())) for _ in range(N)]

res = float('inf')
for r in range(N + 1):
    for c in combinations(range(N), r):
        skills = [0] * M
        price = 0
        for i in c:
            price += books[i][0]
            for j, a in enumerate(books[i][1:]):
                skills[j] += a
        if all(skill >= X for skill in skills):
            res = min(res, price)

if res == float('inf'):
    print(-1)
else:
    print(res)

Measured memory_bytes: 9132
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N;
    string s;
    cin >> N >> s;

    int ans = 0;
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            for (int k = 0; k <= 9; k++) {
                bool judge0 = 0, judge1 = 0, judge2 = 0;
                rep(l, N) {
                    if (!judge0 && s[l] - '0' == i)
                        judge0 = 1;
                    else if (!judge1 && judge0 && s[l] - '0' == j)
                        judge1 = 1;
                    else if (judge1 && s[l] - '0' == k)
                        judge2 = 1;
                }

                if (judge2) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3656
<?php
list($n, $u, $v) = ints();
--$u;
--$v;
for ($i = 0; $i < $n - 1; ++$i) {
    list($a, $b) = ints();
    --$a;
    --$b;
    $g[$a][] = $b;
    $g[$b][] = $a;
}
$du = bfs($u);
$dv = bfs($v);
$max = 0;
for ($i = 0; $i < $n; ++$i) {
    if ($dv[$i] > $du[$i] &&  $dv[$i] > $max) {
        $max = $dv[$i];
        $mi = $i;
    }
}
echo $dv[$mi] - 1;
function bfs($s)
{
    global $n, $g;
    $q = new SplQueue(); // キューを用意
    $dist = array_fill(0, $n, -1); // 距離を格納する配列（-1の場合はその頂点が未発見）

    $dist[$s] = 0; // 始点からの距離格納配列
    $q->enqueue($s); // キューに始点を追加

    while (!$q->isEmpty()) {
        $v = $q->dequeue();

        foreach ($g[$v] as $next_v) {
            if ($dist[$next_v] !== -1) continue; // 発見済み

            $dist[$next_v] = $dist[$v] + 1;
            $q->enqueue($next_v);
        }
    }
    return $dist;
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 63640
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())

#繰り返し自乗法だよ
#これはnのp乗をmで割ったあまりをだすよ
def modular_w_binary_method (n,m,p):
    ans=1 if n>0 else 0
    while(p>0):
        if p%2==1:
            ans=(ans*n)%m
        n=(n**2)%m
        p//=2
    return ans
#mod上でのaの逆元を出すよ
"""
    フェルマーの小定理より a**(p)%p==a isTrue
    これを利用すれば a**(p-2)%p==a**(-1) isTrue
    元と逆元とをかけてpで割れば1が余るよ！
"""
def modular_inverse(a,prime):
    return(modular_w_binary_method(a,prime,prime-2))
#逆元を使うと容易に頑張れるｃ
def conbination(n,a,mod=10**9+7):
    #cはイラない
    res=1 
    for s in range(a):
        res=(res*(n-s)*(modular_inverse(s+1,mod)))%mod

        
    return res
#操作から作れるものの組み合わせは何個かー＞同じものでも違う方法で構成できるかから考える方法もある
"""
"""

#solution:

#input
H,W=pin()
h=0
for i in range(H):
    t=list(input())
    for j in t:
        if j=="#":
            h+=1
#print(h)
print(["Impossible","Possible"][h==(H+W-1)])
#print(m)
#print(["No","Yes"][cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

Measured memory_bytes: 68332
N=int(input())
A=[int(x) for x in input().split()]
guu=[]

result="APPROVED"
for i in range(N):
    if A[i]%2==0:
        guu.append(A[i])
for i in range(len(guu)):
    if (guu[i]%3!=0)and(guu[i]%5!=0):
            result="DENIED"
            break

print(result)

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

const ll INF =ll(1e18)+1;

int main(){
  ll n,k;
  cin >> n >>k;
  vector<ll> a(n);
  rep(i,n)cin >> a.at(i);
  sort(a.begin(),a.end());
  ll l = -INF,r=INF;
  while(l+1<r){  
  	ll x = (l+r)/2,count=0; 
    rep(i,n){
      if(a[i]<0){
        int l=-1,r=n;
        while (l+1<r) {
          int m = (l+r)/2;
          if (a[i] * a[m] < x) {
            r = m;
          } else {
            l = m;
          }
        }
        count+=n-r;
      }else{
        int l=-1,r=n;
        while(l+1<r){
          int m =(l+r)/2;
          if(a[i]*a[m]<x){
            l = m;
          }else{
            r = m;
          }
        }       
        count+=r;   
      }
      if(a[i]*a[i]<x)count--;
    }
    count/=2;
    if(count<k){
      l=x;
    }else{
      r=x;
    }
  }
  cout << l << endl;
}

Measured memory_bytes: 1792
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<String> w = new ArrayList<String>(n);
        for(int i = 0; i < n; i++){
            w.add(sc.next());
        }
        List<String> x = new ArrayList<String>(new HashSet<>(w));
        boolean bre = false;
        for(int i = 0; i < n - 1; i++){
            if (w.get(i).charAt(w.get(i).length() - 1) != w.get(i + 1).charAt(0)) {
                bre = true;
                break;
            }
        }
        if (bre || w.size() != x.size()) {
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

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

using ll = long long;
using lli = long long int;

std::string s;
ll k, n;
std::vector<ll> vec, vec3;
std::vector<std::pair<ll, ll>> vec2;

int main() {
    std::cin >> s;
    n = s.size();
    ll min_change = 100;
    std::cin >> k;
    vec.assign(n, 0);
    vec3.assign(n, 0);
    for (int i = 0; i < n; i++) {
        ll p;
        if (s[i] == 'a') {
            p = 0;
        }
        else {
            p = ('z'-s[i]) + 1;
        }
        vec[i] = p;
        vec2.push_back(std::make_pair(p, i));
        if (p < min_change) {
            min_change = p;
        }
    }
    if (k < min_change) {
        s[s.size()-1] += k;
        std::cout << s << std::endl;
        return 0;
    }
    for (ll i = 0; i < n; i++) {
        if (k >= vec2[i].first) {
            k -= vec2[i].first;
            s[i] = 'a';
        }
    }
    k %= 26;
    s[s.size()-1] += k;
    std::cout << s << std::endl;
}


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

int main (){ 
    int H, W, N;
    cin>>H>>W>>N;
    int LK=max(H, W);
    int Ans=N/LK;
    if(N>Ans*LK)Ans++;
    cout<<Ans;
}

Measured memory_bytes: 256
using System;

class Hoge{
  static void Main(){
    string[] s=Console.ReadLine().Split();
    int a=int.Parse(s[0]);
    int b=int.Parse(s[1]);
    if(a<=8&&b<=8){
      Console.WriteLine("Yay!");
    }
    else{
      Console.WriteLine(":(");
    }
  }
}

Measured memory_bytes: 11092
/******************
*  Writer: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;

int n,t,a,b,ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	ans=1e9;
	cin>>n>>t;
	for(int i=1;i<=n;i++){
		cin>>a>>b;
		if(b<=t){
			ans=min(ans,a);
		}
	}
	
	if(ans==1e9){
		cout<<"TLE";
	}else{
		cout<<ans;
	}
	
	return 0;
}


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


int main()
{
    long long x;
    cin >> x;
    long long res = 100;
    long long year = 0;
    while (res < x)
    {
        res = res * 1.01;
        year++;
    }
    cout << year << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

int N;
int A[666];

int pos[666];

int dp[2][333][333];

signed main(){
    cin>>N;

    memset(pos,-1,sizeof(pos));
    rep(i,2*N){
        cin>>A[i];
        if(A[i]!=-1){
            A[i]--;
            pos[A[i]]=i;
        }
    }

    dp[0][0][0]=1;
    rep(i,2*N){
        int p=pos[2*N-1-i];
        rep(j,N+1)rep(k,N+1){
            if(p!=-1&&A[p^1]!=-1){
                add(dp[(i+1)&1][j][k],dp[i&1][j][k]);
            }
            else if(p!=-1){
                add(dp[(i+1)&1][j+1][k],dp[i&1][j][k]);
                if(k)add(dp[(i+1)&1][j][k-1],dp[i&1][j][k]);
            }
            else{
                add(dp[(i+1)&1][j][k+1],dp[i&1][j][k]);
                if(j)add(dp[(i+1)&1][j-1][k],dp[i&1][j][k]*j%mod);
                if(k)add(dp[(i+1)&1][j][k-1],dp[i&1][j][k]);
            }
            dp[i&1][j][k]=0;
        }
    }

    int ans=dp[0][0][0];
    int num=0;
    rep(i,N)if(A[i*2]==-1&&A[i*2+1]==-1)num++;
    for(int i=1;i<=num;i++)ans=ans*i%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<bits/stdc++.h>
#include<array>
using namespace std;
#define int long long
#define fast_cin ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define endl "\n"
#define with_tests int t; cin >> t; while(t--){ solve(); cout << endl; }
#define without_tests solve(); cout << endl;
#define CEIL(x, y) (ll)ceil((long double)(x)/(long double)(y))
#define epsilon 1e-9 
typedef long long ll;
const int mod = 1e9+7;
const int N = 3e3+1;

// int dp[N][N];

void solve(){
    
    string s, t;
    cin >> s >> t;
    int n = s.length(), m = t.length();
    
    vector<vector<int>> dp(n+1, vector<int>(m+1, 0));

    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    int i = n, j = m;
    string ans = "";
    while(i!=0 && j!=0){
        if(dp[i][j] == dp[i-1][j]){
            i = i-1;
        }
        else if(dp[i][j] == dp[i][j-1]){
            j = j-1;
        }
        else{
            ans += s[i-1];
            i = i-1, j = j-1;
        }
    }
    // for(int i=0; i<=n; i++){
    //     for(int j=0; j<=m; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    reverse(ans.begin(), ans.end());
    cout << ans;
}

int32_t main(){

    fast_cin;
    // with_tests;
    without_tests;

    return 0;
}


Measured memory_bytes: 73632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define forin(x,y) for(ll i=x;i<y;i++)
#define vii vector<ll>
#define pii  pair<ll,ll>
#define pb push_back
#define mp make_pair
#define big (ll)1e18 +5
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void evaluate()
{
    ;
}
int main()
{
    ios::sync_with_stdio(false);    cin.tie(0);     cout.tie(0);
    ll n,w,temp=0,sum_val=0,ans=0; cin>>n>>w;
    vii val(n+1),wt(n+1);
    forin(0,n)
    {
        cin>>wt[i+1]>>val[i+1];
        sum_val += val[i+1];
    }
    vector<vii> dp(n+1);
    for(auto &i : dp)   i.resize(sum_val+1,0);
    for(ll i=0;i<=n;i++)    dp[i][0] = 0;
    for(ll i=1;i<=sum_val;i++)  dp[0][i]=  big;
    for(ll i=1;i<=n;i++)
    {
        for(ll j = 1; j<=sum_val; ++j)
        {
            dp[i][j] = min(dp[i-1][j], dp[i-1][max((ll)0,j-val[i])]+wt[i]);
        }
    }
    for(ll i=1;i<sum_val+1;++i)
    {
        if(dp[n][i]<=w)
        {
            ans = max(ans,i);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 79488
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        sc.close();
        int ans = 0;
        for(int i = 1; i <= n; i++){ 
            if(i <= k){
                ans = ans + x;
            }else{
                ans = ans + y;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21588
#if _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#ifndef ONLINE_JUDGE 
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

// Reads a 1D vector
template <class T>
void read1d(vector<T> & arg) {
	const int l = arg.size();
	for (int i = 0; i < l; ++i) cin >> arg[i];
}

void read() {}
// Reads arbitrary values
template <class T1, class... T2>
void read(T1& var1, T2&... var2) { cin >> var1; read(var2...); }



void pln() { cout << (DEBUG ? "]\n" : "\n"); }
template <class T1, class... T2>
void pln(const T1& var1, const T2& ... var2) { cout << var1 << " "; pln(var2...); }

// Prints arbitrary values and goes to next line
template <class T1, class... T2>
constexpr void print(const T1& var1, const T2& ... var2) { cout << (DEBUG ? " [ " : ""); pln(var1, var2...); }

// Prints arbitrary values and goes to next line ONLY IF IN DEBUG MODE
template <class T1, class... T2>
constexpr void debug(const T1& var1, const T2& ... var2) { if (!DEBUG) return;  cout << " debug : [ "; pln(var1, var2...); }





using ll = long long;
using ull = unsigned long long;


#define all(x) begin(x), end(x)

const bool MULTIPLE_TEST_CASES = 0;


void exec() 
{
	int n, x, t;
	read(n, x, t);

	int ans = (n / x) * t;
	if (n % x != 0) ans += t;

	print(ans);
}

















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

	if (!MULTIPLE_TEST_CASES)
		exec();
	else {
		int n;
		cin >> n;

		while (n--)
			exec();
	}

    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());
            var ans = 1;

            for (var i = 3; i <= X; i++)
            {
                for (var j = 2; j <= X; j++)
                {
                    var val = i;
                    var count = 0;
                    var isOk = false;
                    while (val % j == 0)
                    {
                        count++;
                        val /= j;
                        if (val == 1)
                        {
                            isOk = true;
                            break;
                        }
                    }
                    if (isOk && count > 1)
                    {
                        ans = i;
                        break;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const int nax = 305;
const int inf = 1e9 + 5;
char sl[nax][nax];
int dp[nax][nax];
// int pre[nax][2];
#define move move_compile
int move[nax][nax];

void mini(int & a, int b) {
	a = min(a, b);
}

/* int solve(int a, int b) {
	if(a >= b) return 0;
	int & r = dp[a][b];
	if(r != inf) return r;
	for(int mid = a; mid <= b; ++mid) {
		int maybe = solve(a, mid - 1) + solve(mid + 1, b);
		if(a != mid) maybe += pre[mid][0];
		if(b != mid) maybe += pre[mid][1];
		r = min(r, maybe);
	}
	return r;
} */

int main() {
	long long ans = 0;
	int h, w;
	scanf("%d%d", &h, &w);
	for(int i = 0; i < h; ++i)
		scanf("%s", sl[i]);
	for(int col = 0; col < w - 1; ++col) {
		for(int i = 0; i <= h; ++i)
			move[i][h] = move[h][i] = 0;
		for(int i = h - 1; i >= 0; --i)
			for(int j = h - 1; j >= 0; --j)
				move[i][j] = move[i+1][j+1] + (sl[h - 1 - i][col] == sl[h - 1 - j][col+1]);
		//for(int i = 0; i < h; ++i)
		//	for(int j = 0; j < h; ++j)
		//		printf("move[%d][%d] = %d\n", i, j, move[i][j]);
		// printf("%d\n", move[0][0]);
		for(int i = 0; i <= h; ++i)
			for(int j = 0; j <= h; ++j)
				dp[i][j] = inf;
		dp[0][0] = 0;
		for(int i = 0; i <= h; ++i)
			for(int j = 0; j <= h; ++j) {
				int tmp = dp[i][j] + move[i][j];
				mini(dp[i+1][j], tmp);
				mini(dp[i][j+1], tmp);
			}
		//printf("%d\n", dp[h][h]);
		ans += dp[h][h];
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
int a[3000][2],i=0;
do{
scanf("%d %d",&a[i][0],&a[i][1]);
i++;
}while(a[i-1][0]!=0||a[i-1][1]!=0);
for(int b=0;b<i-1;b++){
if(a[b][0]<=a[b][1])printf("%d %d\n",a[b][0],a[b][1]);
else if(a[b][0]>a[b][1])printf("%d %d\n",a[b][1],a[b][0]);
}
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> count(N);
  for (int i= 0; i < M* 2; i++) {
    int x;
    cin >> x;
    count.at(x- 1)++;
  }
  for (int i= 0; i < N; i++) {
    cout << count.at(i) << endl;
  }
}

Measured memory_bytes: 3632
import sys

k = int(input())
a = list(map(int, input().split()))


x, y = 2, 2

for i in range(k-1, -1, -1):
    minx = x + (a[i] - x % a[i]) % a[i]
    maxx = y - y % a[i]
    if minx > maxx:
        print(-1)
        sys.exit(0)
    else:
        x, y = minx, maxx + a[i] - 1


print(x, y)


Measured memory_bytes: 14224
import java.util.*;

class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();//夏休み
		int m=sc.nextInt();//宿題の数
		
		int sum=0;
		
		for(int i=0;i<m;i++){
			sum+=sc.nextInt();
		}
		
		if(sum>n)System.out.println(-1);
		else System.out.println(n-sum);
	}
}

Measured memory_bytes: 46076
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#define ll long long

using namespace std;


void solve(){
    string str;
    cin >> str;
    int count = 0;
    int mx = 0;
    for(int i = 0; i < str.length(); i++)
    {
        if(str[i] == 'R')
            count++;
        else
        {
            mx = max(count, mx);
            count = 0;
        }
    } 
    mx = max(count, mx);
    cout << mx << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3644
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("sumsqr.in");ofstream out("sumsqr.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int a,k,o=0,z;
vec<vec<int>> n;

void gen(vec<int> m){
    if(m.size()==a){
        int tyt = 0;
        for(auto &i : n){
            tyt += i[3]*(m[i[1]]-m[i[0]]==i[2]);
        }
        o = max(o, tyt);
        return;
    }
    for(int q = m.empty() ? 1 : m.back(); q<=k; q++){
        m.pb(q);
        gen(m);
        m.pop_back();
    }
}

int main() {
    fast;
    cin>>a>>k>>z;
    n = vec<vec<int>>(z, vec<int>(4));
    for(int q=0; q<z; q++){
        for(int w=0; w<4; w++) cin>>n[q][w];
        n[q][0]--;
        n[q][1]--;
    }
    gen(vec<int>());
    cout<<o;
}

Measured memory_bytes: 3656
import string


S = input()
lowercase_list = string.ascii_lowercase

bucket = [0 for i in range(len(lowercase_list))]
for s_i in S:
    bucket[lowercase_list.index(s_i)] += 1


for index, val in enumerate(bucket):
    if val == 0:
        print(lowercase_list[index])
        exit()
print('None')


Measured memory_bytes: 3832
N = int(input())
S = [input().strip() for _ in range(N)]
M = int(input())
T = [input().strip() for _ in range(M)]
cntmax = 0
for s in S:
    cnt = S.count(s)
    for t in T:
        if t==s:
            cnt -= 1
    cntmax = max(cntmax,cnt)
print(cntmax)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;
int N;
vector<int> v;
vector<int> dp;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> N;
    v.resize(N);
    dp.resize(N);
    fill(all(dp), 0);

    for(int i = 0; i < N; i++) {
        cin >> v[i];
    }

    for(int i = 1; i < N; i++) {
        if(i == 1) dp[i] = abs(v[i] - v[i-1]) + dp[i-1];
        else dp[i] = min(abs(v[i] - v[i-1]) + dp[i-1], abs(v[i] - v[i-2]) + dp[i-2]);
    }

    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 3992
#include<iostream>
using namespace std;
int main()
{
	int n,k,ans;
	ans=1;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		if(ans>k)
		{
			ans+=k;
			continue;
		}
		if(ans<=k)
		{
			ans+=ans;
			continue;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
  { 
  int i,c=0,n;
   cin>>n;
   char arr[n] ;
   for(i=0;i<n;i++)
     cin>>arr[i];
   for(i=0;i<n;i++){
      if(arr[i]=='A' && arr[i+1]=='B' && arr[i+2]=='C')
      {  c++;
       i+=2;
      }
   
   }
   cout<<c<<endl;
   
  }

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

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)
#define Dep(i, s, e) for (re int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

il int read() {
	int x = 0; bool f = true; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return f ? x : -x;
}

char s[210];
int k, n, dp[110][5][2];

int dfs(int now, int cnt, bool eql) {
	if (now == n + 1) return cnt == k;
	if (cnt > k) return 0;
	if (dp[now][cnt][eql]) return dp[now][cnt][eql];
	int nmax = eql ? s[now] - '0' : 9, sum = 0;
	Rep(i, 0, nmax) {
		sum += dfs(now + 1, cnt + (i != 0), eql && (i == nmax));
	}
	return dp[now][cnt][eql] = sum;
}

int main() {
	gets(s + 1), k = read();
	n = strlen(s + 1);
	printf("%d", dfs(1, 0, 1));
	return 0;
}

Measured memory_bytes: 256
N = int(input())
lst = list(map(int,input().split()))
c1 = 0
c2 = 0
for i in lst:
  if (i % 4 == 0):
    c1 += 1
  elif (i % 2 != 0):
    c2 += 1
    
ans = 'No'
if (len(lst) % 2 == 0):
  if (c1 >= c2):
    ans = 'Yes'
else:
  if (c1 >= c2 - 1):
    ans = 'Yes'
print(ans)

Measured memory_bytes: 62576
import java.util.Scanner;

class Main {
 
    //https://atcoder.jp/contests/abc129/tasks/abc129_a
    public static void main( String[] args ) {
      try{
        Scanner scanner = new Scanner(System.in);
 
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
 
        System.out.println(Math.min(a + b, Math.min(b + c, c + a)));
      } catch(Exception e){
      return;
      }
    }
}

Measured memory_bytes: 23892
import datetime
yobi = {0:"Monday",1:"Tuesday",2:"Wednesday",3:"Thursday",4:"Friday",5:"Saturday",6:"Sunday"}
try:
    while True:
        m, d= map(int, input().split())
        if m == 0 and d == 0 :
            exit()
        day = datetime.datetime.strptime("2004/" + str(m) + "/" + str(d),"%Y/%m/%d")
        if day.weekday() in yobi:
            output = yobi[int(day.weekday())]
            print(output)
except EOFError:
    pass


Measured memory_bytes: 7336