akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))


N = ii()
A, B = mi()

for i in range(A, B+1):
    if not i % N:
        print('OK')
        exit()
print('NG')

Measured memory_bytes: 9220
//  [[8] {} [24]] ->  MAMBA FOREVER.

#include<bits/stdc++.h>
using namespace std;

typedef long double ld;
#define int long long
#define RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i <n; i++)
#define repv(i,k,n) for(i=k; i<n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define endl '\n'
int mod = 1e9+7;
int power(int x,int n)
{   if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;   return (y*y)%mod;   }
    if(n&1)     {   int y =  power(x,n-1);  return (x%mod * y%mod)%mod; }
}
const int maxn = 200005;
//  --------------------------------------------------------------------
void solve()
{
    int n,i,j,k,m;
    cin>>n;
    int ar[n];
    rep(i,n)
        cin>>ar[i];
    if(n<=1)
    {   cout<<0;    exit(0);}
    if(n==2)
    {   cout<<abs(ar[1]-ar[0]); exit(0);}
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(ar[1] - ar[0]);

    for(i=2; i<n; i++)
    {
        dp[i] = min( abs(ar[i] - ar[i-1]) + dp[i-1] , abs(ar[i]-ar[i-2]) + dp[i-2] );
    }
    //  for(i=0; i<n; i++)
    //  cout<<dp[i]<<" ";
    //  cout<<endl;
    cout<<dp[n-1];
}
signed main()
{
    RAGE;
    
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 1792
// ABC060B - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	for (int i = 1; i <= 100; i++) {
		if (i * A % B == C) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
//Subhash Suman
//Date: 21/02/19 ; Day: Thursday ; Time: 21::50::47 
//Description : 

#include<bits/stdc++.h>
#define ll long long int
#define MAX INT_MAX
#define MIN INT_MIN
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>

using namespace std;
const int N = 2e5+5;
int a1[N];
ll tree[4*N],dp[N],a2[N];
int n;

void buildTree(int s=1,int e=n,int index=1){
    if(s>e){
        return;
    }
    if(s==e){
        tree[index]=dp[s];
        return;
    }
    int mid = (s+e)/2;
    buildTree(s,mid,2*index);
    buildTree(mid+1,e,2*index+1);
    // as it is a max tree so max is used
    tree[index] = max(tree[2*index],tree[2*index+1]);
    return;
}

ll query(int qs,int qe,int s=1,int e=n,int index=1){
    if(qe<s || qs>e || s>e){
        return MIN*1LL;
    }
    if(qs<=s && qe>=e){
        return tree[index];
    }
    int mid = (s+e)/2;
    ll q1 = query(qs,qe,s,mid,2*index);
    ll q2 = query(qs,qe,mid+1,e,2*index+1);
    return max(q1,q2);
}

//add value to elm at pos i in dp
void update(int i,ll value,int s=1,int e=n,int index=1){
    if(s>e || s>i || e<i){
        return;
    }
    if(s==e && s==i){
        tree[index]+=value;
        return;
    }
    int mid = (s+e)/2;
    update(i,value,s,mid,2*index);
    update(i,value,mid+1,e,2*index+1);
    tree[index] = max(tree[2*index],tree[2*index+1]);
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);   
    cin>>n;
    for(int i = 0; i < n; i++){
        cin>>a1[i];
    }
    for(int i = 0; i < n; i++){
        cin>>a2[i];
    }
    buildTree();
    for(int i = 0; i < n; i++){
        ll q = max(query(1,a1[i]-1),0LL);
        dp[a1[i]] = q + a2[i];
        //cout<<dp[a1[i]]<<'\n';
        update(a1[i],dp[a1[i]]);
    }
    cout<<query(1,n)<<'\n';
    return 0;
}

Measured memory_bytes: 9216
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}


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

    vector<int> cost = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    int n, m;
    cin >> n >> m;
    vector<int> num(8);
    rep(i, m){
        int a;
        cin >> a;
        num[cost[a]] = max(num[cost[a]], a);
    }

    vector<string> dp(n + 1, "0");
    dp[0] = "";
    rep(i, n){
        rep(j, 8){
            if(i + j > n || num[j] == 0 || dp[i] == "0"){
                continue;
            }
            string s = dp[i];
            s.push_back(num[j] + '0');

            if(dp[i+j] == "" || SZ(dp[i+j]) < SZ(s) || dp[i+j] < s){
                dp[i+j] = s;
            }
        }
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 30336
from itertools import groupby, accumulate, product, permutations, combinations
def calc(x,X):
  n = len(x)
  ans = 10**10
  for q in product([0,1],repeat=n):
    point = 0
    cnt = 0
    for i in range(n):
      if q[i]==1:
        if cnt>0:
          point += 10
        cnt += x[i]
    if cnt>0:
      point += abs(cnt-X)
    else:
      point = 10**10
    ans = min(point,ans)
  return ans

def solve():
  ans = 10**10
  N, A, B, C = map(int, input().split())
  L = [int(input()) for _ in range(N)]
  for p in product(['A','B','C','D'],repeat=N):
    a,b,c = [],[],[]
    cnt = 0
    for i in range(N):
      if p[i]=='A':
        a.append(L[i])
      elif p[i]=='B':
        b.append(L[i])
      elif p[i]=='C':
        c.append(L[i])
    cnt += calc(a,A)+calc(b,B)+calc(c,C)
    ans = min(ans,cnt)
  return ans
print(solve())

Measured memory_bytes: 76388
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ans = -2e18;
    ans = max(ans, a*1ll*c);
    ans = max(ans, a*1ll*d);
    ans = max(ans, b*1ll*c);
    ans = max(ans, b*1ll*d);
    printf("%lld\n", ans);
}

