akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

#define check cnt=0;for(j=0;j<6;j++)if(d1[j]==d2[j])cnt++;
#define r tmp=d2[1];d2[1]=d2[3];d2[3]=d2[4];d2[4]=d2[2];d2[2]=tmp;
#define y tmp=d2[0];d2[0]=d2[3];d2[3]=d2[5];d2[5]=d2[2];d2[2]=tmp;

int main(){
 int d1[6],d2[6],tmp,cnt,j,a=1,i,k;

 for(int i=0;i<6;i++){
  cin >> d1[i] ;
 }
 for(int i=0;i<6;i++){
  cin >> d2[i] ;
 }

 check
   if(cnt==6)a=0;

 while(a){
  for(i=0;i<5;i++){
   for(k=0;k<4;k++){
    check
    if(cnt==6)break;
    r
   }
   check
   if(cnt==6)break;
   tmp=d2[0];
   d2[0]=d2[1];
   d2[1]=d2[5];
   d2[5]=d2[4];
   d2[4]=tmp;
  }
  if(cnt==6)break;
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   r
  }
  if(cnt==6)break;
  y
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   r
  }
  a=0;
 }

 if(cnt==6)cout << "Yes" << endl ;
 else cout << "No" << endl ;

 return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>

int main()
{
    int h1, m1, h2, m2, k;
    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
    int ans = (h2 * 60 + m2) - (h1 * 60 + m1) - k;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1680
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>


//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll K;
ll cnt[10][100];
ll maxCnt[10][100];
ll total;
    
int main(){

    vll count;
    int K;
    cin >> K;

    for( int ni = 1 ; ni <10 ; ni++ ){
        count.push_back(ni);
    }

    ll val;
    rep(ni,K){
        val = count[ni];
        //cout << ni+1 << " : " << val << endl;
        //count.erase(count.begin());
        int key;
        key = val%10;
        if(key>0) count.push_back(val*10+(key-1));
        count.push_back(val*10+key);
        if(key<9) count.push_back(val*10+(key+1));
    }
    cout << val << endl;


}

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

int main(){
   string s;
   cin>>s;

   int a[200001];
   a[0]=0;

   long long ans=0;
   for (int i = 1; i < s.size(); ++i){
      if(s[i-1]=='B')
         a[i]=a[i-1]+1;
      else
         a[i]=a[i-1];

      if(s[i]=='W')
         ans+=a[i];

   }


   cout<<ans<<endl;


}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

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


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

    vi a = vi(3, 0);
    cin >> a[0] >> a[1] >> a[2];
    sort(ALL(a));

    string ans = "No";
    if (a[0] + a[1] == a[2]) {
        ans = "Yes";
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<climits>
using namespace std;
#define int long long
int solve(vector<int>&weights,vector<int>&values,int index,int max_weight,vector<vector<int>>&dp){
	if(max_weight<0)return LLONG_MIN;
	if(index==0||max_weight==0){
		return 0;
	}
	if(dp[index][max_weight]!=-1)return dp[index][max_weight];
	return dp[index][max_weight]=max(values[index-1]+solve(weights,values,index-1,max_weight-weights[index-1],dp),solve(weights,values,index-1,max_weight,dp));
}
int32_t main(){
	int n,w;
	cin>>n>>w;
	vector<int>weights(n);
	vector<int>values(n);
	for(int i=0;i<n;i++){
		cin>>weights[i];
		cin>>values[i];
	}
	vector<vector<int>>dp(n+1,vector<int>(w+1,-1));
	
	cout<<solve(weights,values,n,w,dp)<<endl;
	// for(auto i:dp){
	// 	for(auto j:i)cout<<j<<" ";
	// 	cout<<endl; 
	// }
}

Measured memory_bytes: 83100
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n;
	cin >> n;
	vector<ll> a(n);
	ll maxa = 0, ans = 0;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] < maxa) {
			ans += maxa - a[i];
			a[i] = maxa;
		}
		maxa = a[i];
	}
	cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> number(N);
  for(int i=0;i<N;i++){
    cin >> number.at(i);
  }
  sort(number.begin(), number.end());
  reverse(number.begin(), number.end());
  int Alice=0;
  int Bob=0;
  for(int i=0;i<N;i=i+2){
    Alice += number.at(i);
  }
  for(int i=1;i<N;i=i+2){
    Bob += number.at(i);
  }
  cout << Alice-Bob;
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    
    int a[n+1];
    f1(i,1,n+1)
    cin>>a[i];

    int ans = 0;
    int temp = 0, curr = 1;

    int vis[n+1];
    memset(vis, -1, sizeof vis);
    vis[1] = 0;
    int cyc = -1,start = -1;
    while(1)
    {
        curr = a[curr];
        temp++;
        // cout<<curr<<gp<<temp<<endl;
        if(temp == k)
        {
            cout<<curr<<endl;
            return 0;
        }
        else if(curr == a[curr])
        {
            cout<<curr<<endl;
            return 0;
        }
        if(vis[curr] >= 0)
        {
            k -= (vis[curr]);
            // cout<<vis[curr]<<endl;
            cyc = temp - vis[curr];
            start = curr;
            break;
        }
        vis[curr] = temp;
    }
    // cout<<cyc<<endl<<start<<endl;
    // cout<<temp<<endl;
    k %= cyc;
    if(k == 0)
    k+=cyc;

    // if(k == 0)
    // k += temp;
    memset(vis, -1, sizeof vis);
    vis[start] = 0, temp = 0;
    while(1)
    {
        curr = a[curr];
        temp++;
        if(temp == k)
        {
            cout<<curr<<endl;
            return 0;
        }
        else if(curr == a[curr])
        {
            cout<<curr<<endl;
            return 0;
        }
        if(vis[curr] >= 0)
        {
            k -= vis[curr];
            cyc = temp - vis[curr];
            start = curr;
            break;
        }
        vis[curr] = temp;
    }
    // cout<<k<<endl;
    // f1(i,1,n+1)
    // {
    //     if(vis[i] == k)
    //     {
    //         cout<<vis[i]<<endl;
    //         break;
    //     }
    // }
    return 0;
}

