akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;

void main()
{
  while ( true ) {
	string[] line = split( readln() );
	int n = to!int( line[ 0 ] );
	int q = to!int( line[ 1 ] );
	if ( n == 0 && q == 0 ) break;
	int[ 101 ] date;
	foreach ( i; 0 .. n ) {
	  line = split( readln() );
	  int m = to!int( line[ 0 ] );
	  foreach ( j; 0 .. m ) {
		date[ to!int( line[ j + 1 ] ) ]++;
	  }
	}
	int mx = reduce!(max)( 0, date );
	if ( mx >= q ) {
	  foreach ( i; 0 .. 100 ) {
		if ( date[ i ] == mx ) {
		  writeln( i );
		  break;
		}
	  }
	} else {
	  writeln( 0 );
	}
  }
}

Measured memory_bytes: 2040
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MOD=1e9+7;
int memo[1005][1005];
char kotak[1005][1005];
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int N, M;
	cin>>N>>M;
	for(int a=1;a<=N;a++)
	{
		for(int b=1;b<=M;b++)
		{
			cin>>kotak[a][b];
		}
	}
	for(int a=1;a<=N;a++)
	{
		for(int b=1;b<=M;b++)
		{
			if(kotak[a][b]=='#') continue;
			if(a==1 && b==1) memo[a][b]=1;
			else
			{
				memo[a][b]+=memo[a-1][b];
				memo[a][b]%=MOD;
				memo[a][b]+=memo[a][b-1];
				memo[a][b]%=MOD;
			}
		}
	}
	printf("%d\n", memo[N][M]);
	return 0;
}

Measured memory_bytes: 5120
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 305
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,k;
char str[MAXN];
int dp[MAXN][MAXN][MAXN];
int solve(int l,int r,int k)
{
    if(l>r) return 0;
    if(l==r) return 1;
    if(dp[l][r][k]!=-1) return dp[l][r][k];
    int &ans=dp[l][r][k];
    ans=0;
    ans=max(ans,solve(l+1,r,k));
    ans=max(ans,solve(l,r-1,k));
    if(str[l]==str[r]) ans=max(ans,2+solve(l+1,r-1,k));
    else if(k) ans=max(ans,2+solve(l+1,r-1,k-1));
    return ans;
}
int main()
{
    scanf("%s",str+1);
    n=strlen(str+1);
    scanf("%d",&k);
    memset(dp,-1,sizeof(dp));
    printf("%d\n",solve(1,n,k));
    return 0;
}



Measured memory_bytes: 111104
from collections import defaultdict

MOD = 1000000007
n = int(input())
s = input()
t = input()
dic = defaultdict(int)
dic[s[0]] = 1
for cs, ct in zip(s[1:n-1], t[1:n-1]):
    dic[cs] += dic[ct]
    dic[cs] %= MOD
print(dic[t[-1]])


Measured memory_bytes: 6288
#include <bits/stdc++.h>
#define l first
#define r second
#define int long long

const int maxn = 1e6 + 1, maxk = 1500101;

using namespace std;

int a[maxn], b[maxn], c[maxn];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m, q, x, y;
    cin >> x >> y >> n >> m >> q;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++)
        cin >> b[i];
    for (int i = 0; i < q; i++)
        cin >> c[i];
    sort(a, a + n);
    sort(b, b + m);
    sort(c, c + q);
    for (int i = 0; i < x; i++)
        a[i] = a[n - x + i];
    for (int i = 0; i < y; i++)
        b[i] = b[m - y + i];
    for (int i = 0; i < x / 2; i++)
        swap(a[i], a[x - i - 1]);
    for (int i = 0; i < y / 2; i++)
        swap(b[i], b[y - i - 1]);
    for (int i = 0; i < q / 2; i++)
        swap(c[i], c[q - i - 1]);
    int i = 0, j = 0, p = x + y - 1;
    int cx = 0, cy = 0, cc = 0;
    for (int i = 0; i <= min(p, q - 1); i++)
        cc += c[i];
    int ans = 0;
    while (i < x || j < y) {
        if (p >= q) {
            if (j == y || i < x && a[i] > b[j])
                cx += a[i++];
            else
                cy += b[j++];
            --p; continue;
        }
        ans = max(ans, cx + cy + cc);
        if (j == y || i < x && a[i] > b[j])
            cx += a[i++];
        else
            cy += b[j++];
        cc -= c[p]; --p;
    }
    ans = max(ans, cx + cy + cc);
    cout << ans;
    return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define F first