Measured memory_bytes: 3760
using System;
class aoj{
	static void Main(){
		string []d=Console.ReadLine().Split(' ');
		int []a=new int[2];
		for(int i=0;i<2;i++){
		a[i]=int.Parse(d[i]);
		}
		int b=a[0]*a[1];
		int c=a[0]*2+a[1]*2;
		Console.WriteLine("{0} {1}",b,c);
	}
}

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

int main(){
    long long a,b,x;
    cin>>a>>b>>x;
    long long ans;
    if(a==0){
        ans=b/x+1;
    }else{
        ans=b/x+1-((a-1)/x+1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
long long int solve(int**schedule,long long int**p,vector<int>d,int n,int day,bool check){
  if(day==10){
    if(!check){
	return -1000000000;
    }
    long long int ans=0;
    for(int i=0;i<n;i++){
      ans+=p[i][d[i]];
    }
    return ans;
  }
  long long int ans=solve(schedule,p,d,n,day+1,check);
  for(int i=0;i<n;i++){
    d[i]+=schedule[i][day];
  }
  long long int ans2=solve(schedule,p,d,n,day+1,true);
  if(ans < ans2)return ans2;
  return ans;
}
int main(void){
  int n=0;
  cin>>n;
  int**schedule=new int*[n];
  long long int**p=new long long int*[n];
  for(int i=0;i<n;i++){
    schedule[i]=new int[10];
    p[i]=new long long int[11];
    for(int j=0;j<10;j++){
      cin>>schedule[i][j];
    }
  }
  vector<int>d(n);
  for(int i=0;i<n;i++){
    d[i]=0;
    for(int j=0;j<=10;j++){
      cin>>p[i][j];
    }
  }
  cout<<solve(schedule,p,d,n,0,false)<<endl;
  return 0;
}
  

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
const char E = '\n';
const int N = 100005;
const ll mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie(0);
    ll x, a, y, b, c, p[N], q[N], r[N], in1, in2, ans = 0;
    multiset <int> s;
    cin >> x >> y >> a >> b >> c;
    for (int i=1; i<=a; i++) {
        cin >> p[i];
    }
    for (int i=1; i<=b; i++) {
        cin >> q[i];
    }
    for (int i=1; i<=c; i++) {
        cin >> r[i];
    }
    sort (p+1, p+1+a);
    sort (r+1, r+1+c);
    sort (q+1, q+1+b);
    p[a+1] = 1e9+1;
    q[b+1] = 1e9+1;
    in1 = a-x+1; in2 = b-y+1;
    for (int i=in1; i<=a; i++) {
        ans += p[i];
        s.insert (p[i]);
    }
    for (int i=in2; i<=b; i++) {
        ans += q[i];
        s.insert (q[i]);
    }
    for (int i=1; i<=c; i++) {
        int v = *s.begin();
        if (r[i] <= v) continue;
        ans += r[i]-v;
        s.erase (s.find(v));
        s.insert (r[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 11008
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

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

    int a, b, c;
    cin >> a >> b >> c;

    cout << (a + b + c >= 22 ? "bust" : "win") << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define vll vector<ll>
#define sz size()
#define pb emplace_back
#define mp make_pair
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL))
const int N = 100005;

int main()
{
	ll a,b;
	cin>>a>>b;
	if(a>=1 && a<=9 && b>=1 && b<=9)
	cout<<a*b;
	else
	cout<<"-1";
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define swap(a,b) a^=b^=a^=b

int main(){

  int length, i, j, a[N], flag = 0;

  scanf("%d", &length);
  for(i = 0; i < length; i++) scanf("%d", &a[i]);

  for(i = 0; i < length - 1; i++){
    for(j = length - 1; j >= i + 1; j--){
      if(a[j] < a[j-1]){
	swap(a[j], a[j-1]);
	flag++;
      }
    }
  }

  for(i = 0; i < length; i++){
    printf("%d", a[i]);
    if(i != length - 1) printf(" ");
  }
  printf("\n%d\n", flag);

  return 0;
}

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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;
int ans = 0;
int t;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	else return(gcd(y, x%y));
}

int main() {
	cin >> t;
	for (int _ = 0; _ < t; _++) {
		ll a, b, c, d;
		bool flg = false;
		cin >> a >> b >> c >> d;
		if (a >= b && d >= b) {
			ll cd = gcd(b, d);
			if (c >= a - cd * ((a - b) / cd + 1))flg = true;
		}
		if (flg) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define mod 1000000007 //1e9+7
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  i,j,n,k,cnt=0;
    string s;
    cin>>s;
    for(i=0; s[i]; i++)
        if(s[i]=='x')
            cnt++;
    if(cnt>=8)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;
import java.util.ArrayList;

public class Main{
 public static void main(String[] args){
  Scanner sc=new Scanner(System.in);
  ArrayList<Integer> ave=new ArrayList<Integer>();
  int n;
  do{
  int max=1000,min=0,counter_M=0,counter_m=0;
  int sum=0;
  n=sc.nextInt();
  for(int k=0;k<n;k++){
    int s=sc.nextInt();
    sum+=s;
    if(max<=s||counter_M==0){
      max=s;
      counter_M=1;
    }
    if(min>=s||counter_m==0){
      min=s;
      counter_m=1;
    }
  }
  double ave_s=(double)(sum-max-min)/(double)(n-2);
  ave.add((int)ave_s);
}while(n!=0);
for(int j=0;j<ave.size()-1;j++){
  System.out.println(ave.get(j));
}
}
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e9;
const int MOD = 1e9+7;

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; }


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N; cin >> N;
    vi A(N); REPS(i, N-1) cin >> A[i];
    vi B(N); REPS(i, N-1) B[A[i]-1]++;
    REP(i, B.size()) cout << B[i] << endl;
}

Measured memory_bytes: 6368
//おまじない
//#include <bits/stdc++.h>
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ‘ ‘
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn=100000;
ll n,c;
ll x[maxn],v[maxn];
ll cws[maxn],cbs[maxn+1];
vector<pair<ll,ll> > cwm(maxn),cbm(maxn+1);

int main(){

  cin >> n>>c;
  rep(i,n){
    cin >> x[i]>>v[i];
  }

  //時計回りの差し引きを求める
  cws[0]=v[0];
  cwm[0]=make_pair(cws[0]-x[0],x[0]);

  for(int i=1;i<n;i++){
    cws[i]=cws[i-1]+v[i];
    if(cwm[i-1].first<cws[i]-x[i]){
      cwm[i]=make_pair(cws[i]-x[i],x[i]);
    }else{
      cwm[i]=cwm[i-1];
    }
  }
  cbs[n]=0;
  cbm[n]=make_pair(0,0);
  cbs[n-1]=v[n-1];
  cbm[n-1]=make_pair(cbs[n-1]-(c-x[n-1]),c-x[n-1]);
    for(int i=n-2;i>=0;i--){
      cbs[i]=cbs[i+1]+v[i];
      if(cbm[i+1].first<cbs[i]-(c-x[i])){
	cbm[i]=make_pair(cbs[i]-(c-x[i]),c-x[i]);
      }else{
	cbm[i]=cbm[i+1];
      }

    }

    ll ans=max((ll)0,cbm[0].first);

    for(int i=n;i>0;i--){
      ans=max(ans,max(cbm[i].first+cwm[i-1].first-cbm[i].second,cbm[i].first+cwm[i-1].first-cwm[i-1].second));
    }

    cout << ans<<endl;

  return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>

int main ()
{
    long long x,t,f,h;
    while (scanf ("%lld",&x)  !=EOF)
    {
        t=x/500;
        h=t*1000;
        f=(x-t*500)/5;
        h=h+5*f;
        printf("%d\n",h);
    }
    return 0;
}


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

// 方針：-1が出力されることはない。
// 普通に数えて終わり。

int step (int L) {
  string S = to_string(L);
  int res = 0;
  for (auto i=1; i<S.size(); i++) {
    int I1 = stoi(S.substr(0, i));
    int I2 = stoi(S.substr(i, S.size()-i));
    int temp = I1 * I2;
    // cerr << "I1 = " << I1 << ", I2 = " << I2 << ", temp = " << temp << endl;
    if (res < temp) res = temp;
  }
  return res;
}

int count_step (int L) {
  int res = 0;
  for ( ; L>=10 ; res++) {
    // cerr << "res = " << res << endl;
    L = step(L);
  }
  return res;
}

int main() {
  int Q;
  cin >> Q;
  for (auto i=0; i<Q; i++) {
    int N;
    cin >> N;
    cout << count_step(N) << endl;
  }
}

Measured memory_bytes: 1244
#include <iostream>

using namespace std;

int main(void)
{
    int N, D, X;
    cin >> N; cin >> D; cin >> X;

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        ans += (D - 1) / A + 1;
    }
    ans += X;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import itertools
n = int(input())
P = list(map(str, input().split()))
Q = list(map(str, input().split()))
p = ''
for e in P:
  p += e
p = int(p)
q = ''
for e in Q:
  q += e
q = int(q)
l = [str(i) for i in range(1, n + 1)]
r = itertools.permutations(l, n)
a = []
for v in r:
  s = ''
  for e in v:
    s += e
  s = int(s)
  a.append(s)
print(abs(a.index(p) - a.index(q)))

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

using namespace std;

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

typedef long long ll;

const int N = 2200;
const ll INF = 1e18;
const ll BRD = 1e10;

vector<ll> pr;

void delCubes(ll& v) {
  for (ll p : pr) {
    while (v % (p * p * p) == 0) {
      v /= (p * p * p);
    }
  }
}

ll getPair(ll v) {
  __int128 res = 1;
  for (__int128 p : pr) {
    if (v % (p * p) == 0) {
      res = res * p;
      v /= (p * p);
    }
    else if (v % p == 0) {
      res = res * p * p;
      v /= p;
    }
  }
  if (v != 1) {
    __int128 sq = sqrt(v);
    while (sq * sq < v) sq++;
    while (sq * sq > v) sq--;
    if (sq * sq == v) {
      res = res * sq;
    }
    else {
      res = res * v * v;
    }
  }
  if (res <= BRD) return res;
  else return INF;
}

void solve() {
  int n; cin >> n;
  unordered_map<ll, int> mp;
  for (int i = 0; i < n; i++) {
    ll v; cin >> v;
    delCubes(v);
    mp[v]++;
  }
  ll ans = (mp[1] > 0);
  mp.erase(1);
  for (auto x : mp) {
    ll v = x.first, res = x.second;
    ll nv = getPair(v);
    //cout << v << " " << nv << endl;
    if (mp.count(nv) == 0) {
      ans += res;
    }
    else if (res > mp[nv] || res == mp[nv] && v < nv) {
      ans += res;
    }
  }
  cout << ans;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

bool prime(ll p) {
  for (int mul = 2; mul * mul <= p; mul++)
    if (p % mul == 0) return false;
  return true;
}

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  for (int p = 2; p < N; p++) {
    if (prime(p))
      pr.push_back(p);
  }
  solve();
}


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

#define p_ary(ary,a,b,i) do { cout << "["; for (int i = a;i <= b;++i) cout << ary[i] << (b == i ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto it = map.begin();;++it) {if (it == map.end()) {cout << "}\n";break;}else cout << "" << it->first << "=>" << it->second << ", ";}}while(0)

typedef long long ll;

const ll mod = 1e9+7;

const int MAX_N = 100010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow(ll a,ll b) {
    ll ret;
    if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void create_table(int n) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= n;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[n] = pow(fact[n],mod-2);
    for (int i = n;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= n;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

int main() {
    int n,a[100010];
    cin >> n;
    for (int i = 0;i < n;++i) cin >> a[i];
    create_table(n);
    inv[0] = 0;
    for (int i = 0;i < n;++i) {
        inv[i+1] += inv[i];
        inv[i+1] %= mod;
    }
    ll ans = 0;
    //p_ary(inv,0,n,i);
    for (int i = 0;i < n;++i) {
        ans += (inv[n-i]+inv[i+1]-1)%mod*a[i]%mod;
        ans %= mod;
    }
    cout << ans*fact[n]%mod << endl;
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n,x,t;
    cin >> n >> x  >> t;
    int ans = n/x*t;
    if(n%x != 0) ans += t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3676
A,B,M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = 0
m += min(a)
m += min(b)
waribiki= [[0,0,0]for i in range(M)]
for i in range(M):
    waribiki[i] = list(map(int, input().split()))
for i in range(M):
    S = a[waribiki[i][0]-1] +b[waribiki[i][1]-1] - waribiki[i][2]
     
    if m> S:
        m = S
print(m)

Measured memory_bytes: 38372
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;


vector<int> MonSat;
//300000までの月曜土曜素数を列挙
void Sieve_of_Eratosthenes(){
	int n=300001;
    bool list[n]; rep(i,n) list[i]=1; //全数にフラグ
	//6の倍数,8の倍数…と削っていく
    for(int i=6;i<n;i++){
		if(i%7!=1&&i%7!=6) list[i]=0;
        if(list[i]){
            for(int j=2;i*j<n;j++) list[i*j]=0;
        }
    }
	//フラグが立っていれば月曜土曜素数
    for(int i=6;i<n;i++){
        if(list[i]) MonSat.push_back(i);
    }
}

int main(){
	Sieve_of_Eratosthenes();
	int n;
	while(cin>>n&&n!=1){
		cout<<n<<":";
		for(int i=0;i<(int)MonSat.size();i++){
			if(n%MonSat[i]==0){
				cout<<" "<<MonSat[i];
			}
		}
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 3524
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

//lli gcd(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    if(x%y==0){
//        return y;
//    }
//    else{
//        return gcd(y,x%y);
//    }
//}
//
//lli lcm(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    return x*y/gcd(x,y);
//}

struct work{
    lli w;
    lli t;
    bool operator<(const work &another)const{
        return t<another.t;
    }
};

int main(){
    lli a,n,b[3];
    string ans="Yes";
    map<lli,lli> map;
    lli i,j;
    cin>>n;
    rep(i,0,n){
        cin>>a;
        map[a]++;
    }
    switch(map.size()){
        case 1:
            if(map[0]!=n){
                ans="No";
            }
            break;
        case 2:
            if(n%3!=0){
                ans="No";
            }
            else{
                if(map[0]!=n/3){
                    ans="No";
                }
            }
            break;
        case 3:
            if(n%3!=0){
                ans="No";
            }
            else{
                j=0;
                for(auto itr=map.begin();itr!=map.end();itr++){
                    b[j]=itr->first;
                    if(itr->second!=n/3){
                        ans="No";
                    }
                    j++;
                }
                b[1]^=b[2];
                if(b[0]!=b[1]){
                    ans="No";
                }
            }
            break;
        default:ans="No";break;
    }
    cout<<ans<<endl;
}


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

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int ans = min(k, n)*x + max(n-k, 0)*y;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    set<string> st;
    rep(i, n) {
        string s;
        cin >> s;
        st.insert(s);
    }
    
    out(st.size());
    re0;
}

Measured memory_bytes: 19256
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let mut s: std::collections::VecDeque<char> = it.next().unwrap().chars().collect();
    let q: usize = it.next().unwrap().parse().unwrap();
    let mut rev = 0;
    for _ in 0..q {
        let op: usize = it.next().unwrap().parse().unwrap();
        if op == 1 {
            rev ^= 1;
        } else {
            let f = it.next().unwrap().parse::<usize>().unwrap() - 1;
            let c = it.next().unwrap().chars().next().unwrap();
            if rev ^ f == 0 {
                s.push_front(c);
            } else {
                s.push_back(c);
            }
        }
    }
    let ans: String = if rev == 1 {
        s.into_iter().rev().collect()
    } else {
        s.into_iter().collect()
    };
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 10492
while True:
    try:
        l = list(map(int, input().split(",")))
    except:
        break
    sum_l = sum(l[:10])
    M = sum_l*l[10]/(l[10] + l[11])
    for i in range(10):
        M -= l[i]
        if M <= 0:
            print(i+1)
            break




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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    int *a = new int[n]{0};
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
    }

    sort(a,a+n);
    int *dp = new int[k+1]{0};
    fill(dp,dp+k+1,0);

    for(int i=1;i<=k;++i)
    {
        for(int j=0;j<n;++j)
        {
            if(a[j] > i)
                break;
            if(dp[i - a[j]] == 0)
                dp[i] = 1;
        }
    }
    if(dp[k] == 1)
    {
        cout<<"First"<<endl;
    }
    else
    {
        cout<<"Second"<<endl;
    }
    return 0;
}

Measured memory_bytes: 768
/*
Hanit Banga
*/

#include <iostream>
#include <vector>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

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

const int N = 1e5 + 5;

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

	int odd = 0;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		odd += a % 2;
	}	

	if (odd % 2)
		cout << "NO\n";

	else
		cout << "YES\n";
}

Measured memory_bytes: 384
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
using namespace std;

int n;
int a[100005];

//隣り合ってダメなやつはまとめて1回
//そうでなければ1つで1回

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(a[i] == i+1){
			if(i < n-1 && a[i+1] == i+2){
				ans += 1;
				i++;
			}else{
				ans += 1;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
    int H, W, N, Sx, Sy;
    cin >> H >> W >> N >> Sx >> Sy;
    string S, T;
    cin >> S >> T;

    bool flag = true; // true ならTの勝ち。つまりYes


    int down[202000]; //累積和にあたるもの
    int up[202000]; //初手で出れる場合があるんだよな
    int right[202000];
    int left[202000];
    for(int i=0; i<N; i++){
        down[i]=0;
        up[i]=0;
        right[i]=0;
        left[i]=0;
    }
    //向きに注意

    //下へ出れるか 
    //SからはDをTからはUを
    if(S.at(0)=='D'){
        down[0] =1;
    }
    for(int i=0; i<N-1; i++){
        down[i+1]=down[i];
        if(T.at(i)=='U' &&(Sx+down[i] >1) ) down[i+1]--;
        if(S.at(i+1)=='D' ) down[i+1]++;
    }
    //
    for(int i=0; i<N; i++){
        if(down[i] >= H+1-Sx){
            flag = false;
        }
    }

    //上へ出れるか
    if(S.at(0)=='U'){
        up[0] =1;
    }
    for(int i=0; i<N-1; i++){
        up[i+1] =up[i];
        if(T.at(i)=='D' &&(Sx-up[i] < H)) up[i+1]--;
        if(S.at(i+1)=='U' ) up[i+1]++;
    }
    //
    for(int i=0; i<N; i++){
        if(up[i] >= Sx){
            flag = false;
        }
    }

    //右へ出れるか
    if(S.at(0)=='R'){
        right[0] =1;
    }
    for(int i=0; i<N-1; i++){
        right[i+1] =right[i];
        if(T.at(i)=='L' && (Sy+right[i] >1)) right[i+1]--;
        if(S.at(i+1)=='R') right[i+1]++;
    }
    //
    for(int i=0; i<N; i++){
        if(right[i] >= W+1-Sy){
            flag = false;
        }
    }

    //左へ出れるか
    if(S.at(0)=='L'){
        left[0] =1;
    }
    for(int i=0; i<N-1; i++){
        left[i+1] =left[i];
        if(T.at(i)=='R' && (Sy -left[i] < W)) left[i+1]--;
        if(S.at(i+1)=='L') left[i+1]++;
    }

    //
    for(int i=0; i<N; i++){
        if(left[i] >= Sy){
            flag = false;
        }
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

typedef long long ll;
typedef long double ld;

int main()
{
  string S;

  cin >> S;

  if(S == "ABC"){
    cout << "ARC"<<endl;
  }else if(S == "ARC"){
    cout << "ABC"<<endl;
  }
  

  return 0;
}


Measured memory_bytes: 3592
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- VU.map pred . VU.fromList . map unsafeTextToInt . T.words <$> T.getLine :: IO (VU.Vector Int)
  let
    ls = VU.accumulate (+) (VU.replicate n 0) . VU.map (flip (,) 1) $ as :: VU.Vector Int
    m = VU.sum . VU.map comb $ ls :: Int
  VU.mapM_ print . VU.map ((m -) . pred . (ls VU.!)) $ as

comb :: Int -> Int
comb l = (l * pred l) `div` 2

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 14972
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

int main(){
  string s;
  string out = "";
  int n;
  while(cin >> s)
  {
    out = "";
    for(int i = 0; i < s.length(); i++)
    {
      if(s[i] == '@')
      {
       	i++;
        n = s[i] - '0';
        i++;
        for(int j = 0; j < n; j++)
        {
          out += s[i];
        }
      }
      else
      {
       	out += s[i];
      }
    }
    cout << out << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
n = int(input())
a1 = [int(v) for v in input().split(' ')]
a2 = [int(v) for v in input().split(' ')]

max_score = 0

for c in range(n):
    tmp_score = 0
    for i in range(c+1):
        tmp_score += a1[i]
    for i in range(c, n):
        tmp_score += a2[i]
    if tmp_score > max_score:
        max_score = tmp_score

print(max_score)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn for(int i=0;i<n;i++)
#define pb push_back
#define pob pop.back()
int main()
{
    int k;
    cin>>k;
   double ans=ceil(k/2);
   cout<<ans*(k-ans);
   return 0;
    
    
}

Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
inf = float("inf")
s = [["#"] * (W + 2)]
D = [[inf] * (W + 2)]
white_num = 0
for i in range(H):
    main = list(input())
    white_num += len([e for e in main if e == "."])
    s.append(["#"] + main + ["#"])
    D.append([inf] * (W + 2))
s.append(["#"] * (W + 2))
D.append([inf] * (W + 2))


def BFS():  # 幅優先探索
    global D
    D[1][1] = 1
    q = deque()
    q.append((1, 1))
    while len(q) != 0:
        p = q.popleft()
        for e in [(p[0] + 1, p[1]), (p[0], p[1] + 1), (p[0] - 1, p[1]), (p[0], p[1] - 1)]:
            if s[e[0]][e[1]] == "." and D[e[0]][e[1]] == inf:
                D[e[0]][e[1]] = D[p[0]][p[1]] + 1
                q.append(e)
                if e == (H, W):
                    return white_num - D[H][W]
    return -1


print(BFS())

# for i in range(1, H + 1):
#    print(" ".join(list(map(str, D[i][1:-1]))))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    ll K;
    cin >> K;

    int N = 50;
    ll a = (K + 49) / 50;
    K = a * 50 - K;

    cout << N << '\n';
    for (int i = 0; i < N; ++i) {
        ll tmp = a + N - 1 + K;
        cout << (i < K ? tmp - (N + 1) : tmp) << " ";
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector< vector<int> > dis(n);
    rep(i, n){
        dis[i].resize(n, 1e8);
        dis[i][i] = 0;
    }
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;    b--;
        dis[a][b] = 1;
        dis[b][a] = 1;
    }
    rep(k, n){
        rep(i, n){
            rep(j, n){
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }
    vector<int> path;
    for(int i = 1 ; i < n ; i++){
        path.push_back(i);
    }
    int ans = 0;
    do{
        int cnt = dis[0][path[0]];
        rep(i, n-2){
            cnt += dis[path[i]][path[i+1]];
        }
        if(cnt == n-1){
            ans++;
        }
    }while(next_permutation(path.begin(), path.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int N,K;cin>>N>>K;
  int bkt[100010];
  memset(bkt,0,sizeof(bkt));

  for(int i=0;i<N;i++){
    int a,b;cin>>a>>b;
    bkt[a]+=b;
  }

  int cont=0;
  for(int t=1;t<=100000;t++){
    cont+=bkt[t];
    if(K<=cont){
      cout<<t<<endl;
      return 0;
    }
  }

}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int a, b, c, i;
int main(){
cin>>a>>b>>c;
if (a==b)
  i++;
if (a==c)
  i++;
if (b==c)
  i++;
if (i==1)
  cout<<"Yes";
else 
  cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int N;
signed main(){
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  while(1){
    if(A.size()==1) break;
    sort(A.begin(),A.end());
    for(int i=1;i<A.size();i++){
      A[i]%=A[0];
      if(A[i]==0){
        A.erase(A.begin()+i);
        i--;
      }
    }
  }
  cout << A[0] << endl;
  return 0;
}


Measured memory_bytes: 1024
import math

input_line = input().split()
a = float(input_line[0])
b = float(input_line[1])
h = float(input_line[2]) + float(input_line[3]) / 60.0
m = float(input_line[3])

hour = [a * math.cos((3.0-h) / 6.0 * math.pi), a * math.sin((3.0-h) / 6.0 * math.pi)]
minute = [b * math.cos((15.0-m) / 30.0 * math.pi), b * math.sin((15.0-m) / 30.0 * math.pi)]

d = math.sqrt((minute[0]-hour[0])**2 + (minute[1]-hour[1])**2)

print(d)


Measured memory_bytes: 9524
score = []

while True:
    m, f, r = [int(i) for i in input().split()]
    if m == -1 and f == -1 and r == -1:
        break
    score.append([[m],[f],[r]])

for i in range(len(score)):
    if score[i][0][0] == -1 or score[i][1][0] == -1:
        print('F')
    elif score[i][0][0] + score[i][1][0] >= 80:
       print('A')
    elif score[i][0][0] + score[i][1][0] >= 65:
        print('B')
    elif score[i][0][0] + score[i][1][0] >= 50:
        print('C')
    elif score[i][0][0] + score[i][1][0] >= 30:
        print('C') if score[i][2][0] >= 50 else print('D')
    else:
        print('F')

Measured memory_bytes: 7704
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
using namespace std;

int main(){
  int N, L;
  cin >> N >> L;
  int sum = 0;  
  int min = abs(L);
  
  for(int i = 1; i <N; i++){
    if(abs(L + i) < abs(min)){
      min = L + i;
    }
  }
  cout << ((L + (L + N - 1))* N)/2  - min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n,m,p; cin>>n>>m>>p;
  vector<tuple<ll,ll,ll>> E;
  vector<vector<ll>> to(n),ot(n);
  vector<ll> state(n);
  rep(_,m){
    ll a,b,c; cin>>a>>b>>c;
    --a; --b;
    to[a].push_back(b);
    ot[b].push_back(a);
    E.emplace_back(a,b,p-c);
  }
  // dfs
  function<void(ll)> dfs=[&](ll v){
    if(state[v]&1) return;
    state[v]+=1;
    for(ll nv:to[v]) dfs(nv);
  };
  dfs(0);
  function<void(ll)> rdfs=[&](ll v){
    if(state[v]&2) return;
    state[v]+=2;
    for(ll nv:ot[v]) rdfs(nv);
  };
  rdfs(n-1);
  // Bellman-Ford
  vector<ll> d(n,INF);
  d[0]=0;
  rep(step,n){
    for(auto tup:E){
      ll a,b,c;
      tie(a,b,c)=tup;
      if(!(state[a]&1) || !(state[b]&2)) continue;
      if(chmin(d[b],d[a]+c) && step==n-1){
        cout<<-1<<"\n";
        return;
      }
    }
  }
  cout<<max(-d[n-1],(ll)0)<<"\n";
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N, AC=0, WA=0, TLE=0, RE=0;
  string jdg;
  
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> jdg;
    if(jdg == "AC"){
      AC += 1;
    }
    else if(jdg == "WA"){
      WA += 1;
    }
    else if(jdg == "TLE"){
      TLE += 1;
    }
    else{
      RE += 1;
    }
  }
  cout << "AC x " << AC <<endl;
  cout << "WA x " << WA <<endl;
  cout << "TLE x " << TLE <<endl;
  cout << "RE x " << RE <<endl;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES

#include <iostream>
#include <math.h> 
#include <vector>
#include <algorithm>
#include <iomanip>      // std::setprecision
#include <map>
#include <unordered_map>
#include <string>
#include <set>
#include <unordered_set>
#include <sstream>


using namespace std;

int main()
{
	int N;
	std::vector<int> nums;
	std::vector<int>sol;

	std::cin >> N;
	long long sum = 0;
	for (int i = 0; i < N; ++i)
	{
		int input;
		std::cin >> input;
		nums.push_back(input);
		sum += input;
	}
	long long odd_sum = 0;
	for (int i = 1; i < N; i+=2)
	{
		odd_sum += nums[i] * 2;
	}

	nums[0] = nums[0] - (sum - odd_sum)/2;
	std::cout << sum - odd_sum << " ";
	for (int i = 1; i < N; i++)
	{
		std::cout << nums[i-1] * 2 << " ";
		nums[i] -= nums[i - 1];
	}
}


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

int main(void)
{
  int n;
  std::cin >> n;

  bool flag = false;

  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i*j == n) {
        flag =true;
        break;
      }
    }
  }

  if (flag) {
    std::cout << "Yes" << std::endl;
  }
  else {
    std::cout << "No" << std::endl;
  }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse

#endif

namespace AGC008B
{
	void Run(void)
	{
		ll n, k; cin >> n >> k;
		vector<ll> a(n);
		rep(i, 0, n)
			cin >> a[i];

		ll l = 0;
		ll r = k - 1;
		vector<ll> ans_w(1);
		rep(i, 1, n)
			ans_w[0] += (0 < a[i] && k <= i) ? a[i] : 0;
		while (1)
		{	// 白く塗ったKマスをスライドさせて累積
			l++; r++;
			if (r == n)
				break;

			ans_w.push_back(ans_w.back());
			ans_w.back() += (0 < a[l - 1]) ? a[l - 1] : 0;
			ans_w.back() += (0 < a[r]) ? -a[r] : 0;
		}

		l = 0;
		r = k - 1;
		vector<ll> ans_b(1);
		rep(i, 0, n)
			ans_b[0] += (i < k) ? a[i] : (k <= i && 0 < a[i]) ? a[i] : 0;
		while (1)
		{	// 黒く塗ったKマスをスライドさせて累積
			l++; r++;
			if (r == n)
				break;

			ans_b.push_back(ans_b.back());
			ans_b.back() += (0 < a[l - 1]) ? 0 : -a[l - 1];
			ans_b.back() += (0 < a[r]) ? 0 : a[r];
		}

		cout << max(*max_element(all(ans_w)), *max_element(all(ans_b)));
	}
};

int main(void)
{
	AGC008B::Run();
	return 0;
}


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

int main(int argc, char const *argv[])
{
  int W, H, N;
  cin >> W >> H >> N;
  vector<int> x(N), y(N), a(N);
  for(int i = 0; i < N; i++)
    cin >> x[i] >> y[i] >> a[i];

  int xmin = W;
  int xmax = 0;
  int ymin = H;
  int ymax = 0;

  for(int i = 0; i < N; i++)
  {
    switch (a[i]) {
      case 1: if(x[i]>xmax)
                xmax = x[i];
              break;
      case 2: if(x[i]<xmin)
                xmin = x[i];
              break;
      case 3: if(y[i]>ymax)
                ymax = y[i];
              break;
      case 4: if(y[i]<ymin)
                ymin = y[i];
              break;
    }
  }

  if(xmin <= xmax || ymin <= ymax)
    cout << 0 << endl;
  else
    cout << (xmin - xmax)*(ymin - ymax) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << endl;}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	vi v(1010, -1);
	v[0] = 0;
	var(int, d, g);
	vi p(d), c(d);
	rep(i, 0, d) {
		cin >> p[i] >> c[i];
	}
	int sum_p = sum(all(p), 0);
	rrep(i, d - 1, -1) {
		rrep(j, sum_p, -1) {
			if (v[j] != -1) {
				rep(k, j + 1, j + p[i]) {
					chmax(v[k], v[k - 1] + (i + 1) * 100);
				}
				chmax(v[j + p[i]], v[j] + (i + 1) * 100 * p[i] + c[i]);
			}
		}
	}
	rep(j, 1, sum_p + 1) {
		if (v[j] >= g) {
			print(j);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 int main(void)
 {
     int N,i,j=0;
     char S[100];
     scanf("%d",&N);
     scanf("%s",S);
   
     for(i=0;i<N;i++){
       if(S[i]=='A'){
         if(S[i+1]=='B'){
           if(S[i+2]=='C') j++;
         }
       }
     }
     printf("%d\n",j);
     return 0;
 }


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a % 2 == 1 && b % 2 == 1) cout << "Odd" << endl;
    else cout << "Even" << endl;
}




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

int main() {
  
  int k,x;
  cin >> k >> x;
  
  for ( int i = 0; i < k * 2 - 1; i++){
    cout << x - ( k - 1 ) + i << " ";
  }
  
  cout << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

long long MOD = 1e9+7;
int MAX_INT = 1e9;

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

  string S;
  cin >> S;

  cout << S[0] << S[1] << S[2] << endl;

  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
 
int main()
{
 
  ll n, k;
  cin >> n >> k;
 
  ll total = 0;
  for (ll i = k; i < n + 1; i++)
  {
    ll max = (n + n - i + 1) * i / 2;
    ll min = (i - 1) * i / 2;
    ll val = max - min + 1;
 
    total += val;
    total %= MOD;
  }
 
  if (total < 0)
    total += MOD;
 
  total += 1;
  total %= MOD;
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 3628