akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using static Input;
class Program
{
    public class node
    {
        public node pnode;
        public List<node> lstNode = new List<node>();
        public long value;
    }
    static int N;
    static int Q;
    static node[] a;
    static void INPUT()
    {
        N = NextInt();
        Q = NextInt();
        a = new node[N];
        for (int i = 0; i < N; i++)
        {
            a[i] = new node();
        }
        for (int i = 0;  i < N - 1; i++)
        {
            var t = LineInt();
            a[t[0]-1].lstNode.Add(a[t[1]-1]);
            a[t[1]-1].lstNode.Add(a[t[0]-1]);
        }
        for (int i = 0; i < Q; i++)
        {
            var t = LineInt();
            a[t[0]-1].value += t[1];
        }
    }
    static void OUTPUT()
    {
        foreach (var n in a)
        {
            if (n.pnode != null)
                n.value += n.pnode.value;
            foreach (var c in n.lstNode)
            {
                if (n == c)
                    continue;
                c.pnode = n;
            }
        }

        foreach (var n in a)
        {
            Console.WriteLine(n.value);
        }
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();
#else
        INPUT();
#endif
        OUTPUT();
    }

    static void TESTINPUT()
    {
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}



Measured memory_bytes: 54780
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int calc(set<int> now){
    int res = infi;
    for(auto x:now){
        //cout << x << " ";
        for (auto y:now){
            if(x==y)
                continue;
            int z = abs(x - y);
            res = min(res, min(z, 24 - z));
        }
    }
    //cout << endl;
    return res;
}


int main()
{
    int n;
    cin >> n;
    vii d(n);
    rep(i, n) cin >> d[i];
    vii cnt(13, 0);
    rep(i,n){
        if (d[i]==0){
            cout << 0 << endl;
            return 0;
        }
        cnt[d[i]]++;
    }
    set<int> kakutei;
    vector<pii> choice;
    choice.push_back(mp(0, 24));
    rep(i,13){
        if (cnt[i]>2){
            cout << 0 << endl;
            return 0;
        }
        else if (cnt[i]==2){
            kakutei.insert(i);
            kakutei.insert(24 - i);
        }
        else if (cnt[i]==1){
            choice.push_back(mp(i, 24 - i));
        }
    }
    int ans = 0;
    rep(s,1<<(choice.size())){
        set<int> now(kakutei);
        rep(i,choice.size()){
            if ((s>>i)&1){
                now.insert(choice[i].F);
            }
            else {
                now.insert(choice[i].S);
            }
        }
        ans = max(ans, calc(now));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
typedef vector<int> vi;

int main() {
	int n;
	while (scanf("%d", &n)&&n!=0) {
		vi stu(n*n);
		for (int i=0; i<n*n; i++) scanf("%d", &stu[i]);
		vi row(n,1000000), col(n,0);
		for (int i=0; i<n; i++) {
			for (int j=i*n; j<(i+1)*n; j++) row[i] = min(row[i], stu[j]);
		}
		for (int i=0; i<n; i++) {
			for (int j=i; j<n*n; j+=n) col[i] = max(col[i], stu[j]); 
		}
		int res = 0;
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				if (row[i]==col[j]) res = row[i];
			}
		}
		printf("%d\n",res);
	}
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
   long N, M;
   cin >> N >> M;
   long ans = 1;
   for(long i=1; i * i <= M; i++) {
       if(M % i == 0) {
           long i_pair = M / i;
           if(N <= i_pair) {
               ans = max(ans, i);
           }
           if(N <= i) {
               ans = max(i_pair, ans);
           }
        }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define M 1000000007

static inline unsigned gcd(unsigned s, unsigned t)
{
  unsigned r;
  if (t == 0) return s;
  for ( ;(r = s % t) != 0; s = t, t = r);
  return t;
}

static inline int inverse(int a)
{
  int x = 1, g = a % M, v = 0, w = M, s, t, q;

  while (w != 0) {
    q = g / w;
    t = g - q * w;
    s = x - q * v;
    x = v;
    g = w;
    v = s;
    w = t;
  }

  x %= M;

  if (x < 0) x += M;

  return x;
}

int
main(int ac, char *av[])
{
  int n;
  unsigned A[10000];
  unsigned L[10000];
  unsigned g, u;
  unsigned long ll = 1, z = 0;

  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%u", &A[i]);
    L[i] = 1u;
  }

  for (int i = 0; i < n; ++i) {
    unsigned a = A[i];

    g = gcd(L[i], a);

    u = a / g;

    z = (z * u + ll * inverse(g)) % M;

    ll = (ll * u) % M;

    for (int j = i + 1; j < n; ++j) {
      L[j] = (unsigned long) L[j] * u % A[j];
    }
  }

  printf("%lu\n", z);

  return 0;
}


Measured memory_bytes: 1740
def resolve():
  N = int(input())
  A = [int(x) for x in input().split(" ")]
  if N == 0 and A[0] != 1:
    print(-1)
    return True
  min_maxs = {}
  min_maxs[len(A)-1] = [A[-1], A[-1]]

  for index in reversed(range(len(A)-1)):
    min_maxs[index] = [min_maxs[index+1][0] // 2 + A[index], min_maxs[index+1][1] + A[index]]
  # print(min_maxs)
    # min_maxs.insert(0, [min_maxs[0][0] // 2 + a, min_maxs[0][1] + a])
  # print(min_maxs)
  # max_node_in_depth = [sum(A[i:]) for i in range(len(A))]

  # # 各 depth における最小値
  # min_node_in_depth = [0] * (len(A))
  # min_node_in_depth[-1] = max_node_in_depth[-1]
  # index = -1
  # for i in range(1, len(A)):
  #   min_node_in_depth[index] = -(-min_node_in_depth[index + 1] // 2) + A[index]
  #   index = index - 1

  # for min_max in min_maxs:
  #   print(min_max)

  result = 1
  recent = 1
  for index in range(1, len(A)):
    num_of_node = (recent - A[index-1]) * 2
    # print(min_max, num_of_node)
    if num_of_node < min_maxs[index][0]:
      print(-1)
      return True
    
    result += min(num_of_node, min_maxs[index][1])
    recent = min(num_of_node, min_maxs[index][1])

  print(result)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 94924
#include <stdio.h>
/*ABC 135 B*/
void swap (int *x, int *y){/*swap を作る*/
	int temp;/*値を一時保存する変数*/

	temp = *x;
	*x = *y;
	*y = temp;
}

int main(void)
{
  int N;
  int p[50];
  int count = 0;

  scanf("%d", &N);
  for (size_t i = 0; i < N; i++) {
    scanf("%d", &p[i]);
  }

  for (size_t i = 0; i < N-1; i++) {
    if (p[i] > p[i+1]) {
      count = 1;
      break;
    }
  }

  for (size_t i = 0; i < N; i++) {
    if (count == 0) break;
    for (size_t j = 0; j < N; j++) {
      if (count == 0)break;
      if(i != j ){
        count = 0;
        swap(&p[i],&p[j]);
      }
      for (size_t k = 0; k < N-1; k++) {
        if (p[k] > p[k+1]){
          count = 1;
          break;
        }
      }
      swap(&p[i],&p[j]);
    }
  }
  
  if(count == 0)printf("YES\n");
  else printf("NO\n");
}


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


int main() {
	int n,k,q;
    cin>>n>>k>>q;
    vector<int> tr(q);
    vector<int> a(n,0); //初期値０
    
    rep(i,q){
        cin>>tr[i];
        a[tr[i]-1]++;
    }
	
    rep(i,n){
        //cout<<a[i];
        if(a[i]>q-k)  cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    
}


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

int main(){
    int N, tmp,max;
    cin >> N;
    vector<int> H(N);
    cin >> H[0];
    max = 0;
    tmp = 0;
    for(int i = 1; i < N; i++){
        cin >> H[i];
        if(H[i] > H[i-1]){
            if(tmp > max){
                max = tmp;
            }
            tmp = 0;
            continue;
        }
        tmp++;
    }
    if(tmp > max){
        max = tmp;
    }
    cout << max << endl;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)

func digitSum(num int)int {
	digitSum := 0
	for num > 0 {
		digitSum += num % 10
		num /= 10
	}
	return digitSum
}

func main() {
	var n,a,b int
	fmt.Scan(&n,&a,&b)
	
	sum := 0
	for i := 1; i <= n; i++ {
		v := digitSum(i)
		if v >= a && v <= b {
			sum += i
		}
	}
	fmt.Println(sum)
}

Measured memory_bytes: 512
import heapq
s = raw_input()
k = int(raw_input())

heap = [(s[i], i) for i in range(len(s))]
heapq.heapify(heap)
seen = set()
while(k and heap):
	t,ii = heapq.heappop(heap)
	if t not in seen:
		seen.add(t)
		k-=1
		if k == 0:
			print t
	if ii + 1 < len(s):
		heapq.heappush(heap, (t + s[ii+1], ii+1))
	


Measured memory_bytes: 85428
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first first
#define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;

signed main(){
    string s;
    cin >> s;
    rep(i, 0, 4){
        cout << s[i];
    }
    cout << " ";
    rep(i, 4, 12){
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
d = {}
for a in A:
    d[a - 1] = d.setdefault(a - 1, 0) + 1
    d[a] = d.setdefault(a, 0) + 1
    d[a + 1] = d.setdefault(a + 1, 0) + 1

print(max(d.values()))


Measured memory_bytes: 19756
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define y1 shinkle
#define fi first
#define se second
#define bg begin
cs int RLEN=1<<20|1;
inline char gc(){
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();
	return ch;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}
template<typename tp>inline void chemx(tp &a,tp b){a=max(a,b);}
template<typename tp>inline void chemn(tp &a,tp b){a=min(a,b);}
cs int mod=998244353;
inline int add(int a,int b){return (a+b)>=mod?(a+b-mod):(a+b);}
inline int dec(int a,int b){return (a<b)?(a-b+mod):(a-b);}
inline int mul(int a,int b){static ll r;r=(ll)a*b;return (r>=mod)?(r%mod):r;}
inline void Add(int &a,int b){a=(a+b)>=mod?(a+b-mod):(a+b);}
inline void Dec(int &a,int b){a=(a<b)?(a-b+mod):(a-b);}
inline void Mul(int &a,int b){static ll r;r=(ll)a*b;a=(r>=mod)?(r%mod):r;}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(Mul(res,a),1);return res;}
inline int Inv(int x){return ksm(x,mod-2);}
inline int fix(ll x){x%=mod;return (x<0)?x+mod:x;}
cs int N=1000005;
int fac[N],ifac[N];
inline void init_fac(){
	fac[0]=ifac[0]=1;
	for(int i=1;i<N;i++)fac[i]=mul(fac[i-1],i);
	ifac[N-1]=Inv(fac[N-1]);
	for(int i=N-2;i;i--)ifac[i]=mul(ifac[i+1],i+1);
}
inline int C(int n,int m){return (n<m||n<0||m<0)?0:mul(fac[n],mul(ifac[m],ifac[n-m]));}
int n,k;
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	init_fac();
	n=read(),k=read();int res=0;
	if(k<n)return puts("0"),0;
	for(int r=(k/2)+1;r<=k;r++){
		int b=k-r;
		if(r<b)continue;
		Add(res,dec(C(k,r),C(k,2*r-n+1)));
	}
	if(!(k&1))Add(res,dec(C(k-1,k/2),C(k-1,k-n+1)));
	cout<<res<<'\n';return 0;
}


Measured memory_bytes: 8448
def sieve():
    L = 1299710
    primes = []
    isPrime = [ True for _ in range(L) ]
    for i in range(2, L):
        if isPrime[i]:
            primes.append(i)
            for j in range(i * i, L, i):
                isPrime[j] = False
    return primes

def getPrimeGap(num, primes):
    if num in primes:
        return 0

    for i in range(100000 - 1):
        if primes[i] < num and primes[i + 1] > num:
            return primes[i + 1] - primes[i]

if __name__ == '__main__':
    primes = sieve()
    while True:
        num = int(input())
        if num == 0:
            break

        print(getPrimeGap(num, primes))


Measured memory_bytes: 19620
#include <iostream>
#include <algorithm>
using namespace std;
#include <vector>
#include <map>
#include <set>
#include <cmath>    //floor ceil
#include <cstdio>
#include <climits>  //INT_MAX
#include <cstring>
#include <cstdlib>
#define debug(x) cerr<<#x<<'='<<(x)<<endl;

#define endl '\n'
#define lli long long int

int main () {
    lli ans=0;
    int n;
    cin >> n;
    int a[n];
    for (int i=0;i<n;i++) {
        cin >> a[i];
        if(i!=0 && a[i]<a[i-1]) ans += a[i-1]-a[i],a[i]=a[i-1];
        //debug(ans);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

    ll max = floor(a * min(b - 1, n) / b) - a * floor(min(b - 1, n) / b);

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest._400Problems_remain_
{
    class CF2017Final_B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Read();
            int[] cnts = new int[3];
            for(int i = 0; i < s.Length; i++)
            {
                cnts[s[i] - 'a']++;
            }
            Array.Sort(cnts);
            Console.WriteLine(cnts[2] - cnts[0] <= 1 ? "YES" : "NO");
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
 
int main(void)
{
  int W, H, x, y, r;
 scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

 if( ((W >= x + r) && (x - r >= 0)) && ((H >= y + r) && (y - r >= 0)) ) 
  printf("Yes\n"); 
 else printf("No\n");
return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int b, r, g, c, s, t;
    while(cin >> b>> r >> g >> c >> s >> t, b+r+g+c+s+t != 0){
        int ans = 100;
        int bonus = 0;

        ans += b*15;
        bonus += b*5;
        ans += r*15;
        bonus += r*3;
        ans += g*7 + c*2;

        ans += bonus*15;
        ans -= (t-s)*3;
        ans += bonus;

        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int h,w;
char f[105][105];

int main()
{
    cin >> h >> w;
    for (int i = 1;i <= h;i++){
        for (int j = 1;j <= w;j++){
            cin >> f[i][j];
        }
    }
    
    int dp[105][105];
    
    for (int i = 1;i <= h;i++){
        for (int j = 1;j <= w;j++){
            if (i == 1 && j == 1){
                if (f[i][j] == '#'){
                    dp[i][j] = 1;
                }
                else {
                    dp[i][j] = 0;
                }
            }
            else if (i == 1 && j != 1){
                if (f[i][j] == '#' && f[i][j-1] == '.'){
                    dp[i][j] = dp[i][j-1] + 1;
                }
                else {
                    dp[i][j] = dp[i][j-1];
                }
            }
            else if (i != 1 && j == 1){
                if (f[i][j] == '#' && f[i-1][j] == '.'){
                    dp[i][j] = dp[i-1][j] + 1;
                }
                else {
                    dp[i][j] = dp[i-1][j];
                }
            }
            else {
                int k = dp[i-1][j];
                int l = dp[i][j-1];
                if (f[i][j] == '#' && f[i-1][j] == '.'){
                    k += 1;
                }
                if (f[i][j] == '#' && f[i][j-1] == '.'){
                    l += 1;
                }
                
                dp[i][j] = min(k,l);
            }
        }
    }
    cout << dp[h][w] << endl;
}


Measured memory_bytes: 256
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

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

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }
ll power(ll n , ll k) { if(k == 0) return 1 ; if(k&1) return n*sqr(power(n,k/2)) ; else return sqr(power(n,k/2)); }

const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;
const   int dx[] =   {+1,+2,+2,+1,-1,-2,-2,-1};
const   int dy[] =   {-2,-1,+1,+2,+2,+1,-1,-2};

int main() {ikarus_101

    ll n,m,i,j,k,x;

    cin>>n;
    vll a(n),b(n),v(n);
    vin(a);
    vin(b);
    iota(all(v),1);
    for(i=1;;i++) {
        if(v == a) {
            break;
        }
        next_permutation(all(v));
    }
    v.resize(n);
    iota(all(v),1);
    for(j=1;;j++) {
        if(v == b) {
            break;
        }
        next_permutation(all(v));
    }

    cout << abs(i-j) << endl;













    return 0;
}


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

#define int long long

#define rep(i, n) for (signed i = 0; i < signed(n); i++)
#define REP(i, s, n) for (signed i = signed(s); i < signed(n); i++)
#define rrep(i, n) for (signed i = signed(s) - 1; i >= 0; i--)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, const T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }


void calc() {
	string s; cin >> s;
	int N = s.size();
	int a = 0, b = N - 1;
	int ans = 0;
	while(a < b) {
		if (s[a] != s[b]) {
			if (s[a] == 'x') {
				a++;
				ans++;
			} else if (s[b] == 'x') {
				b--;
				ans++;
			} else {
				cout << -1 << endl;
				return;
			}
		} else {
			a++; b--;
		}
	}

	cout << ans << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	calc();
#ifdef _MSC_VER
	system("pause");
#endif
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

const int N = 100010;
int n, m;
char s[N], s1[N];
int vis[N];

inline bool check(char s[])
{
	int l = strlen(s);
	for (int i = 0; i < l/2; i ++)
		if (s[i] != s[l-1-i]) return false;
	return true;
}

int main()
{
	scanf("%s", s); n = strlen(s);
	m = 0; int cntx = 0;
	for (int i = 0; i < n; i ++){
		if (s[i] != 'x') s1[m ++] = s[i];
		else vis[m] ++;
	}
	s1[m] = '\0';
	if (!check(s1)){ puts("-1"); return 0; }
	int ans = 0;
	for (int i = 0; i <= m/2; i ++)
		if (vis[i] != vis[m-i]) ans += abs(vis[i]-vis[m-i]);
	printf("%d\n", ans);
	return 0;
}

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

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define LL long long
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;

template<typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}

LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}

template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) {
	return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) {
	return min(a, Smin(args...));
}

template <typename T>
#define errorl(args...) {  \
	string _s = #args;   \
	replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    errl(_it, args);  \
}
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}
#define error(args...) {  \
    string _s = #args;  \
    replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    err(_it, args);  \
    cerr<<endl; \
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}


char s[N];
void Solve() {
	cin>>s;
	int n=strlen(s);
	int zero=1,sum=0;
	for(int i=0;i<n;i++){
		if(i&&s[i]!='0')zero=0;
		sum+=s[i]-'0';
	}
	if(s[0]=='1'&&zero)cout<<10<<'\n';
	else cout<<sum<<'\n';

}


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//  freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}


Measured memory_bytes: 3600
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//---------------------------------------------------------------------------
bool color[200001];
//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,k;cin>>n>>k;
    cout<<n-k+1<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------

/*
ll n;cin>>n;
vector<ll>a(n);
for(ll i=0;i<n;i++)
    cin>>a[i];
 
ll n;cin>>s;
string s;cin>>s;

ll n,m;cin>>n>>m;
vector<ll>a(n),b(m);
for(ll i=0;i<n;i++){
    cin>>a[i];
}
for(ll i=0;i<m;i++){
    cin>>b[i];
}

ll n;cin>>n;
vector<Pll>xy;
for(ll i=0;i<n;i++){
    ll x,y;cin>>x>>y;
    xy.pb({x,y});
}
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = 998244353;


signed main() {
    int n;
    cin >> n;
    vector<int> d(n, 0);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        d[x]++;
        if ((i == 0 && x != 0) || (i != 0 && x == 0)) {
            cout << 0 << "\n";
            return 0;
        }
    }
    int ans = 1;
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < d[i]; j++)
            ans = ans * d[i - 1] % MOD;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
import numpy as np

def main():
    n, k, q = map(int, input().split())
    
    ls = [q] * n

    rls = [k] * n

    maru_list = [0] * n

    ls = np.array(ls)
    rls = np.array(rls)
    maru_list = np.array(maru_list)

    for i in range(q):
        maru = int(input())
        maru_list[maru-1] += 1

    ls = ls - maru_list

    rls = rls - ls

    for i in range(n):
        print('Yes' if rls[i] > 0 else 'No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 15972
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  sort(A.begin(), A.end());
  for(int i=1; i<N; ++i) {
    if(A[i] == A[i-1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


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

int main(){
  long long int a,b,c,k;
  cin >> a >> b >> c >> k;
  long long int ans = (k % 2) == 0 ? a-b : b-a;
  if(abs(ans) > 1e18) cout << "Unfair" << endl;
  else cout << ans << endl;
  return 0;
}

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

int main(){
	int n,i,ans = 0;
	string str;
	cin >> n;
	cin >> str;
	for(i = 0; i < n - 2; i++){
		if(str[i] == 'A'){
			if(str[i+1] == 'B'){
				if(str[i+2] == 'C'){
					ans++;
				}
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

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

int main() {
	char b;
	cin>>b;
	char ans = 'C';
	if(b == 'A')ans = 'T';
	if(b == 'T')ans = 'A';
	if(b == 'C')ans = 'G';
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstring>
#include <iomanip>
using namespace std;

void solve(){
  double res = 0.0;
  int num = 0;
  int N;
  cin >> N;
  vector<int> x(N), y(N);
  for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];

  vector<int> vec(N);
  iota(vec.begin(), vec.end(), 1);

  double dist[10][10];
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) dist[i][j] = -1.0;
  }

  do {
    double tmp_dist = 0.0;
    for (int i = 0; i+1 < N; ++i) {
      int l = vec[i] - 1;
      int r = vec[i+1] - 1;
      if(dist[r][l] < 0) dist[l][r] = sqrt((x[l] - x[r]) * (x[l] - x[r]) + (y[l] - y[r]) * (y[l] - y[r]));
      else dist[l][r] = dist[r][l];
      tmp_dist += dist[l][r];
    }
    num++;
    res += tmp_dist;
  }while(next_permutation(vec.begin(), vec.end()));

  cout << setprecision(16) << (res) / num << endl;
}

int main(void) {

  solve(); 
  return 0;
}

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

char str[100];

int max(int a,int b){
    if(a>b)return a;
    return b;
}

int min(int a,int b){
    if(a<b)return a;
    return b;
}

void getInput(char *pstr)
{
    fgets(pstr, sizeof(str), stdin);
}

int main() {
    char *pstr = &str[0];
    int D, G = 0;
    int p[10], c[10];
    
    /* 標準入力の処理 */
    getInput(pstr);
    D = atoi(strtok(pstr, " "));
    G = atoi(strtok(NULL, " "));
    for (int i = 0; i < D; i++)
    {
        getInput(pstr);
        p[i] = atoi(strtok(pstr, " "));
        c[i] = atoi(strtok(NULL, " "));
    }
    
    int result = 100000000;
    /* 計算 */
    for(int i = 0; i < pow(2, D); i++){
        int bit = i;
        int currentValue = 0;
        int count = 0;
        int maxNotCmp = -1;
        for(int j = 0; j < D; j++){
            if ((bit >> j) % 2 == 1) {
                currentValue += 100 * (j + 1) * p[j] + c[j];
                count += p[j];
            } else {
                maxNotCmp = max(maxNotCmp, j);
            }
        }
        if(currentValue < G){
            int need = G - currentValue;
            if (need > 100 * (maxNotCmp + 1) * (p[maxNotCmp] - 1)) {
                continue;
            }
            count += (need + 100 * (maxNotCmp + 1) - 1) / (100 * (maxNotCmp + 1));
        }
        result = min(result, count);
    }
    /* 結果の出力 */
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int manhattanDist(Pii& p1, Pii& p2)
{
    int x1 = p1.FIR, y1 = p1.SEC;
    int x2 = p2.FIR, y2 = p2.SEC;
    return abs(x1 - x2) + abs(y1 - y2);
};

void solveSingleCase(int caseNo)
{
    int N, M;
    cin >> N >> M;
    VEC(Pii) students(N), checkpoints(M);
    READVEC(students);
    READVEC(checkpoints);

    for (Pii st : students) {
        int best = -1, bestDistance = 0;
        FOR(j, 0, M) {
            if (best < 0 || manhattanDist(st, checkpoints[j]) < bestDistance) {
                best = j;
                bestDistance = manhattanDist(st, checkpoints[j]);
            }
        }
        cout << ++best << endl;
    }
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	a := nextInt()
	b := nextInt()
	c := nextInt()
	if a+b >= c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>

using namespace std;

int n, x;

int solve()
{
    int cnt = 0;
    for(int i = 1; i < n; i++){
        for(int j = i + 1; j < n; j++){ 
            for(int k = j + 1; k <= n; k++){
                if((i + j + k) == x) cnt++;
            }
        }
    }
    return cnt;
    
}

int main()
{
    while(1){
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        cout << solve() << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var x = cin.ReadLong;
            var a = cin.ReadLongArray(N);

            long ans = Max(a[0] - x, 0);
            for (int i = 0; i < N - 1; ++i)
                if (a[i] + a[i + 1] > x)
                {
                    long diff = a[i] + a[i + 1] - x;
                    ans += Min(diff, a[i + 1]);
                    a[i + 1] -= Min(diff, a[i + 1]);
                }
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
    }
}


Measured memory_bytes: 29404
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int dp[N][3];

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
    }
    cout << *max_element(dp[n], dp[n]+3);
    return 0;
}


Measured memory_bytes: 1408
/*

*/
#include<bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,a,n) for(int i=(a);i<(n);i++)
#define repe(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
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; }

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int l,r,d,cnt=0;cin>>l>>r>>d;
  rep2(i,l,r+1){
    if(i%d==0)cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {double T,X;
            cin>>T>>X;
            cout << T/X << endl;
}

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

int main(){
    int n, ans, m;
    cin >> n;
    while(n > 0){
        ans = 0;
        m = 2;
        while(1){
            if( m%2 == 0 ){
                if( n/m < m/2 ) break;
                if( n%m == m/2 ) ans++;
            }else{
                if( n/m < m/2+1) break;
                if( n%m == 0 ) ans++;
            }
            m++;
        }
        cout << ans << endl;
        cin >> n;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define FastRead                      \
                        ios_base::sync_with_stdio(false); \
                        cin.tie(0);
#define endl "\n"
using namespace std;
int main()

{
    FastRead
    long long int t,i,a1,a2,b1,b2;
    cin>>t;
    cout<<t+pow(t,2)+pow(t,3);
    return 0;

}


Measured memory_bytes: 4200
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int l[205];
int main()
{
	int num=0;
	scanf("%d",&n);
	n*=2;
	for(int i=1;i<=n;i++)
		scanf("%d",&l[i]);
	sort(l+1,l+1+n);
	for(int i=n-1;i>=1;i-=2)
	{
		num+=l[i];
	}
	printf("%d\n",num);
}//

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args) {
        int no1 = 0;
        int no2 = 0;
        int no3 = 0;
        Scanner sc = new Scanner(System.in);
        for(int i = 0; i < 10; i++) {
            String line = sc.nextLine();
            int h = Integer.parseInt(line);
            if(h > no1) {
                int a = no1;
                int b = no2;
                no2 = a;
                no3 = b;
                no1 = h;
                continue;
            }else if(h > no2) {
                no3 = no2;
                no2 = h;
                continue;
            }else if(h > no3) {
                no3 = h;
                continue;
            }
        }
        System.out.println(no1);
        System.out.println(no2);
        System.out.println(no3);
     
    }
 } 


Measured memory_bytes: 26068
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    string S;
    cin>>S;
    int k=S.size(),lose=0;
    rep(i,k){
        if(S[i]=='x') lose++;
    }
    if(lose>7) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
//Java8(OpenJDK 1.8.0)
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Solve s= new Solve();
		s.solve();
	}

}
class Solve{
	 Scanner sc = new Scanner(System.in) ;
	 void solve() {
		
		 int s_before =sc.nextInt();
	
		
		 
		 
		 System.out.println(s_before*s_before*3);

	 }
}

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