Measured memory_bytes: 6788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
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 const INF = 1001001001;


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

int n,k; cin >> n >> k;
vi a(n); rep(i,n) cin >> a[i];

ll s = 0;
rep(i,n) s += a[i];
vi v;
for(int i = 1; i * i <= s; ++i) {
    if(s % i == 0) {
        v.push_back(i);
        v.push_back(s/i);
    }
    if(i * i == s) v.pop_back();
}
int ans = 1;
for(auto g : v) {
    vi r(n);
    rep(i,n) r[i] = a[i] % g;
    sort(r.begin(), r.end());
    vi sr(n+1), sl(n+1);
    rep(i,n) sl[i+1] = sl[i] + r[i];
    drep(i,n) sr[i] = sr[i+1] + g - r[i];
    rep(i,n+1) {
        if(sl[i] == sr[i] && sl[i] <= k) {
            chmax(ans, g);
            break;
        }
    }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    long long x,n,i,a,sum=0;
    scanf("%lld%lld",&x,&n);
    for(i=0;i<n;i++){
        scanf("%lld",&a);
        sum+=a;
    }
    if(x<=sum) printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main()
{
    ll n, tmp;
    cin >> n;
    tmp = n;
    ll s=0;
    while(tmp>0)
    {
        s += tmp%10;
        tmp /= 10;
    }
    if(n%s == 0) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);++i)
#define FORALL(i, x) for(typeof((x).begin()) i=(x).begin();i!=(x).end();++i)
#define PB push_back
using namespace std;

vector<vector<int> > E;

int countChild(int n, int d, int p){
    int ret = 1;
    if(d > 0){
        FORALL(i,E[n]){
            if(*i == p) continue;
            ret += countChild(*i, d-1, n);
        }
    }
    return ret;
}

