akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;

int to[500002][26];
const int MAX_D = 19;
int skip[500002][MAX_D];
string s;
const int INF = 500001;

void solve() {
  cin >> s;
  for(int j = 0; j < 26; j++) {
    to[s.size()][j] = INF;
    to[INF][j] = INF;
  }
  for(int i = 0; i <= INF; i++) skip[i][0] = INF;
  for(int i = s.size()-1; i >= 0; i--) {
    to[i][s[i]-'a'] = i+1;
    for(int a = s[i]-'a'+1; a < 26; a++) {
      to[i][a] = to[to[i][a-1]][a-1];
    }
    skip[i][0] = to[to[i][25]][25];
    for(int a = 0; a < s[i]-'a'; a++) {
      to[i][a] = to[skip[i][0]][a];
    }
  }
  for(int d = 1; d < MAX_D; d++) {
    for(int i = 0; i <= INF; i++) {
      skip[i][d] = skip[skip[i][d-1]][d-1];
    }
  }
  int q;
  cin >> q;
  while(q--) {
    int lhs, rhs;
    cin >> lhs >> rhs;
    int d = MAX_D-1;
    lhs--;
    rhs--;
    while(d >= 0) {
      if(skip[lhs][d] <= rhs+1) lhs = skip[lhs][d];
      d--;
    }
    if(lhs-1 == rhs) cout << "Yes\n";
    else cout << "No\n";
  }
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 89116
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

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

    vector<int> orig(n);
    vector<int> abs_orig(n);

    REP(i, n)
    {
        orig.at(i) = l + i;
        abs_orig.at(i) = abs(l + i);
    }

    sort(abs_orig.begin(), abs_orig.end());

    int eat = abs_orig.at(0);

    int ans = 0;
    bool flag = true;
    REP(i, n)
    {
        if (flag)
        {
            if (abs(orig.at(i)) == eat)
            {
                flag = false;
            }
            else
            {
                ans += orig.at(i);
            }
        }
        else
        {
            ans += orig.at(i);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <iomanip>
#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <limits>
#include <list>
#include <stack>

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef vector<ll> VL;
typedef vector<VL> VVL;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll a, t;
	cin >> a >> t;
	for (int i = 1; i < n; ++i) {
		ll ai, ti;
		cin >> ai >> ti;
		ll x = max(1LL, a/ai + (a%ai ? 1 : 0));
		x = max(x, t/ti + (t%ti ? 1 : 0));
		a = ai*x;
		t = ti*x;
	}
	cout << a + t;
}

Measured memory_bytes: 256
import collections as c
ip = lambda : map(int, input().split())
# ##############
N = int(input())
l = list(ip())
d = []
for i in range(N-1):
    d.append(l[i+1]-l[i])

ans = 0
mod = int(1e9+7)
c=0
l=1
for i in range(N-1):
    c = ((i+1)*c + l)%mod
    ans = ((i+1)*ans + c*d[i])%mod
    l = l*(i+1)%mod
print(ans)

Measured memory_bytes: 14636
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll sum;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if (i%3==0||i%5==0)
			continue;
		sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll N,M,K;
    cin>>N>>M>>K;
    bool flag=false;
    rep(i,N+1){
        rep(j,M+1){
            if(i*(M-j)+j*(N-i)==K){
                flag=true;
            }
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        Console.WriteLine((long) (n - 1) * n / 2);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main()
{
int a,b;
cin>>a;
cin>>b;
if(b%2==!0)
{
    cin>>b;
}
if(0<=a&&a<=100&&2<=b&&b<=1000)
{
if(a>=13)
{
    cout<<b;
}
else if (a>=6&&a<=12)
{
    cout<<b/2;
}
else if(a<=5)
{
    cout<<0;
}

}
      return 0;
}


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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int N, K, buf1, buf2, ans=0;
    vector<int> A(100,-1);
    cin >> N >> K;

    REP(i,K){
        cin >> buf1;
        REP(j,buf1){
            cin >> buf2;
            if (A[buf2-1] == -1){
                A[buf2-1] = 1;
                ans += 1;
            }
        }
    }
    cout << N - ans << endl;
}

Measured memory_bytes: 3632
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val d = sc.nextInt()
    val x = (0 until n).map { (0 until d).map { sc.next().toInt() }  }
    println(problem133b(n, d, x))
}

fun problem133b(n: Int, d: Int, x: List<List<Int>>): Int {
    var count = 0
    for (i in 0 until n) {
        for (j in i + 1 until n) {
            var sum = 0.0
            for (k in 0 until d) {
                sum += Math.pow(Math.abs(x[i][k] - x[j][k]).toDouble(), 2.toDouble())
            }
            val sqrt = Math.sqrt(sum)
            if (sqrt == sqrt.toInt().toDouble()) {
                count++
            }
        }
    }
    return count
}

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

using namespace std;

int main() {
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
        int h, w;
        scanf("%d%d", &h, &w);
        vector<vector<char>> a(h, vector<char>(w));
        vector<vector<int>> dp(h, vector<int>(w, 0));
        dp[0][0] = 1;
        for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                        scanf(" %c", &a[i][j]);
                }
        }
        const int mod = (int) 1e9 + 7;
        for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                        if (a[i][j] != '.') {
                                continue;
                        }
                        if (i + 1 < h && a[i + 1][j] == '.') {
                                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
                        }
                        if (j + 1 < w && a[i][j + 1] == '.') {
                                dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod;
                        }
                }
        }
        printf("%d\n", dp[h - 1][w - 1]);
        return 0;
}