#define S second

int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll k;
	cin>>k;
	ll a[n+1];
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	vector<ll>next(n+1,-1);
	vector<ll>v;
	ll cur=1;
	while(next[cur]==-1){
		next[cur]=a[cur];
		cur=next[cur];
		v.PB(cur);
	}
	ll cyclebg=cur;
	ll len=1;
	vector<ll>cycle;
	cycle.PB(cyclebg);
	while(next[cur]!=cyclebg){
		cur=next[cur];
		cycle.PB(cur);
		len++;
	}
	ll done=v.size()-len;
	ll rem=(k-done)%len;
	if(k<=v.size()){
		cout<<v[k-1];
	}
	else{
		cur=cyclebg;
		while(rem>0){
			cur=next[cur];
			rem--;
		}
		cout<<cur;
		//cout<<cycle[rem];
	}
	return 0;
}

Measured memory_bytes: 10788
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint M, D;
    cin >> M >> D;
    lint res = 0;
    range(m, 1, M + 1) range(d, 1, D + 1) {
        lint d10 = d / 10, d1 = d % 10;
        if (d10 >= 2 and d1 >= 2 and d1 * d10 == m) res += 1;
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B,C=MI()
    need=(C-A-B)
    # print(need,4*A*B)
    if(need<0):
        print("No")
        return
    if(need**2>4*A*B):
        print("Yes")
    else:
        print("No")

    # print("YNeos"[sqrt(A)+sqrt(B)>=sqrt(C)::2])
if __name__ == '__main__':
    main()

Measured memory_bytes: 5392
n = input()
a = [int(i) for i in input().split()]

minx = min(a)
maxx = max(a)
ans = 2 * 10 ** 18

for i in range(minx,maxx+1):
  judge = 0
  for j in a:
    temp = (j - i) ** 2
    judge += temp
  if judge < ans:
    ans = judge

print(ans)


Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
      	long d = sc.nextLong();
      	d *= d;
      	long stack1;
      	long stack2;
      	int count = 0;
      	
      	for(int i = 0;i < n;i++){
        	stack1 = sc.nextInt();
          	stack2 = sc.nextInt();
          	if(stack1*stack1 + stack2*stack2 <= d) count++;
        }
      
        System.out.println(count);
            	
        
	}
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  ll k; cin >> k;
  vector<vector<string>> v(1000);

  ll cnt = 0;
  for(char i='1';i<='9';++i) {
    v[0].push_back(to_string(i-'0'));
    cnt++;
    if(cnt == k) {
      cout << i << endl;
      return 0;
    }
  }
  for(int i=0;i<999;++i) {
    for(int j=0;j<SZ(v[i]);++j) {
      if(v[i][j].back() != '0') {
        v[i+1].push_back(v[i][j]+to_string(v[i][j].back()-'0'-1));
        cnt++;
        if(cnt == k) {
          cout << v[i+1].back() << endl;
          return 0;
        }
      }
      v[i+1].push_back(v[i][j]+to_string(v[i][j].back()-'0'));
      cnt++;
      if(cnt == k) {
        cout << v[i+1].back() << endl;
        return 0;
      }
      if(v[i][j].back() != '9') {
        v[i+1].push_back(v[i][j]+to_string(v[i][j].back()-'0'+1));
        cnt++;
        if(cnt == k) {
          cout << v[i+1].back() << endl;
          return 0;
        }
      }
    }
    //printv(v[i+1]);
  }
}


Measured memory_bytes: 5752
program main
  implicit none
  integer :: n, i, l, res
  character(50) :: s
  read (*, *) n
  read (*, *) s
  l = len(trim(s))
  res = 0
  do i = 1, l - 2
    if(s(i:i + 2) == "ABC") res = res + 1
  end do
  write (*, "(i0)") res