int main(){
    int N, K;
    cin >> N >> K;
    E = vector<vector<int> >(N);
    REP(i,N-1){
        int A, B;
        cin >> A >> B;
        A--; B--;
        E[A].PB(B);
        E[B].PB(A);
    }
    int ret = N;
    if(K % 2 == 0){
        REP(i,N){
            int tret = N - countChild(i, K/2, -1);
            ret = min(ret, tret);
        }
    }else{
        REP(i,N){
            FORALL(j,E[i]){
                if(i > *j) continue;
                int tret = N - countChild(i, K/2, *j) - countChild(*j, K/2, i);
                ret = min(ret, tret);
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll wq[100003];
int main()
{
    int g,t;
    ll re=1,lm=1e18;
    scanf("%d",&t);
    for(g=0;g<t;g++)
        scanf("%lld",&wq[g]);
    for(g=0;g<t;g++)if(!wq[g]){
        printf("0\n");
        return 0;
    }
    for(g=0;g<t;g++){
        if(wq[g]<=(lm/re))
            re*=wq[g];
        else{
            printf("-1\n");
            return 0;
        }
    }
    printf("%lld\n",re);
    return 0;
}


Measured memory_bytes: 4508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";
 
const ll inf = 1e18;
const ll N = 1e5 + 2;
 
ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}
 
ll vis[N] = {}, ans = 0;
 
void dfs(vlli v[], ll x){
    if(!vis[x]){
        vis[x]=1;
        forn(i, 0, v[x].size()){
            dfs(v, v[x][i]);
        }
    }
}
 
 
int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll n;
    cin>>n;
    ll m;
    cin>>m;
    vlli v[n+1];
    forn(i, 0, m){
        ll x, y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    ll f = 1;
    while(f){
        f=0;
        forn(i, 1, n+1){
            if(!vis[i]){
                f=1;
                ans++;
                dfs(v, i);
            }
        }
    }
    cout<<max(0ll, ans-1)<<endl;
 
}

Measured memory_bytes: 11108
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        char c = sc.next().toCharArray()[0];
        if('a'<=c && c<='z') {
            System.out.println('a');
        } else {
            System.out.println('A');
        }

    }

}

Measured memory_bytes: 35388
#include <cstdio>
#include <cstdlib>
#define INF (__INT32_MAX__ / 2);

using namespace std;

int main(int argc, char **argv) {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);

    printf("%d\n", b % a == 0 ? a + b : b - a);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define f first
#define s second
vector<int>g[200005];
signed main()
{
   int n;
   cin>>n;
   for(int i=2;i<=n;i++)
   {
       int j;
       cin>>j;
       g[j].pb(i);
   }
   for(int i=1;i<=n;i++)
    cout<<g[i].size()<<endl;
}


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

int main()
{
  int a, b, c;

  cin >> a >> b >> c;

  int k;
  cin >> k;

  for (int i = 0; i <= k; i++)
  {
    for (int j = 0; j <= k-i; j++)
    {
      for (int l = 0; l <= k-j; l++)
      {
        int a_tmp = a * pow(2,i);
        int b_tmp = b * pow(2,j);
        int c_tmp = c * pow(2,l);
        // cout << l << endl;
        if (c_tmp > b_tmp && b_tmp > a_tmp)
        {
          cout << "Yes";
          // cout << a_tmp << endl
          //      << b_tmp << endl
          //      << c_tmp << endl;
          return 0;
        }
      }
    }
  }

  cout << "No";
}


Measured memory_bytes: 4088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

            //long[] iti = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            /*
             * 
             * int a,b,c;
            a = int.Parse(Console.ReadLine()); //標準入力
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            b = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
            c = int.Parse(str[1]);
　　　　　　　Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
             * */
            long[] iti = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();

            long[] ni = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();

            long sann = long.Parse(Console.ReadLine()); // 制限秒数


            long ssss = iti[1] - ni[1]; // 追う速度

            long sss2 = 0;
            if (ni[0] <0)
            {
                if(iti[0] < 0)
                {
                    sss2 = (ni[0] * -1) - (iti[0] * -1);
                    sss2 = Math.Abs(sss2);
                }
                else
                {
                    sss2 = (ni[0] * -1) + iti[0];
                }
            }
            else
            {
                if (iti[0] < 0)
                {
                    sss2 = ni[0]+ (iti[0] * -1);
                }
                else
                {
                    sss2 = ni[0]- iti[0];
                }
            }
          

            if((ssss* sann) >= sss2)  // 速度*秒数 >= 距離 の時
            {
                Console.WriteLine("YES");
            } else
            {
                Console.WriteLine("NO");
            }

            //Console.Read();
        }
    }
}


Measured memory_bytes: 28248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
    int a,b;cin>>a>>b;
    if(b%a==0){
        cout<<a+b<<endl;
    }else{
        cout<<b-a<<endl;
    }
}


Measured memory_bytes: 256
N,K=map(int, input().split())
A=list(map(int, input().split()))
D,E=[],[]
zcnt,scnt,fcnt=0,0,0
for i in A:
  if i==0:
    zcnt+=1
    D.append(0)
  elif i>0:
    D.append(i)
    scnt+=1
  else:
    E.append(i)
    fcnt+=1
mod=10**9+7
ans=1
#全て使う場合は問答無用でかける
if K==N:
  for i in A:
    ans*=i
    ans%=mod
  print(ans)
  exit()
#マイナスを奇数個絶対かける→確実に答えはマイナス
if K%2==1 and max(A)<0:
  A=sorted(A)[::-1]
  for i in range(K):
    ans*=A[i]
    ans%=mod
  print(ans)
  exit()