Measured memory_bytes: 5248
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2340

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

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

	int P,N;
	char C;
	long long LPAR=0, RPAR=0;
	rep(nth,Q)
	{
		cin >> P >> C >> N;
		
		if(C == '('){
			LPAR += N;
		}else{
			RPAR += N;
		}

		cout << ( (LPAR == RPAR) ? "Yes" : "No" ) << endl;
	}
	return 0;
}

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

int main(){
  int n;cin>>n;
  vector<int> a(n);
  int b=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    b^=a[i];
  }
  for(int i=0;i<n;i++){
    cout<<(int)(a[i]^b);
    if(i<n-1) cout<<' ';
  }
  cout<<endl;
  return 0;
}
  

Measured memory_bytes: 4012
import java.util.Scanner;

public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        int k = stdIn.nextInt();
        int[] temp = new int[k];
        int startIdx = 0;
        for(int i=0; i<n; i++){
            if(i < k){
                temp[i] = stdIn.nextInt();
            }else{
                int x = stdIn.nextInt();
                if(temp[startIdx] < x){
                    System.out.println("Yes");
                }else{
                    System.out.println("No");
                }
                temp[startIdx] = x;
                startIdx = (startIdx + 1) % k;
            }
        }
    }
}


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

using ll = long long;

const int max_N = 1e5 + 21;

int n,q,top;

ll A,st[max_N],t[max_N],ans[max_N];

int main(){
	scanf("%d%d",&n,&q);
	st[++top]=n;
	for(int i=1;i<=q;++i){
		scanf("%lld",&A);
		while(top&&st[top]>=A)--top;
		st[++top]=A;
	}
	t[top]=1;
	for(int i=top;i;--i){
		ll k=st[i];
		while(k>st[1]){
			int j=std::lower_bound(st+1,st+1+top,k)-st-1;
			t[j]+=t[i]*(k/st[j]);
			k%=st[j];
		}
		ans[k]+=t[i];
	}
	for(int i=n;i;--i)ans[i]+=ans[i+1];
	for(int i=1;i<=n;++i)printf("%lld\n",ans[i]);
	return 0;
}

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

using namespace std;

namespace {
    int N;
    void input() {
        cin >> N;
    }

    template<typename T>
    string to_s(T t) {
        ostringstream os;
        os << t;
        return os.str();
    }

    int f(int N) {
        string s = to_s(N);
        int sum = 0;
        for (auto c : s) {
            int x = c - '0';
            sum += x;
        }
        return sum;
    }

    void solve() {
        cout << (N % f(N) == 0 ? "Yes" : "No") << endl;
    }
}

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



Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
int gcd(long long int a,long long int b,long long int c)
{
   long long int n,m,t,j,k,h;
   if(a>b)
   {
       t=a;a=b;b=t;
   }
   if(a<=b)
   {
       m=b%a;
       if(m==0) n=a;
       while(m!=0)
       {
           b=a;
           a=m;
           m=b%a;
       }
       n=a;
   }

   if(n>c)
   {
       j=n;n=c;c=j;    //j×÷½»»»
   }
   if(n<=c)
   {
       k=c%n;
       if(k==0) h=n;
       while(k!=0)
       {
           c=n;
           n=k;
           k=c%n;
       }
       h=n;
   }
   return h;
}




