akhauriyash/Code-Regression huggingface dataset:
/*
   Author: Shivam Shukla
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
	fastio();
	auto tstart= clock();
 

    int n; cin >> n;
    vl a(n); repa(i, n) cin >> a[i];   
    
    ll mn = numeric_limits<ll>::max();
    repa(i, 100){
       ll tot = 0;
       repa(j, sz(a))
          tot += (a[j] - i) * (a[j] - i);
       mn = min(tot, mn);
    }
    cout << mn << endl;

    cerr<<setprecision(2)<<fixed<<"Time elapsed: "<<(double)(clock() - tstart)/CLOCKS_PER_SEC<<endl; 
    return 0; 
}

Measured memory_bytes: 256
var obj = {};
obj.U = "rrrr".split("");
obj.D = "oooo".split("");
obj.F = "yyyy".split("");
obj.L = "gggg".split("");
obj.R = "bbbb".split("");
obj.B = "wwww".split("");
 
function topRotateFn(k) {
   var a = obj[k].slice();
   obj[k][0] = a[2];
   obj[k][1] = a[0];
   obj[k][2] = a[3];
   obj[k][3] = a[1];
}
 
function mawasu(str) {
   var arr = str.split(",");
   var a = [];
   arr.forEach(v => {
      var getArray = getFn(v);
      a.push(getArray[0], getArray[1]);
   });
   a = a.slice(-2).concat(a.slice(0, -2));
   arr.forEach((v, i) => {
      setFn(v, a[i * 2], a[i * 2 + 1]);
   });
}
 
function getFn(v) {
   var [k, n] = v.split("");
   if (n == "0") return [obj[k][0], obj[k][1]];
   else if (n == "1") return [obj[k][1], obj[k][3]];
   else if (n == "2") return [obj[k][2], obj[k][0]];
   else if (n == "3") return [obj[k][3], obj[k][2]];
}
 
function setFn(v, a, b) {
   var [k, n] = v.split("");
   if(n=="0"){obj[k][0]=a;obj[k][1]=b;}
   else if(n=="1"){obj[k][1]=a;obj[k][3]=b;}
   else if(n=="2"){obj[k][2]=a;obj[k][0]=b;}
   else if(n=="3"){obj[k][3]=a;obj[k][2]=b;}
}
 
function writeFn(y, x, s) {
   yx[y][x] = obj[s][0];
   yx[y][x + 1] = obj[s][1];
   yx[y + 1][x] = obj[s][2];
   yx[y + 1][x + 1] = obj[s][3];
}
 
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("");
arr.forEach(v => {
   topRotateFn(v);
   if (v == "U") mawasu("F0,L0,B0,R0")
   else if (v == "D") mawasu("F3,R3,B3,L3");
   else if (v == "F") mawasu("R2,D0,L1,U3");
   else if (v == "L") mawasu("F2,D2,B1,U2");
   else if (v == "R") mawasu("U1,B2,D1,F1");
   else if (v == "B") mawasu("R1,U0,L2,D3");
});
var yx = [];
for (var i = 0; i < 6; i++) yx[i] = "........".split("");
for (var s in obj) {
   if (s == "U") writeFn(0, 2, s);
   else if (s == "D") writeFn(4, 2, s);
   else if (s == "F") writeFn(2, 2, s);
   else if (s == "L") writeFn(2, 0, s);
   else if (s == "R") writeFn(2, 4, s);
   else if (s == "B") writeFn(2, 6, s);
}
console.log(yx.join("\n").replace(/\,/g, ""));


Measured memory_bytes: 16612
#include<iostream>
#define FOR(i,a,b) for(int i=(a);i<(b);++i) 
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  int N, H, W; cin>>N>>H>>W;
  cout << (N-H+1)*(N-W+1) << endl;
  return 0;
}


Measured memory_bytes: 256
//Volume0-0063
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		//initialize
		StringBuffer sb;
		int cnt = 0;

		//input
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			sb = new StringBuffer(sc.nextLine());
			
			//calculate
			if(sb.toString().equals(sb.reverse().toString())){cnt++;}
		}
		
		//output
		System.out.println(cnt);
	}
}

Measured memory_bytes: 17168
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;

long long int N, M, K, W, H, L, R;

long long int GCD(long long int a, long long int b) {
	if (a < b)swap(a, b);
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

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

	cin >> N;
	long long int num[2000] = {};
	for (int i = 0; i < N; i++)cin >> num[i];
	for (int i = 1; i < N; i++)num[0] = num[0] / GCD(num[0], num[i])*num[i];
	cout << num[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

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

int main(){
    string S; cin>>S;
    solve(S);
}

Measured memory_bytes: 3628
#include <iostream>

void bubble_sort(int l[], int N)
{
  for(int i = 0; i < N; i++)
  {
    for(int k = i + 1; k < N; k++)
    {
      if(l[i] < l[k])
      {
        int temp = l[i];
        l[i] = l[k];
        l[k] = temp;
      }
    }
  }
}

int main()
{
  int N, K, l[50], length = 0;
  std::cin >> N >> K;
  
  for(int i = 0; i < N; i++)
  {
    std::cin >> l[i];
  }
  
  bubble_sort(l, N);

  for(int i = 0; i < K; i++)
  {
    length += l[i];
  }
  
  std::cout << length;
  return 0;
}

Measured memory_bytes: 3160
H,W=map(int,input().split())
A=[0]*10
dist=[10**10]*10
for i in range (10):
    A[i]=list(map(int,input().split()))

for i in range(10):
    dist[i]=A[i][1]

for k in range(10):
    for i in range(10):
        for j in range(10):
            if(dist[i]>A[i][j]+dist[j]):
                dist[i]=A[i][j]+dist[j]

s=0
for i in range (H):
    T=list(map(int,input().split()))
    for j in range(W):
        if T[j]==-1:
            continue
        else:
            s+=dist[T[j]]
print(s)



Measured memory_bytes: 41136
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var r = int.Parse(Console.ReadLine());
            Console.WriteLine(3 * Math.Pow(r, 2));
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
using ll = long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int n, k;
    cin >> n >> k;
    V a(n);
    rep(i, n) cin >> a[i];
    cout << (n + k - 3) / (k - 1) << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
    int n,ma=0,x=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='I'){
            x++;
            ma=max(x,ma);
        }else{
            x--;
        }
    }
    cout<<ma;
    return 0;
}

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        double ret = 0;
        for (int i = 0; i < N; i++)
        {
            double x = cin.nextDouble();
            string u = cin.nextString();
            if (u == "JPY")
            {
                ret += x;
            }
            else
            {
                ret += x * 380000.0;
            }
        }
        Console.WriteLine(ret);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}



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

int main()
{
    ll n;
    cin >> n;
    int ans = 15;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i) continue;
        int j = n / i;
        int k = i;
        int dj = 0;
        int di = 0;
        while(j) {
            j /= 10;
            dj++;
        }
        while(k) {
            k /= 10;
            di++;
        }
        ans = min(ans, max(dj, di));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3688
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int W,H,N;
  while(~scanf("%d %d %d",&W,&H,&N)){
    int res = 0;
    int sx,sy;
    scanf("%d %d",&sx,&sy);

    for(int i=1;i<N;i++){
      int x,y;
      scanf("%d %d",&x,&y);
      int diff_x = x - sx;
      int diff_y = y - sy;

      if((diff_x <= 0 && diff_y >= 0)
         || ((diff_x >= 0 && diff_y <= 0))){
        res += abs(diff_x) + abs(diff_y);
      }
      else{
        int abs_diff_x = abs(diff_x);
        int abs_diff_y = abs(diff_y);
        int min_diff = min(abs_diff_x,abs_diff_y);
        res += min_diff;
        abs_diff_x -= min_diff;
        abs_diff_y -= min_diff;
        res += max(abs_diff_x,abs_diff_y);
      }
      sx = x;
      sy = y;

    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1188
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+50;
const int inf=0x3f3f3f3f;
int n,k;
vector<bool> vis(200001,0);
vector<ll> a(200001,0);
vector<int> g[200001];
void dfs(int t,ll val)
{
    vis[t]=1;
    a[t]+=val;
    for(int i=0;i<g[t].size();i++)
    {
        int v=g[t][i];
        if(!vis[v])
        {
            dfs(v,a[t]);
        }
    }
}
int main()
{
    //freopen("/Users/zilongzhang/Desktop//l.txt","r",stdin);
       scanf("%d %d",&n,&k);
        for(int i=1;i<=n-1;i++) {
            int x, y;
            scanf("%d %d", &x, &y);
            x--;
            y--;
            g[x].push_back(y);
            g[y].push_back(x);
        }
        while(k--)
        {
            int l,b;
            scanf("%d %d",&l,&b);
            l--;
            a[l]+=b;
        }
        dfs(0,0);
        for(int i=0;i<n;i++)
            printf("%lld ",a[i]);
    return 0;
}


Measured memory_bytes: 24320
while True:
	try:
		n=int(input())
		a=[True]*(n+1)
		a[0]=a[1]=False
		for i in range(2,int(n**0.5)+1):
			if a[i]:
				for j in range(i**2,n+1,i):
					a[j]=False
		print(a.count(True))
	except:
		break

Measured memory_bytes: 23268
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=1e5+7;

int a[N],k;

il void die(){
	puts("-1");
	exit(0);
}

int main(){
	scanf("%d",&k);
	rep(i,1,k) scanf("%d",a+i);
	if(a[k]!=2) die();
	ll l=2,r=3;
	per(i,k-1,1){
		ll t1=(l-1)/a[i]+1;
		ll t2=r/a[i];
		if(t1>t2) die();
		l=t1*a[i],r=(t2+1)*a[i]-1;
	}
	printf("%lld %lld\n",l,r);
	return 0;
} 

Measured memory_bytes: 640
class  Dise:
    def __init__(self,top,flont,right,left,back,bottom):
        self.top,self.flont,self.right,self.left,self.back,self.bottom=top,flont,right,left,back,bottom
        
    def rot(self,d):
        if d=='N':
            self.top,self.flont,self.bottom,self.back=self.flont,self.bottom,self.back,self.top
        elif d=='E':
            self.top,self.right,self.bottom,self.left=self.left,self.top,self.right,self.bottom
        elif d=='S':
                self.top,self.flont,self.bottom,self.back=self.back,self.top,self.flont,self.bottom
        elif d=='W':
            self.top,self.right,self.bottom,self.left=self.right,self.bottom,self.left,self.top
    
    def gettop(self):
        return self.top

n=list(map(int,input().split()))
dise=Dise(n[0],n[1],n[2],n[3],n[4],n[5])
str=input()
for s in str:
    dise.rot(s)
print(dise.gettop())


            
        


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

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

using namespace std;

struct team{
  int tid;
  int times;
  int correct;
  array<bool, 10> ans;
  array<int, 10> miss;
  team(int i) : tid(i), times(0), correct(0), ans({false}), miss({0}) {}
  bool operator<(const team& x)const{
    if(correct > x.correct) return true;
    if(correct < x.correct) return false;
    if(times < x.times) return true;
    if(times > x.times) return false;
    if(tid < x.tid) return true;
    return false;
  }
};

int main(){
  int t, p, r;
  vector<team> teams;
  while(cin >> t >> p >> r and t + p + r){
    REP(i, t) { teams.emplace_back(i+1); }
    REP(i, r) {
      int tid, pid, tim;
      cin >> tid >> pid >> tim;
      tid--;
      pid--;
      string res;
      cin >> res;
      if(teams[tid].ans[pid]) continue;
      if(res == "CORRECT") { teams[tid].times += teams[tid].miss[pid] * 1200 + tim; teams[tid].ans[pid] = true; teams[tid].correct++; }
      if(res == "WRONG") { teams[tid].miss[pid]++; }
    }
    sort(ALL(teams));
    REP(i, t) cout << teams[i].tid << " " << teams[i].correct << " " << teams[i].times << endl;
    teams.clear();
  }
  return 0;
}

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

using namespace std;

int main(void)
{
    vector<int> v(4);
    cin >> v[0];
    cin >> v[1];
    cin >> v[2];
    cin >> v[3];
    sort(v.begin(), v.end());

    if(v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 888
arr=Array.new(4){Array.new(3){Array.new(10,0)}}
gets.to_i.times do
    b=gets.split.map(&:to_i)
    arr[b[0]-1][b[1]-1][b[2]-1]+=b[3]
end
4.times do |i|
    arr[i].each { |b| puts " "+b.join(" ") }
    puts "#"*20 if i < 3
end

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

const int max_n = 1e5 + 5;

int dp[max_n][3];
int v[max_n][3];

int main () {
	make(n);
	FOR(i,0,n) {
		make3(a, b, c);
		v[i][0] = a; v[i][1] = b; v[i][2] = c;
	}
	FOR(i,0,3) dp[0][i] = v[0][i];
	FOR(i,1,n) {
		FOR(j,0,3) {
			int rest = 0;
			FOR(k,0,3) {
				if (k==j) continue;
				rest = max(rest, dp[i-1][k]);
			}
			dp[i][j] = rest + v[i][j];
		}
	}
	int ans = 0;
	FOR(j,0,3) ans = max(ans, dp[n-1][j]);
	printf("%d\n", ans);

}	





Measured memory_bytes: 2560
#pragma GCC optimize(2)
#pragma warning(disable:4996)
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include<cstring>
#include <stack>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include <string>
#include<iomanip>
#include<assert.h>
#define itn int
#define endl "\n"
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
const int maxn = 1e6 + 6;
const int maxa = 1000 * 1000 * 1000 + 7;
typedef long long ll;
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int t, n, m, T;
ll dp[maxn];

int main()
{
#ifdef _DEBUG
	freopen("D:\\input.txt", "r", stdin);
	//	freopen("E:\\output.txt", "w", stdout);
#endif
	std::ios::sync_with_stdio(false); cin.tie(0);	cout.tie(0);
	int n, weight;
	cin >> n;
	cin >> weight;
	vector<ll>w(n);
	vector <ll > v(n);
	int mxv = n * 1000;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	memset(dp, 0x7f, sizeof dp);
	dp[0] = 0;
	for (int i = 0; i <n; i++)
		for (int j = mxv; j >= 0; j--) {
			if(j>=v[i])	
			dp[j] = min(dp[j], dp[j - v[i]]+w[i]);
		}
	int ans = 0;
	for (int i = 0; i <= mxv;i++) {
		if (weight >= dp[i])
			ans =max(ans, i);
	}
	cout << ans<<endl;
	return 0;
}

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

int main(){
    ll d;
    cin >> d;
    vector<ll> c(26);
    vector<vector<ll>> s(d, vector<ll>(26));
    rep(i, 26) cin >> c[i];
    for(int i=0; i<d; i++){
        for(int j=0; j<26; j++){
            cin >> s[i][j];
        }
    }
    vector<ll> t(d);
    rep(i, d) cin >> t[i];
    ll score = 0;
    vector<ll> lastd(26, 0);
    rep(i, d){
        score += s[i][t[i]-1];
        lastd[t[i]-1] = i+1;
        rep(j, 26) score -= c[j]*((i+1)-lastd[j]);
        cout << score << endl;
    }
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define MAXN 105
using namespace std;

int n;char l;
string p;
set <string> s;

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>p;
		if (i!=1&&p[0]!=l){puts("No");return 0;}
		if (s.count(p)){puts("No");return 0;}
		s.insert(p);l=p[p.length()-1];
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SQR(x) (x) * (x)
#define itn int

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);
template <typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}

signed main() {
  int N, T;
  cin >> N >> T;
  vector<int> A(N);
  REP(i, N) {
    cin >> A[i];
  }
  vector<int> MAX_A(N);
  REP(i, N) {
    MAX_A[i] = A[i];
  }
  for (int i = N - 2; i >= 0; i--) {
    MAX_A[i] = max(MAX_A[i], MAX_A[i + 1]);
  }
  int MAX = 0;
  int num = 0;
  REP(i, N - 1) {
    MAX = max(MAX, MAX_A[i + 1] - A[i]);
  }
  REP(i, N - 1) {
    if (MAX_A[i + 1] - A[i] == MAX) {
      num += 1;
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
string str[101];
int n,idx=0;

int cal(char ch,int a,int b){
  if(ch=='*') return a*b;
  return a+b;
}

int get_cnt(string a){
  int res=0;
  while(a[res]=='.')res++;
  return res;
}

int dfs(){
  int cnt=get_cnt(str[idx]);
  char ch=str[idx][cnt];
  int res =(ch=='*');
  if(ch!='*'&&ch!='+')return str[idx++][cnt]-'0';
  idx++,cnt++;
  while(idx<n){
    if(get_cnt(str[idx])>=cnt) res = cal(ch,res,dfs());
    else break;
  }
  return res;
}

int main(){

  while(cin>>n,n){
    for(int i=0;i<n;i++) cin>>str[i];
    idx=0;
    cout <<dfs()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define int long long
#define N 200005
using namespace std;

template<typename D = long long, int useAssert = 1>
class BIT{
public:
  int n;
  vector<D> bit0, bit1;
  BIT(){n = -1;}
  BIT(int n_){
    n = 1;
    while(n < n_) n *= 2;
    bit0.resize(n+1, 0);
    bit1.resize(n+1, 0);
  }

  D sum(vector<D> &b, int i){
    D s = 0;
    while(i > 0){
      s = (s + b[i]);// % mod;
      i -= i & -i;
    }
    return s;
  }

  void add(vector<D> &b, int i, D v){
    // v = (mod + v % mod) % mod;
    while(i <= n){
      b[i] = (b[i] + v);//% mod;
      i += i & -i;
    }
  }

  //[a,b)にxを加算 0オリジン
  void add (int a, int b, D x){
    // x = (mod + x % mod) % mod;
    if(a == b) return;
    a++;
    if(useAssert) assert(a <= b && 1 <= a && b <= n);
    add(bit0, a, -x*(a-1));
    add(bit1, a, x);
    add(bit0, b+1, x*b);
    add(bit1, b+1, -x);
  }

  //[a,b)のsumを得る 0オリジン
  D sum(int a, int b){
    if(a == b) return 0;
    a++;
    if(useAssert) assert(a <= b && 1 <= a && b <= n);
    D s = sum(bit0, b);
    D t = sum(bit1, b) * b;
    D u = sum(bit0, a-1);
    D v = sum(bit1, a-1) * (a-1);
    return s + t - u - v;
    //return ((s + t) + (mod - u%mod) + (mod - v%mod)) % mod;
  }
};

int n, q;
vector<int> G[N];
int b[N], e[N];
int idx;

int dfs(int x, int px){
  
  b[x] = idx++;
  e[x] = b[x];
  
  for(int nx : G[x]){
    
    if( nx == px ) continue;
    
    e[x] = max( e[x], dfs( nx, x ) );
    
  }
  
  return e[x];
}

signed main(){

  cin>>n>>q;
  
  for(int i=0;i<n-1;i++){
    int a, b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  
  dfs( 0, -1 );
  
  BIT<int,1> bit( n );

  while(q--){
    
    int p, x;
    cin>>p>>x;
    
    p--;
    
    bit.add( b[p], e[p] + 1, x );
    
  }
  
  for(int i=0;i<n;i++){
    
    if( i ) cout<<' ';
    
    cout<<bit.sum( b[i], b[i]+1 );
    
  }
  
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 29952
#include<cstdio>
using namespace std;
int a[10];
int abs(int a){
	return a>0?a:-a;
}
int main(){
	int n=3,ans=10000;
	for (int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for (int i=1;i<=n;i++){
		int sum=0;
		for (int j=1;j<=n;j++)
		if (i!=j){
			sum=abs(a[j]-a[i]);
			for (int k=1;k<=n;k++)
			if (i!=k&&j!=k) sum+=abs(a[k]-a[j]);
			if (sum<ans) ans=sum;
		}
		
	}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 128
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
using namespace std;
using ll = long long;
const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

mint count(ll N,ll x) {
    // nCx
    mint res = 1;
    for(ll i=0;i<x;i++)res *= N-i;
    for(ll i=1;i<x+1;i++) res /= i;
    return res;
}
ll pow_mod(ll a,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1){
            res = (res*a)%mod;
        }
        a = (a*a)%mod;
        n=(n>>1);
    }
    return res;
}


int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    mint res = pow_mod(2,N,mod)-1;
    res -= count(N,A)+count(N,B);
    cout<<res<<endl;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.print(s.charAt(0));
        System.out.print(s.length() - 2);
        System.out.print(s.charAt(s.length()-1));
        
        }
    }

Measured memory_bytes: 35404
n, m, x_capital, y_capital = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ans = "War"

for i in range(100):
    if x_capital < i and i <= y_capital and max(x) < i and i <= min(y):
        ans = "No War"

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <climits>
using namespace std;

long long bit[100010] = {};

void add(int x,long long v){
	for(int i = x ; i < 100010 ; i += i & -i ){
		bit[i] = max(bit[i],v);
	}
}

long long get(int x){
	long long ans = 0;
	for(int i = x ; i > 0 ; i -= i & -i ){
		ans = max(bit[i],ans);
	}
	return ans;
}

int main(){
	int n;
	cin >> n;
	long long ans = 0;
	for(int i = 0 ; i < n ; i++){
		int a;
		cin >> a;
		add(a,get(a)+a);
	}
	cout << 1ll*n*(n+1) / 2 - get(100001) << endl;
}

Measured memory_bytes: 1936
#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 a,b,c,d;
  cin >> a >> b >> c >> d;
  int flag=0;
  while(1){
    if(flag==0){c-=b;flag=1;if(c<=0){cout<< "Yes" << endl;break;}}
    else {a-=d;flag=0;if(a<=0){cout<< "No" << endl;break;}}
  }
  
}


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

using namespace std;

typedef complex<int> P;

int compress(vector<int>& x1, vector<int>& x2, int w) {
	vector<int> needX;
	needX.push_back(0); needX.push_back(w);
	for (int i = 0; i < x1.size(); ++i) {
		for (int j = -1; j <= 1; ++j) {
			int x = x1[i]+j;
			if (0 <= x && x < w) needX.push_back(x);
		}
	}
	for (int i = 0; i < x2.size(); ++i) {
		for (int j = -1; j <= 1; ++j) {
			int x = x2[i]+j;
			if (0 <= x && x < w) needX.push_back(x);
		}
	}
	sort(needX.begin(), needX.end());
	needX.erase(unique(needX.begin(), needX.end()), needX.end());

	for (int i = 0; i < x1.size(); ++i) {
		x1[i] = find(needX.begin(), needX.end(), x1[i]) - needX.begin();
	}
	for (int i = 0; i < x2.size(); ++i) {
		x2[i] = find(needX.begin(), needX.end(), x2[i]) - needX.begin();
	}

	return find(needX.begin(), needX.end(), w) - needX.begin();
}

char m[6100][6100];

void paint(int x, int y, int w, int h) {
	stack<P> S; S.push( P(x, y) );
	while ( !S.empty() ) {
		P p = S.top(); S.pop();
		int x = p.real(), y = p.imag();

		if (x < 0 || x >= w || y < 0 || y >= h) continue;
		if (m[y][x]) continue;

		m[y][x] = 1;

		S.push( P(x+1, y) );
		S.push( P(x-1, y) );
		S.push( P(x, y+1) );
		S.push( P(x, y-1) );
	}

}
int main() {
	int W, H;
	while ( cin >> W >> H, W || H ) {
		fill(&m[0][0], &m[0][0]+6100*6100, (char)0);

		int N; cin >> N;
		vector<int> X1(N), Y1(N), X2(N), Y2(N);
		for (int i = 0; i < N; ++i) {
			cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i]; --X2[i], --Y2[i];
		}
		W = compress(X1, X2, W);
		H = compress(Y1, Y2, H);

		for (int i = 0; i < N; ++i) {
			int x1 = X1[i], y1 = Y1[i], x2 = X2[i], y2 = Y2[i];

			++m[y1][x1];
			--m[y2+1][x1];

			--m[y1][x2+1];
			++m[y2+1][x2+1];
		}

		for (int y = 0; y < H; ++y) {
			for (int x = 0; x <= W; ++x) {
				m[y+1][x] += m[y][x];
			}
		}
		for (int y = 0; y <= H; ++y) {
			for (int x = 0; x < W; ++x) {
				m[y][x+1] += m[y][x];
			}
		}

		int ans = 0;
		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				if (!m[y][x]) {
					paint(x, y, W, H);
					++ans;
				}
			}
		}
		cout << ans << endl;
	}
}

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


int main(){


    int a, b, c, d, e, f, i, j;

    double t;

    double p = -1;

    int ansx = 0;

    int ansy = 0;

    vector<int> x;

    vector<int> y;


    cin >> a >> b >> c >> d >> e >> f;


    for( i = 0 ; 100 * a * i <= f ; i = i + 1 ){

         for( j = 0 ; 100 * b * j <= f ; j = j + 1 ){

              if( 100 * a * i + 100 * b * j <= f ) x.push_back( 100 * a * i + 100 * b * j );
              
              }

         }

    for( i = 0 ; c * i <= f ; i = i + 1 ){

         for( j = 0 ; d * j <= f ; j = j + 1 ){

              if( c * i + d * j <= f ) y.push_back( c * i + d * j );

              }

         }


    
    for( i = 0 ; i < x.size() ; i = i + 1 ){

         for( j = 0 ; j < y.size() ; j = j + 1 ){

              t = (double) ( 100 * y.at(j) ) / ( x.at(i) + y.at(j) );

              if( x.at(i) + y.at(j) <= f && t > p && x.at(i) != 0 && y.at(j) <= x.at(i) * e / 100 ){

                  p = t;

                  ansx = x.at(i) + y.at(j);

                  ansy = y.at(j);

                  }

              }

         }


    cout << ansx << " " << ansy << endl;


    return 0;

    }


Measured memory_bytes: 1400
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var ans = "ABC";
        if (s == "ABC")
        {
            ans = "ARC";
        }
        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 25780
#include<stdio.h>
int main(){
  int n,i,j,a,m;
  int d[60][60];
  while(scanf("%d",&n),n){
    long long s,h[60]={0};
    int r[60]={0};
    for(i=0;i<n;i++){
      h[i]=(long long)1<<i;
      scanf("%d",&m);
      while(m--){
	scanf("%d",&a);
	d[a][r[a]++]=i;
      }
    }
    for(i=1;i<31;i++){
      for(j=s=0;j<r[i];j++)s|=h[d[i][j]];
      for(j=  0;j<r[i];j++)h[d[i][j]]=s;
      if(s+1==(long long)1<<n)break;
    }
    printf("%d\n",i-31?i:-1);
  }
  return 0;
}

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

using namespace std;

map < string, int > mp;
map < string, int > :: iterator it;
int n, maxi=0;
string s;

int main()
{
    cin >> n;
    while (n--){
        cin >> s;
        mp[s]++;
    if (mp[s] > maxi) maxi = mp[s];
    }

    for (it = mp.begin (); it!= mp.end(); it++) if (it -> second == maxi) cout << it -> first <<endl;

    return 0;
}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

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

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


public class Main{
	public static void main(String[] args) throws IOException{
		int n = sc.nextInt();
        int k = sc.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;++i)
			arr[i] = sc.nextInt();
		int[] dp = new int[n];
		dp[0] = 0;
		dp[1] = Math.abs(arr[1] - arr[0]);
		for(int i=2;i<n;++i){
			int min = Integer.MAX_VALUE;
            for(int j=1;j<=k;j++)
                if ((i-j)>=0)
                    if (Math.abs(arr[i]-arr[i-j])+dp[i-j] < min) min = Math.abs(arr[i]-arr[i-j])+dp[i-j];
            dp[i] = min;
		}
		System.out.println(dp[n-1]);
	}
}

class sc{
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer tokenizer = new StringTokenizer("");
    static String next() throws IOException{
        while (!tokenizer.hasMoreTokens())
            tokenizer = new StringTokenizer(reader.readLine());
        return tokenizer.nextToken();
    }
    static int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
    static double nextDouble() throws IOException{
        return Double.parseDouble(next());
    }
    static long nextLong() throws IOException{
        return Long.parseLong(next());
    }
    static float nextFloat() throws IOException{
    	return Float.parseFloat(next());
    }
}

Measured memory_bytes: 33388
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b=mod-2,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int a, b, k;

signed main() {
    cin >> k >> a >> b;
    rep(i,10000) if (a<=k*i && k*i<=b) return cout<<"OK"<<endl,0;
    cout << "NG" << endl;
}


Measured memory_bytes: 3692
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
typedef long long ll;
typedef long double ld;
const ll inf = 999999999999999999;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(0LL, min(b, d) - max(a, c));
	getchar(); getchar();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

ll ext_gcd(ll A, ll B, ll *X, ll *Y ){
    ll x2, y2, x1, y1, x, y, r2, r1, q, r;
    x2 = 1, y2 = 0;
    x1 = 0, y1 = 1;
    for (r2 = A, r1 = B; r1 != 0; r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y ) {
        q = r2 / r1, r = r2 % r1;
        x = x2 - (q * x1), y = y2 - (q * y1);
    }
    *X = x2; *Y = y2;
    return r2;
}
inline ll mod_inv(ll a, ll m){
    ll x, y;
    ext_gcd(a, m, &x, &y);
    x %= m;
    if ( x < 0 ) x += m;
    return x;
}

const ll mod = 1e9 + 7;
const int nax = 1e5 + 5;
ll fact[nax], nCk[nax];
ll n, k;
ll ara[nax];

void cal()
{
    fact[0] = 1;
    for (ll i = 1; i <= n; i++){
        fact[i] = (fact[i - 1] * i) % mod;
    }
    for (int i = k - 1; i <= n; i++){
        ll num = fact[i];
        ll den = (fact[k - 1] * fact[i - (k - 1)]) % mod;
        nCk[i] = (num * mod_inv(den, mod)) % mod;
    }
}

int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    cin >> n >> k;
    cal();
    for (int i = 0; i < n; i++){
        cin >> ara[i];
    }
    sort(ara, ara + n);
    ll maxS, minS;
    maxS = minS = 0;
    for (int i = 0; i <= n - k; i++){
        minS += (ara[i] * nCk[n - i - 1]) % mod;
    }
    for (int i = n - 1; i >= k - 1; i--){
        maxS += (ara[i] * nCk[i]) % mod;
    }
    ll res = (maxS - minS) % mod;
    if (res < 0){
        res += mod;
    }
    cout << res << endl;
    return 0;
}


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

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

    vector<int> a(n);
    rep(i, n) { cin >> a.at(i); }

    double sum = 0.0;
    rep(i, n) { sum += 1.0 / a.at(i); }

    cout << 1 / sum << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,M;cin>>N>>M;
    vector<pair<int,char>> cond;
    REP(i,M){
        int s;
        char c;
        cin>>s>>c;
        s--;
        cond.push_back({s,c});
    }
    REP(i,1000){
        string num=to_string(i);
        if(num.size()!=N) continue;
        bool ok=true;
        for(auto c:cond) if(num[c.first]!=c.second) ok=false;
        if(ok){
            cout<<num<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;
      cin>>n>>k;

cin>>str;
     str="#"+str;

      n=str.size();

      ll cum[n+2]={};

      for(i=1; i<n; i++)
      {
          if(i+1<n && str[i]=='A' && str[i+1]=='C')
            cum[i]=cum[i-1]+1;

          else cum[i]=cum[i-1];
      }

      while(k--)
      {
          cin>>a>>b;

          cout<<cum[b-1]-cum[a-1]<<endl;
      }





}



Measured memory_bytes: 4500
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n;
  bool connected[200][200] = {};
  
  scanf("%d", &n);

  for(int i=0;i<n;i++){
    int u, k, v;

    scanf("%d%d", &u, &k);
    u--;
    
    for(int j=0;j<k;j++){
      scanf("%d", &v);
      v--;

      connected[u][v] = true;
    }
  }

  queue<int> q1, q2;
  bool visited[200] = {};
  int ans[200];

  for(int i=0;i<n;i++) ans[i] = -1;
  
  q1.push(0);

  for(int i=0;q1.size();i++){

    while(q1.size()){
      int p = q1.front();
      q1.pop();

      if(visited[p]) continue;
      visited[p] = true;

      ans[p] = i;
      
      for(int j=0;j<n;j++){
        if(connected[p][j]){
          q2.push(j);
        }
      }
    }

    q1 = q2;
    q2 = queue<int>();
  }

  for(int i=0;i<n;i++)
    printf("%d %d\n", i+1, ans[i]);
  
  return 0;
}



Measured memory_bytes: 3268
s = input()
if (s[:2] > '12' or s[:2] == '00') and s[2:] < '13' and s[2:] > '00':
    print('YYMM')
elif s[:2] > '00' and s[:2] < '13' and (s[2:] > '12' or s[2:] == '00'):
    print('MMYY')
elif s[:2] > '00' and s[:2] < '13' and s[2:] < '13' and s[2:] > '00':
    print('AMBIGUOUS')
else:
    print('NA')

Measured memory_bytes: 3064