#絶対0をかけなきゃいけない
if K>scnt+fcnt:
  print(0)
  exit()
D,E=sorted(D)[::-1],sorted(E)
#print(D,E)
ans=1
cnt=0
a,b=0,0
while K-cnt>1:
  if a+1<=len(D)-1 and b+1<=len(E)-1:
    d,e=D[a]*D[a+1],E[b]*E[b+1]
    if d>e:
      ans*=D[a]
      a+=1
      cnt+=1
      ans%=mod
    else:
      ans*=e
      b+=2    
      ans%=mod
      cnt+=2
  elif a+1<=len(D)-1:
    d=D[a]*D[a+1]
    ans*=D[a]
    a+=1
    cnt+=1
    ans%=mod
  elif b+1<=len(E)-1:
    e=E[b]*E[b+1]
    ans*=e
    b+=2
    cnt+=2
    ans%=mod

if K-cnt==1:
  Z=[]
  if a!=scnt:
    Z.append(D[a])
  if b!=fcnt:
    Z.append(E[-1])
  if 0 in A:
    Z.append(0)
  ans*=max(Z)
  ans%=mod
print(ans)

Measured memory_bytes: 31676
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// モジュール

bool found = false;

// ランレングス圧縮 O(N)
template <class RandomAccessIterator>
vector<ll> run_length(RandomAccessIterator first, RandomAccessIterator last) {
    vector<ll> rl;
    for (RandomAccessIterator itr = first; itr != last; ) {
        RandomAccessIterator jtr = itr++;
        while ((itr != last && *itr == *(itr-1))) itr++;
        rl.push_back(itr - jtr);
    }
    return rl;
}

// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, m; cin >> n >> m;
    string s; cin >> s;

    auto rl = run_length(ALL_OF(s));
    REP(i, rl.size()) {
        if (i % 2 == 0) continue;
        if (rl[i] >= m) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector<ll> ans; ans.reserve(n+1);
    ll i = n;
    while (i > 0) {
        RANGE(j, max(0LL, i-m), i-1) {
            if (s[j] == '0') {
                ans.push_back(i - j);
                i = j;
                break;
            }
        }
    }

    reverse(ALL_OF(ans));
    REP(i, ans.size()) cout << ans[i] << " \n"[i == i_len-1];

}

Measured memory_bytes: 1488
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> Q;

const int inf1=1e9+9;
const ll inf2=1e16+9;
const ll mol=1e9+7;
const int maxn=5e6+9;
const ll maxx=1e12+9;

string s;

int main()
{
    cin>>s;
    int cnt;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R') cnt=3;
    else if(s[0]=='S'&&s[1]=='S'&&s[2]=='S') cnt=0;
    else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R')) cnt=2;
    else cnt=1;
    printf("%d\n",cnt);
}


Measured memory_bytes: 3232
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
const double PI=3.1415926535897932384626;
double r,C;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>r;
	C=r*2*PI;
	printf("%.15lf",C);
	return 0;
}


Measured memory_bytes: 3760
using System;

class Program
{
    static void Main()
    {
        var S = Console.ReadLine();
        var T = Console.ReadLine();

        var result = 0;
        for (int i = 0; i <= S.Length - T.Length; i++)
        {
            var count = 0;
            for (int j = 0; j < T.Length; j++)
            {
                if (S[i + j] == T[j])
                {
                    count++;
                }
            }
            if (count > result)
            {
                result = count;
            }
        }
        Console.WriteLine(T.Length - result);
    }
}


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