end program main


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define ull unsigned long long int
#define ll long long
#define l long
#define sd(x) scanf("%d",x) 
#define sld(x) scanf("%ld",x) 
#define slld(x) scanf("%lld",x) 
#define sllu(x) scanf("%llu",x) 
#define ss(x) scanf("%s",x) 
#define rep(x) for(book[x].onoff=0;book[x].onoff<2;book[x].onoff++)
#define min(x,y) x<y?x:y

int main(){
  int N,pos;
  sd(&N);
  ull K,v,c;
  sllu(&K);
  int A[N+1],B[200001]={};
  for(int i=1;i<=N;i++)
    sd(&A[i]);
  pos=1;
  B[pos]=1;
  for(ull u=2;u<=K+1;u++){
    pos=A[pos];
    if(u==K+1){
      printf("%d",pos);
      return 0;
    };
    if(B[pos]!=0){
      v=u-B[pos];
      c=B[pos]-1;
      break;
    };
    B[pos]=u;
  };
  //printf("%llu %llu",v,c);
  v=((K-c)%v)+c;
  pos=1;
  for(int i=1;i<=v;i++){
    pos=A[pos];
  };
  printf("%d",pos);
};
   

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

int main() {
	int A, B, C, D, P, X, Y;
	cin >> A >> B >> C >> D >> P;
	X = A*P;
	if(C<P)	Y = B+D*(P-C);
	else Y = B;
	if(X<Y) cout << X << endl;
	else cout << Y << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n,m;
    cin>>n;
    vector <int> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    cin>>m;
    vector <int> b(m);
    for(int i=0;i<m;i++)
    {
        cin>>b[i];
    }
    cout<<lexicographical_compare(a.begin(),a.end(),b.begin(),b.end())<<endl;
    return 0;
}



Measured memory_bytes: 3108
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>
// #include <atcoder/fenwicktree>

using namespace std;
// using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 998244353;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 int x;cin>>x;
 cout << (1 ^ x) << endl;

 return 0;
}