class Program
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var array = new int[N];
        var ans = 0L;
        var count = 0L;
        for (int i = 0; i < N; ++i)
        {
            if (N <= A[i])
            {
                Console.WriteLine(ans);
                return;
            }
            array[A[i]]++;
        }
        for (int i=0;i<N;++i)
        {
            if (i == 0)
            {
                if (N % 2 == 1 && array[i] == 1
                    || N % 2 == 0 && array[i] == 0) continue;
                else
                {
                    Console.WriteLine(ans);
                    return;
                }
            }
            if (2 == array[i])
            {
                count++;
                continue;
            }
            if (0 != array[i])
            {
                Console.WriteLine(ans);
                return;
            }
            
        }
        ans = 1;
        for (int i=0;i<count;++i)
        {
            ans = (ans * 2) % 1000000007; 
        }
        Console.WriteLine(ans);
    }
}

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

int main(){
  int N;
  string S;
  cin>>N;
  cin>>S;
  map<char,int>mp;
  long long cnt=1;
  for(int i=0;i<N;i++){
    mp[S.at(i)]++;
  }
  for(char c='a';c<='z';c++){
    if(mp[c]){
      cnt=(cnt*(mp[c]+1))%1000000007;
    }
  }
  cout<<cnt-1<<endl;
  return 0;
}
  

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

#define mod 1000000007

#define rep(i, n) for(int i=0; i<n; ++i)

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	ll x;
	
	cin >> x;
	
	cout << 2 * (x / 11) + (x % 11 >= 1) + (x % 11 >= 7) << endl;
	
	return 0;
}

Measured memory_bytes: 256