int main(){
  int N,M;
  cin>>N>>M;
  vector<string> A(N);
  vector<string> B(M);
  for(int i = 0;i<N;i++){
    cin>>A.at(i);
  }
  for(int i = 0;i<M;i++){
    cin>>B.at(i);
  }
  string ans = "No";

  int stind2 = 0;
  for(int h = 0;h<(N-M+1);h++){
    int stind = 0;
  for(int i = 0;i<(N-M+1);i++){
    int c = 0;
    for(int j = 0; j < M; j++){
      string tmp ;
      for(int k = 0;k<M;k++){
        tmp.push_back(A.at(stind+j).at(stind2+k));
      }
      if(tmp==B.at(j))c++;
    }
    if(c==M){
      ans = "Yes";
      break;
    }
    stind++;
  }
    if(ans=="Yes")break;
    stind2++;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int> dp(n),h(n);
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
        if(i)
            dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
        for(int j=i-1;j>=i-k&&j>=0;j--)
        {
            dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976

int main(){
	lint a,b,c,k;cin>>a>>b>>c>>k;
	cout<<((k&1)?b-a:a-b)<<endl;
	getchar();
	getchar();
}

//int main(){//平方数を1<k<=nで割ったあまりを求める
//	lint n;cin>>n;
//	LIV ans(n);
//	for(int i=1;i<=n;++i){
//		set<int> s;
//		rep(x,i)s.insert(x*x%i);
//		cout<<i<<": ";
//		for(auto x:s)cout<<x<<",";cout<<endl;
//		ans[i-1]=s.size();
//	}rep(i,n)cout<<ans[i]<<endl;
//	getchar();
//	getchar();
//}

//sub-EOF


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
c = [False]*N
for i in range(N-1):
    if H[i] >= H[i+1]:
        c[i] = True

ans = 0
i = 0
while i < N:
    tmp = 0
    while c[i]:
        tmp += 1
        i += 1
    ans = max(ans, tmp)
    i += 1
print(ans)

Measured memory_bytes: 15020
#include <iostream>
#include <stdio.h>
#include<string>
using namespace std;

class Dice2{
public:
    Dice2(){
        number = new int[6];
        relative = new int[55];
        relative[31] = relative[43] = relative[24] = relative[12] = 0;
        relative[3] = relative[20] = relative[52] = relative[35] = 1;
        relative[1] = relative[40] = relative[54] = relative[15] = 2;
        relative[4] = relative[10] = relative[51] = relative[45] = 3;
        relative[2] = relative[30] = relative[53] = relative[25] = 4;
        relative[21] = relative[42] = relative[34] = relative[13] = 5;
     };
    ~Dice2(){
        delete[] number;
        delete[] relative;
    };

    void setNumber(int index,int num){
        number[index] = num;
    };

    int returnRight(int top,int front){
        int top_index,front_index;
        for(int i = 0; i < 6; i++){
            if(number[i] == top)
                top_index = i;
            if(number[i] == front)
                front_index = i;
        }
        return number[relative[10*top_index+front_index]];
    }
private:
    int* number;
    int* relative;
};

int main(int argc, const char * argv[]) {
   Dice2 dice2;
   int x,q,top,front;
   for(int i = 0; i < 6; i++){
       scanf("%d", &x);
       dice2.setNumber(i,x);
   }
   scanf("%d", &q);
   for(int i = 0; i < q; i++){
       scanf("%d %d", &top, &front);
       printf("%d\n", dice2.returnRight(top,front));
   }
    return 0;
}



Measured memory_bytes: 3184
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[3010][3010];
pair<int, int> pre[3010][3010];
const pair<int, int> NIL(-1, -1);

template <typename Type>
bool is_max(Type &a, Type b) {
    bool res = a < b;
    a = max(a, b);
    return res;
}

signed main() {
    string s, t; cin >> s >> t;
    int N = s.length(), M = t.length();

    fill(dp[0], dp[N+1], -1);
    fill(pre[0], pre[N+1], NIL);
    
    dp[0][0] = 0;
    for(int i=0; i<=N; i++) {
        for(int j=0; j<=M; j++) {
            if(dp[i][j] < 0) continue;
            if(i+1 <= N and is_max(dp[i+1][j], dp[i][j])) {
                // fprintf(stderr, "#debug 1: pre(%lld, %lld) = (%lld, %lld)\n", i+1, j, i, j);
                pre[i+1][j] = make_pair(i, j);
            }
            if(j+1 <= M and is_max(dp[i][j+1], dp[i][j])) {
                // fprintf(stderr, "#debug 2: pre(%lld, %lld) = (%lld, %lld)\n", i, j+1, i, j);
                pre[i][j+1] = make_pair(i, j);
            }
            if(i+1 <= N and j+1 <= M and s[i] == t[j] and is_max(dp[i+1][j+1], dp[i][j] + 1)) {
                // fprintf(stderr, "#debug 3: pre(%lld, %lld) = (%lld, %lld)\n", i+1, j+1, i, j);
                pre[i+1][j+1] = make_pair(i, j);
            }
        }
    }

    string ans = "";
    int x = N, y = M;
    while(make_pair(x, y) != NIL) {
        // fprintf(stderr, "x = %lld, y = %lld\n", x, y);
        if(x > 0 and y > 0 and s[x-1] == t[y-1]) ans += s[x-1];
        int nx, ny; tie(nx, ny) = pre[x][y];
        x = nx, y = ny;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 212352
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define int long long
using namespace std;

signed main() {
	int n;
	cin >> n;
	
	if (n / 100 == n % 10) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

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

#define ll long long int
#define ff(i,a,b) for(ll i = a; i < b; i++)
#define bf(i,b,a) for(ll i = b-1; i >= a; i--)
#define itf(i,a) for(auto i = a.begin(); i != a.end(); i++)
#define itfr(i,a) for(auto i = a.rbegin(); i != a.rend(); i++)
#define MII map<ll,ll> 
#define MCI map<char,ll>
#define MSI map<string,ll>
#define VI vector<ll> 
#define VC vector<char> 
#define VS vector<string> 
#define MP make_pair
#define tc ll t; cin>>t; while(t--)
#define DISPV(v) itf(i,v) cout << *i << ' ';
#define DISPM(m) itf(i,m) cout << i->first << ' ' << i->second << endl;

const int MOD = int(1e9) + 7;

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll n;
    cin >> n;
    ll x = n%1000;
    if(x == 0)
        cout << x;
    else
        cout << 1000 - x;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if ((a < c && c < b) || (b < c && c < a))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
typedef pair<pair<lint, int>, pair<int, int>> ppp;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 1e9 + 7;
const lint INF = mod;
const int MAX = 100010;

lint powmod(lint x, lint n){
    lint ret = 1;
    while(n > 0){
        if(n&1) ret *= x, ret %= mod, n -= 1;
        else x *= x, x %= mod, n >>= 1;
    }
    return ret;
}

vector<lint> fact;
vector<lint> revfact;

void setfact(int n){
    fact.resize(n+1); revfact.resize(n+1);
    fact[0] = 1;
    rep(i, n) fact[i+1] = fact[i] * (i+1) % mod;

    revfact[n] = powmod(fact[n], mod-2);
    for(int i=n-1; i>=0; i--) revfact[i] = revfact[i+1] * (i+1) % mod;
}

lint getC(int n, int r){
    return fact[n] * revfact[r] % mod * revfact[n-r] % mod;
}

int main(){
    int x, y;
    scanf("%d%d", &x, &y);
    int n=-x+2*y, m=2*x-y;
    if(n<0 || m<0 || n%3 || m%3){
        printf("%d\n", 0);
        return 0;
    }
    n/=3; m/=3;
    setfact(2000010);
    printf("%lld\n", getC(n+m, n));
}

Measured memory_bytes: 31488
N,Q=map(int,input().split())
graph=[[] for _ in range(N+1)]
for _ in range(N-1):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
data=[0 for i in range(N+1)]
visited=[False for i in range(N+1)]
for i in range(Q):
    p,x=map(int,input().split())
    data[p]+=x
    
from collections import deque
d=deque()
e=deque()
visited[1]=True
d.append(1)
while d:
    while d:
        x=d.popleft()
        adder=data[x]
        for node in graph[x]:
            if visited[node]==False:
                visited[node]=True
                data[node]+=adder
                e.append(node)
            else:
                pass
    if e:
        d=e
        e=deque()
print(*data[1:])


Measured memory_bytes: 137208
import math
import bisect


prime = [2]

tab = [False]*100001
tab[2] = True
for i in range(3,100000+1,2):

    x = int( math.sqrt(i) )
    x += 1 if x%2 == 0 else 0

    found = False
    for p in prime:
        if x < p:
            break;

        if i % p == 0:
            found = True
            break
                
    if not found:
        prime.append(i)
        tab[i] = True

#print(prime[0:10])
#print(tab[0:10])
q = int(input())

ac = [0] * len(tab)

for i in range(1,len(ac)):
    ac[i] = ac[i-1] + (1 if tab[i] and tab[(i+1)//2] else 0)

#print(ac)
for _ in range(q):

    l, r = map(int,input().split())
    
    ans = ac[r] - ac[l-1]

    print(ans)

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll now = 100;
  ll cnt = 0;
  while(now < n){
    cnt++;
    now += now/100;
  }
  cout<<cnt<<endl;
  return 0;
}

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

int main()
{
	int n, d, x;
	cin >> n >> d;
	x = n / ( d * 2 + 1 );
	if ( n % ( d * 2 + 1 ) != 0 )
		x++;
	cout << x << "\n"; 
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	int n, nowx = 0, nowy = 0, nowt = 0;
	cin >> n;
	REP(i, 0, n) {
		int t, x, y;
		cin >> t >> x >> y;
		if (abs(x - nowx + y - nowy) % 2 != abs(t - nowt) % 2) {
			printf("No\n");
			return 0;
		}
		if (abs(x - nowx) + abs(y - nowy) > abs(t - nowt)) {
			printf("No\n");
			return 0;
		}
		nowt = t;
		nowx = x;
		nowy = y;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#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;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}

Measured memory_bytes: 256
N,M,K=map(int,input().split())
mod=10**9+7
NM=N*M
kaijo=[0]*(NM+1)
gyaku=[0]*(NM+1)
kaijo[0]=1
for i in range(1,NM+1):
    kaijo[i]=kaijo[i-1]*i%mod
gyaku[NM]=pow(kaijo[NM],mod-2,mod)
for i in range(NM,0,-1):
    gyaku[i-1]=gyaku[i]*i%mod
C=kaijo[NM-2]*gyaku[K-2]*gyaku[NM-K]%mod
ans=0
for k in range(1,M):
    x=k*(M-k)*C*N*N%mod
    ans=(ans+x)%mod
for k in range(1,N):
    x=k*(N-k)*C*M*M%mod
    ans=(ans+x)%mod
print(ans)

Measured memory_bytes: 18804
#01:55
#UnionFind最適化に向けた実験
n,m,k = map(int,input().split())
cnt = [1 for _ in range(n)]
pre = [i for i in range(n)]
num = [1 for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  num[a] += 1
  num[b] += 1
  A = []
  B = []
  while a != pre[a]:
    a = pre[a]
    A.append(a)
  while b != pre[b]:
    b = pre[b]
    B.append(b)
  if a != b:
    if cnt[a] >= cnt[b]:
      pre[b] = a
      for aa in A:
        pre[aa] = a
      for bb in B:
        pre[bb] = a
      cnt[a] += cnt[b]
      cnt[b] = 0
    else:
      pre[a] = b
      for aa in A:
        pre[aa] = b
      for bb in B:
        pre[bb] = b
      cnt[b] += cnt[a]
      cnt[a] = 0
#print(pre)
#print(cnt)
root = []
ans = []
for i in range(n):
  I = int(i)
  while I != pre[I]:
    I = pre[I]
  root.append(I)
  ans.append(cnt[I]-num[i])
#print(root)
#print(ans)
for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  if root[a] == root[b]:
    ans[a] -= 1
    ans[b] -= 1
print(' '.join(map(str,ans)))

Measured memory_bytes: 20360
#include<stdio.h>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
    int a, b, x, y;
    scanf("%d%d%d%d", &a, &b, &x, &y);
    printf("%lf %d\n", double(a)*double(b) / 2, x + x == a&&y + y == b);
}

Measured memory_bytes: 128
unittest
{
	assert( [ "2 2" ].parse.expand.solve == 8 );
	assert( [ "3 2" ].parse.expand.solve == 12 );
	assert( [ "1 8" ].parse.expand.solve == 0 );
	assert( [ "100000 100000" ].parse.expand.solve == 530123477 );
}



import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	return tuple( nm[ 0 ], nm[ 1 ] );
}

const MOD = pow( 10L, 9 ) + 7;

auto solve( long n, long m )
{
	// 犬と猿の数の差を計算（差が2匹以上だったら交互に並べられない）
	auto d = ( n - m ).abs;
	if( 2 <= d ) return 0;
	
	// 順列を計算
	auto np = permutation( n );
	auto mp = permutation( m );
	
	// 犬と猿の組み合わせを計算
	auto nmp = ( np * mp ) % MOD;
	if( d == 0 ) nmp = ( nmp * 2 ) % MOD;		// 数の差が無い場合、犬が左端のパターンと猿が左端のパターンで2倍になる
	
	return nmp;
}

auto permutation( long x )
{
	static auto caches = [ 0L, 1L ];
	
	if( caches.length <= x )
	{
		auto h = caches.length;
		caches.length = x + 1;
		foreach( i; h .. caches.length )
		{
			caches[ i ] = ( caches[ i - 1 ] * i ) % MOD;
		}
	}
	
	return caches[ x ];
}


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

int main(void){
	long int n;
	long int check;
	int i;
	int j;
	long int count;
	long int k;

	int f[100000] = {};
	int c[1000] = {};
	scanf("%ld",&n);

	if(n==1){
		printf("Yes\n");
		printf("2\n");
		printf("1 1\n");
		printf("1 1\n");
		return 0;

	}




	i = 2;
	check = i * (i+1)/2;
	while(i * (i+1) / 2 <= n){
		if(check == n){
			printf("Yes\n");
			printf("%d\n",i+1);
			for(j=1;j<i+2;j++){

				printf("%d ",i);
				count = 0;
				k = 0;
				while(count < i){
					if(f[k] == 0){
						f[k] = j;
						if(count == i - 1){
							printf("%ld",k+1);
						}else{
							printf("%ld ",k+1);
						}
						count++;
					}else if(f[k] > 0 && c[f[k]] != j){
						c[f[k]] = j;
						f[k] = -1;
						if(count == i - 1){
							printf("%ld",k+1);
						}else{
							printf("%ld ",k+1);
						}
						count++;
					}
						k++;
					

				}
				printf("\n");

			}
			return 0;
		}

		i++;
		check = i * (i+1)/2;

	}

	printf("No\n");

	return 0;

}

Measured memory_bytes: 1664
n=gets.to_i
x=gets.split(" ").map(&:to_i)
ans = 1
flag = 0
for i in 0..n-1
	ans *= x[i]
	if ans>1000000000000000000
		ans = -1
		break
	end
end
for i in 0..n-1
	if x[i]==0
		ans=0
	end
end

puts ans

Measured memory_bytes: 21616
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define popb pop_back
#define all(A) A.begin(),A.end()
#define ansmod 1000000007
using namespace std;
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
int main() {
	int n,ans=0;
	cin>>n;
	vector<int> a(n),l(n),r(n);
	for(int i=0;i<n;i++) cin>>a[i];
	l[0]=0;
	for(int i=1;i<n;i++){
		l[i]=gcd(l[i-1],a[i-1]);
	}
	r[n-1]=0;
	for(int i=n-2;i>=0;i--){
		r[i]=gcd(r[i+1],a[i+1]);
	}
	for(int i=0;i<n;i++){
		ans=max(ans,gcd(l[i],r[i]));
	}
	cout<<ans<<"\n";
	// your code goes here
	return 0;
}

Measured memory_bytes: 1408
H,W,K,*s = open(0).read().split()
H = int(H)
W = int(W)
K = int(K)
ans = [[0] * W for _ in range(H)]
using = 0
unpainted = -1
for i in range(H):
    appeared = -1
    for j in range(W):
        if s[i][j] == '#':
            if appeared < 0:
                appeared = 1
                using += 1
                for k in range(j+1):
                    ans[i][k] = using
            else:
                using += 1
                ans[i][j] = using
        else:
            if appeared > 0:
                ans[i][j] = using
    if appeared < 0:
        if using > 0:
            ans[i] = ans[i-1]
        else:
            unpainted += 1
if unpainted >= 0:
    for i in range(unpainted,-1,-1):
        ans[i] = ans[i+1]
for x in ans:
    print(*x)

Measured memory_bytes: 12628
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*
int inv[1000001]={0};int invf[1000001]={0};
void findinverse(){
	inv[0]=1;
	inv[1] = 1;
	for(int i = 2; i <=1e6 ; ++i)
		inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
	invf[0]=1;invf[1]=1;
	for(int i=2;i<=1e6;i++){
		invf[i]=invf[i-1]*inv[i]%mod;
	}
}*/
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> orderedMultiset;
int solve()
{
	int n;
	cin>>n;
	int a[n];
	int prefix_sum=0;
	int sum[n+1]={0};
	for(int i=0;i<n;i++){
		cin>>a[i];
		prefix_sum=(prefix_sum+a[i])%mod;
		sum[i+1]=prefix_sum;
	}
	int ans=0;
	for(int i=n-1;i>0;i--){
		int x=(sum[i]*a[i])%mod;
		ans=(ans+x)%mod;
	}
	cout<<ans<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}



Measured memory_bytes: 6788
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

int main(void){
	unsigned long long K,N=50,a[100010];
	//2:15
	//3:16
	cin>>K;
	rep(i,N){
		a[i]=N-1 + (N+1)*(K/N) - K;
	}
	K%=N;
	rep(i,K){
		a[i]+=(N+1);
	}
	cout<<N<<endl;
	rep(i,N)cout<<a[i]<<" ";
	cout<<endl;
	return 0;
}

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

int main()
{
  int a,b,c;
  int h,m,s;

  cin >> a >> b >> c;

  if(a < b){
    if(b < c){
      cout << a << " " << b << " " << c << endl;
    }else{
      if(a < c){
        cout << a << " " << c << " " << b << endl;
      }else{
        cout << c << " " << a << " " << b << endl;
      }
    }
  }else{
    if(a < c){
      cout << b << " " << a << " " << c << endl;
    }else{
      if(b < c){
        cout << b << " " << c << " " << a << endl;
      }else{
        cout << c << " " << b << " " << a << endl;
      }
    }
  }
  
  return 0;
} 

Measured memory_bytes: 1164