Measured memory_bytes: 3620
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; 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 true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DSummerVacation {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      vector<P> vec(n);
      rep(i, n) {
        int a, b; cin >> a >> b;
        vec[i] = P(a, b);
      }
      sort(all(vec));
      int ans = 0;
      int pos = 0;
      priority_queue<int> que;
      for(int i=1; i<=m; i++) {
        while(pos < n && vec[pos].first <= i) {
          que.push(vec[pos].second);
          pos++;
        }
        if (!que.empty()) {
          int p = que.top(); que.pop();
          ans += p;
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  DSummerVacation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 100005;

int n, m;
vector<int> job[MAXN];
priority_queue<int> pq;

ll ans;
/********** Good Luck :) **********/
int main()
{
    TIME(main);
    IOS();
    cin >> n >> m;
    REP (i, n) {
        int a, b;
        cin >> a >> b;
        job[a].eb(b);
    }

    REP1 (i, m) {
        for (auto tsk : job[i]) {
            pq.emplace(tsk);
        }

        if (!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }

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


Measured memory_bytes: 5632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	bitset<10001> b; b[0] = 1;
	rep(i, n) {
		int a; cin >> a;
		b |= b << a;
	}
	int out = 0;
	rep(i, 10001) {
		if (i % 10 == 0)continue;
		if (b[i])out = i;
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        out_of_loop:
        while(true)
        {
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            int ans = 0;
            switch(op)
            {
                case "+" :
                ans = a + b;
                break;
                case "-" :
                ans = a-b;
                break;
                case "*" :
                ans = a * b;
                break;
                case "/" :
                ans = a / b ;
                break;
                case "?" :
                break out_of_loop;
            }
            System.out.println(ans);
        }
        
        sc.close();

    }
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int n, m;
  cin >> n >> m;
  string u;
  cin >> u;
  if(s == u) {
    cout << n-1 << " " << m << endl;
  }
  else {
    cout << n << " " << m-1 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <functional>
#include <time.h>
#include <math.h>

using namespace std;


int main() {

	int a, b;

	cin >> a >> b;

	if (a < b * 2) {
		cout << 0;
	}
	else {
		cout << a - (b * 2);
	}

}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){ll ans=1;rrp(i,n-r+1,n+1){ans*=i;ans%=mod;}return ans/=fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n;
 ll a;
 cin>>n;
 ll div=1;
 for(i=2;i*i<=n;++i){
  if(n%i==0)div=i;
 }
 cout<<dig(max(div,n/div))<<endl;
return 0;}

Measured memory_bytes: 3604
from collections import deque
from itertools import product


def bfs(x, y):
    dist = [[10 ** 9] * w for _ in range(h)]
    dist[y][x] = 0
    que = deque([(x, y)])
    move = product(range(-2, 3), repeat=2)
    near = [(dx, dy, (abs(dx) + abs(dy) >= 2)) for dx, dy in move]

    while len(que) > 0:
        x, y = que.popleft()
        if (x, y) == (Dw - 1, Dh - 1):
            return dist[y][x]

        for dx, dy, cnt in near:
            i, j = x + dx, y + dy
            if (0 <= i < w and 0 <= j < h and
                    dist[j][i] > dist[y][x] + cnt and s[j][i] == '.'):
                dist[j][i] = dist[y][x] + cnt
                if cnt == 0:
                    que.appendleft((i, j))
                elif cnt == 1:
                    que.append((i, j))
    return -1


h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
s = [input() for _ in range(h)]

print(bfs(Cw - 1, Ch - 1))


Measured memory_bytes: 88200
a_list = []
bingo_list = [0] * 9
for _ in range(3):
    a = list(map(int, input().split()))
    a_list = a_list + a
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(9):
        if a_list[i] == b:
            bingo_list[i] = 1
        else:
            continue
if sum(bingo_list[:3]) == 3 or sum(bingo_list[3:6]) == 3 or sum(bingo_list[6:]) == 3:
    print("Yes")
elif bingo_list[0] == bingo_list[3] == bingo_list[6] == 1:
    print("Yes")
elif bingo_list[1] == bingo_list[4] == bingo_list[7] == 1:
    print("Yes")
elif bingo_list[2] == bingo_list[5] == bingo_list[8] == 1:
    print("Yes")
elif bingo_list[0] == bingo_list[4] == bingo_list[8] == 1:
    print("Yes")
elif bingo_list[2] == bingo_list[4] == bingo_list[6] == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
ans = 'No'
def match(i, j):
  for k in range(M):
    for l in range(M):
      if A[i+k][j+l] != B[k][l]:
        return False
  return True
for i in range(N-M+1):
  for j in range(N-M+1):
    if match(i, j):
      ans = 'Yes'
      break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pb push_back
#define pq priority_queue
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define MODNUM 1000000007
#define lp(i,a,b) for(ll i=a; i<b; i++)
 
using namespace std;
 
ll mex(ll a, ll b, ll m) {
	if(b==0) return 1;
	if(b%2) return a*mex((a*a)%m,(b-1)/2,m)%m;
	else return mex((a*a)%m,b/2,m);
}
 
int x,y;
void exteu(ll a, ll m) {
	if(m==0) { x=1;y=0; }
	else {
		exteu(m,a%m);
		ll temp = x;
		x=y;
		y=temp-(a/m)*y;
	}
}
 
ll fact(ll n) 
{	ll prod=1;
	for(ll i=2; i<=n; i++) {
		prod*=i;
	}
	return prod;
}
 
ll gcd(ll a, ll b) {
	if(b==0) return a;
	return gcd(b, a%b);
}
 
// bool isprime[100001];
// void makesieve() {
// 	memset(isprime, true, sizeof(isprime));
// 	for (int i = 2; i <= sqrt(200000); ++i)
// 	{
// 		if(isprime[i]) {
// 			for (int j = i*i; j <= 200000; j+=i)
// 			{
// 				isprime[j]=false;
// 			}
// 		}
// 	}
// }
// 
// 1 2 4 5 8
vvll D = {{-1,-1}, {1,1}, {1,-1}, {-1,1}};
void solve() {
	ll n;cin>>n;
	cout<<(n%1000?(1000-(n%1000)) : 0);
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1;
	// cin >> TESTS;
	// makesieve();
	while(TESTS--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3612
n = gets.to_i
r = n.times.map { gets.to_i }

$max = r.last
def max_min(array)
  if array[1] > $max
    $max = array[1]
  end
  $max - array.first
end

puts (n - 2).downto(0).map { |i| max_min(r[i, n - i]) }.max

Measured memory_bytes: 10052
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(size_t i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(size_t i = 0; i < n; i++)
#define asort(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.begin(), a.end(), greater<int>())
 
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;

const int M = 1e9 + 7;

int32_t main()
{
    fast_io;                        
    int h, w;
    cin >> h >> w;
    char c;
    vector<vector<char>> grid(h+1, vector<char>(w+1));
    vii dp(h+1, vi(w+1));
    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++)
            cin >> grid[i][j];
    
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            if(grid[i][j] == '.')
            {
                if(i == 1)
                {
                    if(j == 1)
                        dp[i][j] = 1;
                    if(j > 1 && dp[i][j-1])
                        dp[i][j] = 1;
                }
                else
                {
                    if(dp[i-1][j] == 0 && dp[i][j-1] == 0)
                        dp[i][j] = 0;
                    else if(dp[i-1][j] == 0)
                        dp[i][j] = dp[i][j-1];
                    else if(dp[i][j-1] == 0)
                        dp[i][j] = dp[i-1][j];
                    else
                        dp[i][j] = ((dp[i-1][j])%M + (dp[i][j-1])%M)%M;    
                }
            }
        }
    }
    cout << dp[h][w]%M;


    return 0;
}

Measured memory_bytes: 11980
h,w=map(int,input().split())
if h==2 and w==2:
  print(1)
  exit()
ans=10**10
if h>=3:
  if h%3==0:
    a=0
  else:
    a=w
  if a<ans:
    ans=a
if w>=3:
  if w%3==0:
    a=0
  else:
    a=h
  if a<ans:
    ans=a
if h>1:
  b=h//3
  x1=w*b
  x2=(h-b)*(w//2)
  x3=h*w-x1-x2
  a=max(x1,x2,x3)-min(x1,x2,x3)
  if a<ans:
    ans=a
  x1=w*(b+1)
  x2=(h-b-1)*(w//2)
  x3=h*w-x1-x2
  a=max(x1,x2,x3)-min(x1,x2,x3)
  if a<ans:
    ans=a
  b=w//3
  x1=h*b
  x2=(w-b)*(h//2)
  x3=h*w-x1-x2
  a=max(x1,x2,x3)-min(x1,x2,x3)
  if a<ans:
    ans=a
  x1=h*(b+1)
  x2=(w-b-1)*(h//2)
  x3=h*w-x1-x2
  a=max(x1,x2,x3)-min(x1,x2,x3)
  if a<ans:
    ans=a
print(ans)

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

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

if(x%10==3){
  cout<<"bon"<<endl;
}
else if((x%10==0)||(x%10==1)||(x%10==6)||(x%10==8)){
  cout<<"pon"<<endl;
}	
else{
  cout<<"hon"<<endl;
}	
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> a(n + 1), b(n);
  std::cin >> a >> b;

  int64_t ans = 0;
  for (int64_t i = 0; i < n; i++) {
    const auto kill = std::min(a[i], b[i]);
    ans += kill;
    a[i] -= kill;
    b[i] -= kill;
    const auto kill2 = std::min(b[i], a[i + 1]);
    ans += kill2;
    a[i + 1] -= kill2;
    b[i] -= kill2;
  }

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


Measured memory_bytes: 1792
import java.util.Scanner;

/**
 * Created by labuser on 2016/04/15.
 */
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {

        int a;
        int b;

        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        a = Integer.parseInt(input[0]);
        b = Integer.parseInt(input[1]);
        System.out.println((a*b)+" "+(a+a+b+b));
    }
}

Measured memory_bytes: 25928
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;
char D;

int main() {
	go;
    cin >> D;
    if(D == tolower(D)) {
    	cout << "a\n";
    }
    else {
    	cout << "A\n";
    }
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(void){
  int n;
  cin>>n;
  if(n<10)cout<<n<<endl;
  else if(n<100)cout<<9<<endl;
  else if(n<1000)cout<<n-90<<endl;
  else if(n<10000)cout<<909<<endl;
  else if(n<100000)cout<<n-9090<<endl;
  else cout<<90909<<endl;

  return 0;
}


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

int main()
{

        string s1;
        string s2;

        cin >> s1;
        cin >> s2;

        int length = s1.length();

        int m = 26;
        int a1[m];
        int a2[m];
        for (int i = 0; i < m; ++i) {
                a1[i] = 0;
                a2[i] = 0;
        }

        int c = 0;
        for (int i = 0; i < length; ++i) {

                c = static_cast<int>(s1[i] - 'a');
                a1[c] += 1;

                c = static_cast<int>(s2[i] - 'a');
                a2[c] += 1;
        }

        int tmp = 0;

        for (int i = 0; i < m; ++i) {

                for (int j = 0; j < m-1; ++j) {

                        if (a1[j] < a1[j+1]) {
                                tmp = a1[j];
                                a1[j] = a1[j+1];
                                a1[j+1] = tmp;
                        }

                        if (a2[j] < a2[j+1]) {
                                tmp = a2[j];
                                a2[j] = a2[j+1];
                                a2[j+1] = tmp;
                        }



                }

        }

        for (int i = 0; i < m; ++i) {

                if (a1[i] != a2[i]) {

                        cout << "No" << endl;

                        return 0;
                }

        }

        cout << "Yes" << endl;

}


Measured memory_bytes: 776
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextLong()
    val w = sc.nextLong()
    if (h == 1L || w == 1L) {
        println(1)
        return
    }
    println(((w + 1) / 2) * ((h + 1) / 2) +
    (w / 2) * (h / 2))
}

Measured memory_bytes: 31276
N,M = list(map(int,input().split()))
xfrom1 = []
xton =[]
for i in range(M):
    a,b = list(map(int,input().split()))
    if a == 1:
        xfrom1.append(b)
    elif a== N:
        xton.append(b)
    elif b==N:
        xton.append(a)
if len(set(xfrom1) & set(xton)) >0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
    


Measured memory_bytes: 27588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


int main() {
	int n, m;
	cin >> n >> m;
	vector<ll> a(n, 0LL);
	rep(i,n) cin >> a[i];
	sort(a.rbegin(), a.rend());

	vector<pair<ll, ll>> candidates(m);
	rep(i,m){
        ll b, c;
        cin >> b >> c;
        candidates[i] = make_pair(c, b);
	}
	sort(candidates.rbegin(), candidates.rend());
	ll ans = 0;
	int i = 0, j = 0;
	while(n--){
        if(j < m && candidates[j].first > a[i]){
           ans += candidates[j].first;
           candidates[j].second--;
        }
        else{
            ans += a[i++];
        }
        if(candidates[j].second == 0) j++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<string.h>
int N;
char c[4];
int main(void){
    scanf("%d",&N);
    getchar();
    int count=0;
    int len;
    for(int i=0;i<N;i++){
        fgets(c,4,stdin);
        len=strlen(c);
        if(len==2) count++;
        else count--;
        if(count<0){
            break;
        }
    }
    if(count==0) printf("YES\n");
    else printf("NO\n");
}



Measured memory_bytes: 2104
//nameishere.cpp
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i(0);i<n;i++)
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 100-back0000007
#define pb push
#define all(v) v.begin(), v.end()

int dp(int a[], int n){
	int dp[n+1];
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	for(int i(3);i<=n;i++){
		dp[i] = min(dp[i-1] + abs(a[i-1] - a[i]) , dp[i-2] + abs(a[i-2] - a[i]));
	}
	return dp[n];
}

int32_t main() {
    fast;
    
    
	int n;
	cin>>n;
	int a[n];
	for(int i(1);i<=n;i++)cin>>a[i];

	cout<<dp(a, n);

	return 0;
}


Measured memory_bytes: 1792
N, Q = gets.split.map(&:to_i)
adages = Array.new(N + 1) do
  Array.new
end
(N - 1).times do
  a, b = gets.split.map(&:to_i)
  adages[a] << b
  adages[b] << a
end
v = Array.new(N + 1, 0)
Q.times do
  posi, point = gets.split.map(&:to_i)
  v[posi] += point
end

stack = [[1, 0]]
w = Array.new(N + 1, -1)
w[0] = 0

while (!stack.empty?)
  pos, parent = stack.pop
  w[pos] = v[pos] + w[parent]
  adages[pos].each do |t|
    next if w[t] != -1
    stack.push([t, pos])
  end
end
puts w[1..N].join(' ')


Measured memory_bytes: 34020
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int w = sc.nextInt();
    
    for(int i = 0; i < s.length(); i+=w) System.out.print(s.charAt(i));
    System.out.println();
   	
  	

  }
}


Measured memory_bytes: 36152
def main():
    from math import ceil
    t1,t2=map(int,input().split())
    a1,a2=map(int,input().split())
    b1,b2=map(int,input().split())
    run1=a1*t1-b1*t1
    run2=a2*t2-b2*t2
    #run1,run2=-4,6
    sum_=run1+run2
    #print(run1,run2,sum_)
    if run1>0 and run2>0:
        print(0)
    elif run1<0 and run2<0:
        print(0)
    else:
        if abs(run1)>abs(run2):
            print(0)
        elif abs(run1)==abs(run2):
            print("infinity")
        else:
            if abs(run1)%abs(sum_)==0:
                print(2*ceil(abs(run1)/abs(sum_)))
            else:
                print(2*ceil(abs(run1)/abs(sum_))-1)
main()

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

using ll = long long;
using namespace std;
const ll MOD = 1e9 + 7;

ll mod(ll a, ll b) {
	if (a >= MOD) a = a % MOD;
	if (b >= MOD) b = b % MOD;
	return (a * b) % MOD;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	vector<ll> white(n + 1, 1), black(n + 1, 1), leaf(n + 1), vis(n + 1);
	vector<vector<int> > edge(n + 1);
	for (int i = 1, x, y; i < n; i++) {
		cin >> x >> y;
		edge[x].push_back(y);
		edge[y].push_back(x);
		leaf[x]++;
		leaf[y]++;
	}
	queue<int> q;

	for (int i = 1; i <= n; i++) {
		if (leaf[i] == 1) 	q.push(i);
	}
	int y;
	while (!q.empty()) {
		y = q.front();
		q.pop();
		vis[y] = 1;
		for (int i = 0; i < (int)edge[y].size(); i++) {
			int x = edge[y][i];
			if (vis[x] == 0) {
				white[x] = mod(white[x], white[y] + black[y]);
				black[x] = mod(black[x], white[y]);
				leaf[x]--;
			}
			if (leaf[x] == 1  && vis[x] == 0) q.push(x);
		}
	}

	ll ans = (white[y] + black[y]) % MOD;
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 12676
#include <bits/stdc++.h>
using namespace std; 
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int x;
	cin>>x;
	int i=1,j=360;
	while(1){
		if(j==i*x){
			cout<<i<<endl;
			return 0;
		}
		if(j<i*x)j+=360;
		i++;
	}
    return 0; 
}/*
*/

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string w;
	map<char, int> cnt;
	bool ans = true;

	for (char c = 'a'; c <= 'z'; c++) cnt[c] = 0;

	cin >> w;
	rep(i, (int)w.length()) cnt[w[i]]++;

	for (char c = 'a'; c <= 'z'; c++) {
		if (cnt[c] % 2 != 0) ans = false;
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string>
#include<cmath>
int main(){
    int N,K;
    double p[200000];
    scanf("%d %d",&N,&K);
    for(int a=0;a<N;a++){
        scanf("%lf",&p[a]);
        p[a]=(p[a])*(p[a]+1.0)/(2*p[a]);
    }
    int x=K;
    double ans=0;
    for(int m=0;m<x;m++){
        ans+=p[m];
    }
    int dec=0;
    double max=ans;
    for(int d=x;d<N;d++){
        ans+=p[d];
        ans-=p[dec];
        dec++;
        if(max<ans){
            max=ans;
        }
    }
    printf("%lf",max);
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <climits>
using namespace std;

int main() {
    int n, top[100], bottom[100], dp[100][100];
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> top[i] >> bottom[i];
    }
    for (int i=1; i<=n; ++i) {
        for (int j=0; j+i-1<n; ++j) {
            dp[j][j+i-1] = INT_MAX;
            if (j == j+i-1) {
                dp[j][j+i-1] = 0;
            } else {
                for (int k=j; k<j+i-1; ++k) {
                    dp[j][j+i-1] = min(dp[j][j+i-1], dp[j][k] + dp[k+1][j+i-1] + top[j] * bottom[k] * top[k+1] * bottom[j+i-1]);
                }
            }
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}

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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int o = 0;
    string s;
    cin >> s;
    
    while(s.size()>1){   
        bool f = false;
        for (int i = 0; i < s.size()-1; ++i){
            if(s[i] != s[i+1]){
                s.erase(i, 2);
                o++;
                f = true;
                break;
            }
        }
        if(!f)
            break;
    }
    cout << 2*o << endl;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**6)

N = int(input())
ABC = [list(map(int, input().split())) for _ in range(N - 1)]
Q, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(Q)]

G = [[] * N for _ in range(N)]
for a, b, c in ABC:
  G[a - 1].append((b - 1, c))
  G[b - 1].append((a - 1, c))

D = [-1] * N

def dfs(v, d):
  D[v] = d
  for i, c in G[v]:
    if D[i] < 0:
      dfs(i, d + c)

dfs(K - 1, 0)

for x, y in XY:
  print(D[x - 1] + D[y - 1])

Measured memory_bytes: 175772
#include<bits/stdc++.h>
using namespace std;
int N,M,R=10000;
vector<int>V;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>N>>M;
    for(int i=1;i<=N;i++)
    {
        int T,O;
        cin>>T>>O;
        if(O<=M)
            R=min(R,T);
    }
    if(R==10000)cout<<"TLE";
    else cout<<R;
}


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


int top, S[1000];

void push(int x)
{
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];

	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			a = pop();
			b = pop();
			push(b - a);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a*b);
		}
		else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	return 0;
}



Measured memory_bytes: 2124
import sys
fastinput=sys.stdin.readline
N,T=map(int,fastinput().split())
p=[int(_) for _ in fastinput().split()]
oyumin=0
oyumax=0
Showertime=0
for i in p:
    if i>oyumax:
        Showertime+=oyumax-oyumin
        oyumin=i
        oyumax=i+T
    else:
        oyumax=i+T
Showertime+=oyumax-oyumin
print(Showertime)

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int w, h, n;
  cin >> w >> h >> n;
  int lx = 0, ly = 0, rx = w, ry = h;
  rep(i, n) {
    int x, y, a;
    cin >> x >> y >> a;
    if(a == 1) lx = max(lx, x);
    if(a == 2) rx = min(rx, x);
    if(a == 3) ly = max(ly, y);
    if(a == 4) ry = min(ry, y);
  }
  if(rx < lx || ry < ly) cout << 0 << endl;
  else cout << (rx - lx) * (ry - ly) << endl;

  return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = [int(coodinate) for coodinate in input().split()]
d_x = tx - sx
d_y = ty - sy

route = []
route.append('U' * d_y + 'R' * d_x)
route.append('D' * d_y + 'L' * d_x)
route.append('L' + 'U' * (d_y + 1) +
    'R' * (d_x + 1) + 'D')
route.append('R' + 'D' * (d_y + 1) + 'L' * (d_x + 1)
    + 'U')

ans = ''.join(route)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main () {
    long double A, B, H, M;
    cin >> A >> B >> H >> M;
    long double pi = 3.141592653589793238462;
    long double aa = 5.5 * M - 30 * H;
    long double angle = abs(aa);
    long double X = pow(A, 2) + pow(B, 2) - 2 * A * B * cos(pi / 180.0000000000 * angle);
    cout << setprecision(11);
    cout << sqrt(X) << endl;

}


Measured memory_bytes: 4112