int main()
{
    long long int n,i,j,k,sum=0;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                sum=sum+gcd(i,j,k);
            }
        }
    }
    printf("%lld",sum);
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],i;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int sum=0;
    for(i=0;i<n-1;i++)
        sum=sum+a[i];
    if(sum>a[n-1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);
    ArrayList<Integer> list = new ArrayList<Integer>();
    
    int n = scan.nextInt();
    int m = scan.nextInt();
    int sum =0;
    
    for (int i=0;i<n;i++){
      int tmp = scan.nextInt();
      list.add(tmp);
      sum += tmp;
    }
    
    Collections.sort(list, Collections.reverseOrder());
    
    double rate = 1.0 * sum/(4*m);
    
    boolean can = true;
    
    for(int i=0;i<m;i++){
      if(list.get(i) < rate){
        can = false;
        break;
      }
    }
    
    if(can){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
    
  }
  
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  if((B - A) % 2 == 0)
    cout << (B - A) / 2 << endl;
  else
    cout << min((A + B - 1) / 2, N - (A + B - 1) / 2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    lint N, K;
    cin >> N >> K;
    N = N%K;
    lint N2 = K - N;
    cout << min(N, N2) << endl;
}

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

#define pb push_back
#define ss second
#define ff first
#define N 100005
#define inf 1000000009
#define ll long long
#define mid(a,b) (a+b)/2
#define pii pair<int,int>

using namespace std;

ll mod = 1e9+7;
ll n,a,b;
ll ans;

ll der(ll a,ll b){
	if(b == 0) return 1;
	ll x = der(a,b / 2);
	if(b % 2) return (((x*x)%mod)*a)%mod;
	return (x * x) % mod;
}

ll f(ll x,ll y){
	ll ans = 1;
	for(ll i = x;i <= y;i++)
		ans = (ans * i) % mod;
	
	return ans;
}

ll C(ll n,ll k){
	return f(n-k+1,n) * der(f(1,k),mod - 2) % mod;
}

int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	ans = (der(2,n) - 1 - C(n,a) - C(n,b) + mod*2) % mod;
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 2000000
int h, a[MAX + 1];
void maxHeapify(int i) {
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;
    if (l <= h&&a[l] > a[i])largest = l;
    else largest = i;
    if (r <= h&&a[r] > a[largest])largest = r;
    if (largest != i) {
        swap(a[i], a[largest]);
        maxHeapify(largest);
    }
}
int main() {
    cin >> h;
    for (int i = 1; i <= h; i++)cin >> a[i];
    for (int i = h / 2; i >= 1; i--)maxHeapify(i);
    for (int i = 1; i <= h; i++) {
        cout << " " << a[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 5064
n,m,s=map(int,input().split())
uvab=[list(map(int,input().split())) for _ in range(m)]
cd=[list(map(int,input().split())) for _ in range(n)]
g=[[] for _ in range(n)]
maxs=0
for u,v,a,b in uvab:
    u,v=u-1,v-1
    g[u].append([v,a,b])
    g[v].append([u,a,b])
    maxs+=a

#「現在いる頂点、現在持っている銀貨枚数」を頂点とし、ダイクストラ法でとく。
from heapq import heappop,heappush
inf=float('inf')
ans=[[inf]*(maxs+1) for _ in range(n)]
s=min(s,maxs)
todo=[[0,0,s]]
ans[0][s]=0
while todo:
    t,v,ss=heappop(todo)
    if ans[v][ss]<t:continue
    for nv,na,nb in g[v]:
        if na>ss:continue
        if ans[nv][ss-na]>t+nb:
            heappush(todo,[t+nb,nv,ss-na])
            ans[nv][ss-na]=t+nb
    c,d=cd[v]
    nss=min(ss+c,maxs)
    if ans[v][nss]>t+d:
        heappush(todo,[t+d,v,nss])
        ans[v][nss]=t+d
for i in range(1,n):
    print(min(ans[i]))



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

using namespace std;

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

    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3])
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

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

int main()
{
    double a,b,c,d;
    cin >> a >> b >> c >> d;
    // cout << c/b  << " " << a/d << endl;
    // cout << std::ceil(c/b)  << " " << std::ceil(a/d) << endl;
    if(std::ceil(c/b) <= std::ceil(a/d)){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

N -= 1
a = list()
alpha = [i for i in 'abcdefghijklmnopqrstuvwxyz']
if N < 26:
    a.append(alpha[N])
else:
    while N > 0:
        sho = N // 26
        amari = N % 26
        a.append(alpha[amari])
        N = N // 26 - 1
    if N == 0:
        a.append(alpha[N])
a.reverse()
print(''.join(a))

Measured memory_bytes: 9208
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(typeof(a) i=a;i!=(b);++i)
#define CLEAR(a,v) memset(a,v,sizeof(a))
#define SORT(a) sort(a,a+sizeof(a)/sizeof(a[0]))
#define MP make_pair
using namespace std;
typedef long long LL;

int main(){
    LL H, W, N;
    cin >> H >> W >> N;
    map<LL,int> mp;
    REP(i,N){
        int A, B;
        cin >> A >> B;
        A--; B--;
        FOR(j,A-2,A+1){
            if(j < 0 || j > H-3){
                continue;
            }
            FOR(k,B-2,B+1){
                if(k < 0 || k > W-3){
                    continue;
                }
                mp[j*W+k]++;
            }
        }
    }
    LL ret[10] = {};
    FOR(i,mp.begin(),mp.end()){
        ret[(*i).second]++;
    }
    ret[0] = (H - 2) * (W - 2);
    FOR(i,1,10){
        ret[0] -= ret[i];
    }
    FOR(i,0,10){
        cout << ret[i] << endl;
    }
}

Measured memory_bytes: 56448
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        p: usize,
        q: usize,
        r: usize,
    }
    println!("{}", p + q + r - std::cmp::max(p, std::cmp::max(q, r)));
}


Measured memory_bytes: 4352
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }


int[] N;

void main() {
  try {
    for (; ; ) {
      N = new int[4];
      foreach (i; 0 .. 4) {
        N[i] = readInt();
      }
      N.sort();
      const ans = (N == [1, 4, 7, 9]);
      writeln(ans ? "YES" : "NO");
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		map.put(1, 2);map.put(2, 5);map.put(3, 5);map.put(4, 4);map.put(5, 5);
		map.put(6, 6);map.put(7, 3);map.put(8, 7);map.put(9, 6);
		Integer[] A = new Integer[M];
		for (int i=0;i<M;i++) {
			A[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(A, Comparator.reverseOrder());

		int[] dp = new int[N+1];
		for (int i=1;i<N;i++) {
			dp[i] = -(Integer.MAX_VALUE-200);
		}
		for (int i=1;i<N+1;i++) {
			int tmp_max = -(Integer.MAX_VALUE-200);
			for (int j : A) {
				if (i-map.get(j)<0) {
					continue;
				}
				tmp_max = Math.max(tmp_max, dp[i-map.get(j)]);
			}
			dp[i] = tmp_max + 1;
		}

		int tmp = N;
		String ans = "";
		for (int i=0;i<dp[N];i++) {
			for (int j : A) {
				if (tmp-map.get(j)<0) {
					continue;
				}
				if (dp[tmp-map.get(j)] == dp[tmp] - 1) {
					ans += String.valueOf(j);
					tmp -= map.get(j);
					break;
				}
			}
		}
		System.out.println(ans);
	}
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define debg(a) cout<<#a<<" "<<a<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl;
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple

typedef long long ll;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef string str;
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  
  int n;
  cin>>n;
  int a=n-2;
  out(a*180);
   
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;cin >> s >> t;
    for(int i=0;i<s.size()+t.size();i++){
        if(i%2==0){
            cout << s[i/2];
        }
        else{
            cout << t[i/2];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String b = sc.next();
        if(b.equals("A")) System.out.println("T");
        if(b.equals("T")) System.out.println("A");
        if(b.equals("C")) System.out.println("G");
        if(b.equals("G")) System.out.println("C");
        sc.close();
    }

}


Measured memory_bytes: 22480
import collections
N = int(input())
S = [sorted(input()) for _ in range(N)]
Ssrt = []
for s in S:
    s = ''.join(s)
    Ssrt.append(s)
cnt = collections.Counter(Ssrt)
ans = 0
for i in cnt.keys():
    if cnt[i] >= 2:
        ans += cnt[i]*(cnt[i]-1)//2
print(ans)


Measured memory_bytes: 149340
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <climits>
using namespace std;

typedef vector <double> VD;
typedef vector <VD> VVD;

VVD C;	// cost
VD prev;
VD next;
int n;	// ì¿ÌíÞ
int m;	// ì¿ð^¦éñ
double answer;

void solve()
{
	prev = VD( n, 1.0 );
	next = VD( n );

	for ( int k = 1; k < m; k++ )
	{
		for ( int i = 0; i < n; i++ )
		{
			next[i] = -1.0;
			for ( int j = 0; j < n; j++ )
			{
				double tmp = prev[j] * C[j][i];
				next[i] = max( next[i], tmp );
			}
		}
		prev = next;
	}

	answer = -1.0;
	for ( int i = 0; i < n; i++ )
		answer = max( answer, prev[i] );
}

int main( void )
{
	while ( cin >> n >> m && n > 0 && m > 0 )
	{
		C = VVD( n, VD( n ) );

		// üÍ
		for ( int i = 0; i < n; i++ )
		{
			for ( int j = 0; j < n; j++ )
			{
				cin >> C[i][j];
			}
		}

		solve();

		cout.setf( ios::fixed );
		cout.precision( 2 );
		cout << answer << endl;
	}

	return 0;
}

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

int main (){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> v(100005);
    for(int i=0;i<n;i++){
        int d,val;
        cin>>d>>val;
        v[d].push_back(val);
    }
    long long int ans=0;
    priority_queue<int> q; 
    for(int i=1;i<=m;i++){
        for(int j=0;j<v[i].size();j++)  q.push(v[i][j]);
        if(!q.empty())  ans+=q.top(),q.pop();
    }
    cout<<ans;
    return 0;
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int diff = abs(A - B) - 1;

    if (diff %2 == 0)
        cout << "Borys" << endl;
    else
    {
        cout << "Alice" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=1000000007;
//string s=bitset<32>(n).to_string();
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    
        lli a,b,c;
        cin>>a>>b>>c;
        if(a+b+c>=22)cout<<"bust";else cout<<"win";
    


  return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    inputs = input().split()
    A = [int(i) for i in inputs]

    d = {}

    for i, AA in enumerate(A):
        d[AA] = i

    for i, dd in enumerate(d):
        if i < len(d) - 1:
            print(str(d[i+1] + 1) + ' ', end="")
        else:
            print(str(d[i+1] + 1))

if __name__ == "__main__":
    main()


Measured memory_bytes: 26220
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

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

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

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
14 13
158 167 181 147 178 151 179 182 176 169 180 129 175 168
181 150 178 179 167 180 176 169 182 177 175 159 173
)");
#define cin input
#endif

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

	vector<int> a(n), b(m);

	for (auto& i : a)
		cin >> i;
	
	sort(a.begin(), a.end());

	for (auto& i : b)
		cin >> i;

	sort(b.begin(), b.end());

	ll r = 1;

	auto ai = a.rbegin(), bi = b.rbegin();

	int c = 0;

	for (int i = m * n; i > 0; --i)
	{
		if (ai != a.rend() && *ai == i && bi != b.rend() && *bi == i)
		{
			c += ai - a.rbegin();
			c += bi - b.rbegin();
			++ai;
			++bi;

			if (ai != a.rend() && *ai == i || bi != b.rend() && *bi == i)
				r = 0;
		} else
		if (ai != a.rend() && *ai == i)
		{
			r *= bi - b.rbegin();
			c += bi - b.rbegin() - 1;
			++ai;

			if (ai != a.rend() && *ai == i)
				r = 0;
		} else
		if (bi != b.rend() && *bi == i)
		{
			r *= ai - a.rbegin();
			c += ai - a.rbegin() - 1;
			++bi;

			if (bi != b.rend() && *bi == i)
				r = 0;
		} else
		{
			r *= c;
			if (c)
				--c;
		}
		r %= 1000000007;
	}

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
bool used[8];

int fact(int k) {
    if (k == 0) return 1;
    return k * fact(k - 1);
}

int main() {
    int n;
    scanf("%d", &n);

    int a = 0;
    for(int i = 0 ;i < n; i++) used[i] = false;
    for(int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);

        used[x - 1] = true;
        int count = 0;
        for(int j = 0; j < x - 1; j++) if(!used[j]) count++;
        a += count * fact(n - i - 1);
    }

    int b = 0;
    for(int i = 0 ;i < n; i++) used[i] = false;
    for(int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);

        used[x - 1] = true;
        int count = 0;
        for(int j = 0; j < x - 1; j++) if(!used[j]) count++;
        b += count * fact(n - i - 1);
    }

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

Measured memory_bytes: 128
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#篩
num = 10 ** 6 + 1 #適当に値を入れる
L = [1 for i in range(num)]; L[0] = 0; L[1] = 0
plist = []
for i in range(num):
	if L[i] == 1:
		plist.append(i); c = 2
		while i * c <= num - 1:
			L[i * c] = 0; c += 1

def prime_factorization(N):
	D = defaultdict(int)
	for i in plist:
		while N % i == 0:
			D[i] += 1; N = int(N // i)

	if N != 1:
		D[N] += 1

	return D


#処理内容
def main():
	N = int(input())
	fac = prime_factorization(N)
	ans = 0
	# print(fac)
	for i in fac:
		for j in range(1, 100):
			if fac[i] < int((j * (j + 1) // 2)):
				ans += j - 1
				break

	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 149968
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
#define sz(x) (int)x.size() 
int const N=3e5+10,oo=1e9;
ll const OO=2e18;
double const eps=1e-8,PI=acos(-1);
int mod=oo+7;

int n,q,cum[N];
string s;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>n>>q;
  cin>>s;
  for(int i=0;i<n-1;i++){
  	if(s[i]=='A'&&s[i+1]=='C')cum[i+1]++;
  	cum[i+1]+=cum[i];
  }
  while(q--){
  	int l,r;
  	cin>>l>>r;
  	cout<<cum[r-1]-cum[l-1]<<'\n';
  }
  return 0;
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(1){
    c -= b;
    if(c<=0){
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if(a<=0){
      cout << "No" << endl;
      break;
    }
  }
}


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

int main() {
  int N;
  cin >> N;
  
  vector<long long> A(N), B(N);
  for(int i = 1; i < N; i++) {
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  int k = 0;
  
  for(int i = 0; i < N; i++) {
    for(int j = k; j < N; j++) {
      if(A.at(j) == i + 1) B.at(i)++;
      else if(A.at(j) > i + 1) break;
    }
    k += B.at(i);
  }
  
  for(int i = 0; i < N; i++) {
    cout << B.at(i) << endl; 
  }
  
}

Measured memory_bytes: 6396
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, M;
  std::cin >> N >> M;
  std::cout << (M < N ? "No" : "Yes") << std::endl;
  return 0;
}

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

const int N = 1e5 + 5;
long long n;

int bitcount(long long x){
    return x == 0? 0: bitcount(x/10) + 1;
}




int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    
    int m = sqrt(n+0.5);
    for (int i = m; i >= 2; i--){
        if(n%i == 0){
            cout<<bitcount(n/i)<<endl;
            return 0;
        }
    }
    cout<<bitcount(n)<<endl;
    
    
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new aoj0033().doIt();
	}
	class aoj0033{
		int a[] = new int [10];
		int num = -1;
		void doIt(){
			int n = sc.nextInt();
			for(int i = 0;i < n;i++){
				for(int j = 0;j < 10;j++){
					a[j] = sc.nextInt();
				}
				num = -1;
				if(dfs(0,0))System.out.println("YES");
				else System.out.println("NO");
			}
		}
		boolean dfs(int left,int right){
			num++;
			if(num == 10) return true;
			if(left < a[num])dfs(a[num],right);
			else if(right < a[num])dfs(left,a[num]);
			if(num == 10) return true;
			return false;
		}
	}
}

Measured memory_bytes: 18156
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define fr(i,n) for(i=0;i<n;i++)
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
const int mod = 1000000007;
const int nn = 1e5+5;
vector<int>edges[nn];
bool visited[nn];
int dist[nn];
int indegree[nn];
#define cc(x) cout << #x << " = " << x << endl
#define dd(x, y) cout << #x << " = " << x << " " << #y << " = " << y << endl
void dfs(int v){
    if(!visited[v]){
        visited[v]=true;
        for(int u:edges[v]){
            dist[u]=max(dist[u],dist[v]+1);
            indegree[u]--;
            if(indegree[u]==0){
                dfs(u);
            }
        }
        
        
    }
}
int main(){
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // int t;
    // cin>>t;
    // while(t--){
    int i,j,k,l,m,n,x=0,y=0,z=0,r,b,c,d,e,f,u,v;
    cin>>n>>m;
    fr(i,m){
        cin>>u>>v;
        edges[u].push_back(v);
        indegree[v]++;
    }
    fr(i,n){
        x=i+1;
        if(!visited[x]&&indegree[x]==0){
            dfs(x);
        }
    }
 fr(i,n){
     x=i+1;
     z=max(z,dist[x]);
 }
 cout<<z<<"\n";
}

Measured memory_bytes: 9728
import java.util.*;
// import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{

	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
	    int[] h = new int[n];
	    int[] dp = new int[n];
	   // int i =0;
	   // List<node> order = new ArrayList<node>();
		for(int i=0;i<n;i++)
		{
		    h[i] = sc.nextInt();
		    dp[i]= 2147483647;
		    if(i==0)
		        dp[i]=0;
		    else if(i==1)
		        dp[i] = dp[0]+Math.abs(h[i]-h[0]);
		    else
		        for(int j = 1;j<=k;j++)
		            dp[i] = Math.min(dp[i],i-j >=0?dp[i-j]+Math.abs(h[i]-h[i-j]):dp[i]);
		}
		System.out.print(dp[n-1]);
	}
}


Measured memory_bytes: 51712
// 2015/07/07 Tazoe

#include <iostream>
using namespace std;

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

	for(int i=0; i<N; i++){
		int x, y, b, p;
		cin >> x >> y >> b >> p;

		int f1 = x*b+y*p;		// 割引なし

		if(b<5){
			b = 5;
		}
		if(p<2){
			p = 2;
		}
		int f2 = (x*b+y*p)*4/5;		// 割引あり

		if(f1<f2){
			cout << f1 << endl;
		}
		else{
			cout << f2 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
N, M = map(int,input().split())
TF = [True]*(N+1)
for m in range(M):
  TF[int(input())] = False
dp = [0]*(N+1)
dp[0]=1
for n in range(N):
  if TF[n] and n<N:
    dp[n+1]+=dp[n]
  if TF[n] and n<N-1:
    dp[n+2]+=dp[n]
print(dp[N]%1000000007)

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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          if((a[2]-a[0])*(a[2]-a[1])<0)
            Console.WriteLine("Yes");
          else
            Console.WriteLine("No");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

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

    if(a==1 && b==2){
        cout<<3;
    }
    else if(a==2 &&b==1){
        cout<<3;
    }
    else if(a==3 && b==1){
        cout<<2;
    }
    else if(a==1 && b==3){
        cout<<2;
    }
    else if(a==2 && b==3){
        cout<<1;
    }
    else if(a==3 && b==2){
        cout<<1;
    }
    else{

    }




}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i = 0 ; i < n ; ++i)
#define rep1(i,n) for(int i = 1 ; i <= n ; ++i)
using namespace std;
int n;
int a[100010],b[100010],c[100010];
int dp[100010][3];
int main()
{
  cin >> n;
  rep(i,n) cin >> a[i] >> b[i] >> c[i];
  rep(i,n+1){
    rep(j,3){
      dp[i][j] = 0;
    }
  }
  
  rep(i,n){
    rep(j,3){
      if(j==0){
	dp[i+1][1] = max( dp[i+1][1] , dp[i][j]+b[i] );
	dp[i+1][2] = max( dp[i+1][2] , dp[i][j]+c[i] );	  
      }
      else if(j==1){
	dp[i+1][0] = max( dp[i+1][0] , dp[i][j]+a[i] );
	dp[i+1][2] = max( dp[i+1][2] , dp[i][j]+c[i] );	  
      }
      else {
	dp[i+1][0] = max( dp[i+1][0] , dp[i][j]+a[i] );
	dp[i+1][1] = max( dp[i+1][1] , dp[i][j]+b[i] );	  
      }      
    }
  }
  cout << max( max( dp[n][0] , dp[n][1] ) , dp[n][2]) << "\n";
  return 0;
}


Measured memory_bytes: 2560
n = int(input())
a_array = [int(x) for x in input().split()]

avg = sum(a_array)/n

res = 1000000
ret = 0
for i, j in enumerate(a_array, 0):
    if abs(j-avg) < res:
        res = abs(j-avg)
        ret = i
print(ret)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define size_t unsigned long long int 
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define INF 0x3f3f3f3f
#define FASTIO ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(0)
#define PI acos(-1)
using namespace std;
void solve()
{
   int a;
   cin>>a;
   cout<<a+(a*a)+(a*a*a);
}
int main()
{
    FASTIO;
    size_t  t;
    t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
   return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
#define N 1000
#define N2 N*N
bool prime[N2+1];
int cave[N+2][N+2]={};
pair<int,int> locate[N2+1];
int last[N+2][N+2];
int dp[N+2][N+2];
int m,n;

bool wall(int x,int y){ return x==0 || y==0 || x==N+1 || y==N+1; }

int rec(int x,int y){
    int value = cave[x][y];
    if(wall(x,y) || value>m)return 0;
    if(dp[x][y])return dp[x][y];
    pair<int,int> child[3];
    rep(i,3)child[i]=pair<int,int>(rec(x+i-1,y-1),last[x+i-1][y-1]);
    sort(child,child+3);
    dp[x][y]=child[2].first;
    if(prime[value])dp[x][y]++;
    last[x][y]=child[2].second;
    if(last[x][y]==0 && prime[value]) last[x][y]=value;
    return dp[x][y];
}

int main(void){
    rep1(i,N2)prime[i]=true;
    prime[0]=prime[1]=false;
    for(int i=2;i<=N2;i++){
        if(prime[i]) for(int k=2;i*k<=N2;k++) prime[i*k]=false;
    }

    int x=1,y=N,d=0;
    int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
    for(int i=N2;i>0;i--){
        cave[x][y]=i;
        locate[i] = pair<int,int>(x,y);
        if(wall(x+dx[d],y+dy[d]) || cave[x+dx[d]][y+dy[d]]) d=(d+1)%4;
        x+=dx[d];
        y+=dy[d];
    }

    while(cin>>m>>n, m|n){
        rep1(x,N)rep1(y,N) dp[x][y]=last[x][y]=0;
        int x=locate[n].first,y=locate[n].second;
        int cnt = rec(x,y);
        cout<<cnt<<" "<<last[x][y]<<endl;
    }

    return 0;
}

Measured memory_bytes: 21824
#!/usr/bin/env python3
import sys
import string
import itertools


def solve(s: str, K: int):

    part_set = set()
    for c in string.ascii_lowercase:
        for i in range(len(s)):
            if c == s[i]:
                part_set |= set(itertools.accumulate(s[i:min(i+K,len(s))]))
        if len(part_set) >= K:
            print(sorted(part_set)[K-1])
            return
                


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    K = int(next(tokens))  # type: int
    solve(s, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ll h, n, sum = 0;
  cin >> h >> n;
  rep(i, n) {
    int a;
    cin >> a;
    sum += a;
  }
  if (h > sum)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin>>x;
  if(x == 1) cout<<0<<endl;
  else cout << 1<<endl;

  return 0;
}


Measured memory_bytes: 3184
#include "stdio.h"

int main(){
    int A500,B100,C50,target,ret;
	int addVal;
  	int retVal = 0;
    //情報を取得
    ret = scanf("%d",&A500);
    ret = scanf("%d",&B100);
    ret = scanf("%d",&C50);
    ret = scanf("%d",&target);
  	
  	int iiA,iiB,iiC;
  	for(iiA=0;iiA<=A500;iiA++){
      for(iiB=0;iiB<=B100;iiB++){
        for(iiC=0;iiC<=C50;iiC++){
          addVal=(iiA*500)+(iiB*100)+(iiC*50);

          if(addVal == target)
            retVal++;
        }
      }
    }
 
	printf("%d",retVal);
  
	return 0; 
}

Measured memory_bytes: 128