akhauriyash/Code-Regression huggingface dataset:
N=int(input())
txy=[[int(j) for j in input().split()] for i in range(N)]
txy.insert(0,[0,0,0])
ans=True

for i in range(N):
	dtxy=[abs(txy[i+1][j] -txy[i][j]) for j in range(3)]
	if (dtxy[0]<sum(dtxy[1:])) or (dtxy[0]%2 != sum(dtxy[1:])%2):
		ans=False
		break
if ans:
	print("Yes")
else:
	print("No")


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

#define ll long long

using namespace std;

int n, a[100], b[100], c[100];
int main() {
    cin >> n;
    for (int i = 1; i <=n; ++i)
        cin >> a[i];
    for (int i = 1; i <= n; ++i)
        cin >> b[i];
    for (int i = 1; i <= n - 1; ++i)
        cin >> c[i];

    int sol = 0;
    for (int i = 1; i <= n; ++i) {
        sol += b[a[i]];
        if (i > 1 && a[i] == a[i - 1] + 1)
            sol += c[a[i - 1]];
    }

    cout << sol;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    int N;
    cin >> N;
    vector<LL> A(N,0);
    REP(i,N)cin>>A[i];

    LL four_count = 0;
    LL two_count = 0;
    REP(i,N){
        if(A[i]%4==0){
            four_count++;
        }else if(A[i]%2==0){
            two_count++;
        }
    }

    LL ans = 0;
    if(N >= 2){
        if (two_count>1){
            ans = (N-1) - 2*four_count - (two_count-1);
        }else{
            ans = (N-1) - 2*four_count;
        }
    }else{
        ans = 1 - four_count;
    }
    
    if(ans <= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4024
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>
#include <iomanip>
#include <sstream>
#include <unordered_map>

using namespace std;
typedef long long ll;


ll ans, mx, mn, flag, sum, cnt;


int main(){
	ll n;
	cin>>n;
	ll a[n],b[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	for(ll i=0; i<n; i++){
		if(a[i]!=b[i]) ans++;
	}
	if(ans==2 || ans==0) cout<<"YES";
	else cout<<"NO";
}


Measured memory_bytes: 256
S = input().strip()
if (int(S[:2])>12 or int(S[:2])==0) and 0<int(S[2:])<=12:
    print("YYMM")
elif 0<int(S[:2])<=12 and (int(S[2:])==0 or int(S[2:])>12):
    print("MMYY")
elif 0<int(S[:2])<=12 and 0<int(S[2:])<=12:
    print("AMBIGUOUS")
else:
    print("NA")

Measured memory_bytes: 3064
/*
 * bubble sort
 *
 *
 */
#include<stdio.h>
int A[100];

//Output function
void printSequence(int length, int num){
    int i;
    for(i=0; i<length; i++){
        if(i!=0)printf(" ");
        printf("%d",A[i]);
    }

    printf("\n");
    printf("%d\n",num);

}

int main(void){
    int key=0, num=0, length, i, j;

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


    //Bubble Sort Algo
    for(i=0; i<=length-1; i++){
        for(j=length-1; j>=i+1; j--){
            if(A[j] < A[j-1]){
                key = A[j];
                A[j] = A[j-1];
                A[j-1] = key;
                num++;
            }
        }
    }

    printSequence(length, num);

    return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;


class UnionFind {
    vector<int> par;
    vector<int> myrank;
    vector<int> size;

public:
     UnionFind(int n) {
         par.resize(n);
         myrank.resize(n);
         size.resize(n);
         for(int i = 0; i < n; i++){
             par[i] = i;
             myrank[i] = 0;
             size[i] = 1;
         }
    }

    //木の根を求める
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (myrank[x] < myrank[y]) {
            par[x] = y;
            size[y] += size[x];
        } else {
            par[y] = x;
            size[x] += size[y];
            if (myrank[x] == myrank[y]) myrank[x]++;
        }
    }

    //xとyが同じ集合に属するかどうか
    bool same(int x, int y) {
        return find(x) == find(y);
    }

    // xが属する集合の大きさを返す
    int getSize(int x){
        return size[find(x)];
    }
};


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

    for(int i = 0; i < m; i++){
        int x, y, z;    cin >> x >> y >> z;
        x--; y--;
        uf.unite(x, y);
    }

    vector<bool> res(n, false);
    int count = 0;
    for(int i = 0; i < n; i++){
        int p = uf.find(i);
        if(!res[p]){
            count++;
            res[p] = true;
        }
    }

    cout << count << endl;




    return 0;
}


Measured memory_bytes: 1408
"use strict"

function main(input) {
  const sq = input.split(/\n|\s/).map(v => ~~v)

  const x = sq[2] - sq[0] //x distance
  const y = sq[3] - sq[1]

  const x3 = sq[2] - y
  const y3 = sq[3] + x
  const x4 = sq[0] - y
  const y4 = sq[1] + x

  console.log(x3, y3, x4, y4)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 21064
#include <cstdio>

int main (){
    int N,M;
    scanf("%d %d",&N,&M);
    int counter[M]={};
    int k[N],tmp;
    for (int i = 0; i < N; i++){
        scanf("%d",&k[i]);
        for (int j = 0; j < k[i]; j++){
            scanf("%d",&tmp);
            counter[tmp-1]++;
        }
    }
    int count=0;
    for (int i = 0; i < M; i++){
        if(counter[i]==N) count++;
    }
    printf("%d",count);
}

Measured memory_bytes: 128
def main():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
    g = [set() for _ in [0]*n]
    [g[a-1].add(b-1) for a, b in ab]
    [g[b-1].add(a-1) for a, b in ab]
    only = []
    sign = [False]*n
    for i in range(n):
        if len(g[i]) == 1:
            only.append(i)
    while only:
        i = only.pop()
        if not g[i]:
            print("Second")
            return
        j = g[i].pop()
        g[j].remove(i)
        if sign[i] and not g[j]:
            print("First")
            return
        if not sign[i] and sign[j]:
            print("First")
            return
        if not sign[j] and not sign[i]:
            sign[j] = True
        if len(g[j]) == 1:
            only.append(j)


main()


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong N;
  vector<llong> A;

  cin >> N;
  A.resize(N);
  for (auto &in: A) {
    cin >> in;
  }
  sort(ALL(A), greater<>());

  if (N == 2) {
    cout << A[0] << endl;
    return 0;
  }
  llong ans = A[0];
  for (int i = 2; i < N; ++i) {
    ans += A[i/2];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4840
N,K,Q = map(int,input().split())

correct = [0]*N

for i in range(Q):
    winner = int(input()) - 1
    correct[winner] += 1


for i in range(N):
    score = K - (Q-correct[i])
    if score <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 9816
// luogu-judger-enable-o2
#include<cstdio>
using namespace std;
int main()
{
    int n,t,x,y;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(x+y>t)
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==0&&t%2==1)
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==1&&t%2==0)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    long long sum = 0; 
    for (int a = 1; a <= k; ++a) {
        for (int b = 1; b <= k; ++b) {
            for (int c = 1; c <= k; ++c) {
                sum += gcd(a, gcd(b,c));
            }
        }
    }
    cout << sum << '\n';
    return 0;
}



Measured memory_bytes: 3648
#include<iostream>
typedef long long LoveLive;
const int md=1e9+7,N=3e6+7;
int X1,X2,X3,X4,X5,X6,Y1,Y2,Y3,Y4,Y5,Y6,ans;
int fac[N],iv[N];
inline int pow(int a,int b){
	int ret=1;
	for(;b;b>>=1,a=(LoveLive)a*a%md)if(b&1)ret=(LoveLive)ret*a%md;
	return ret;
}
struct point{
	int x,y,fh;
}A[4],B[4];
inline int C(int n,int m){return(LoveLive)fac[n]*iv[m]%md*iv[n-m]%md;}
inline int calc(int x,int y){return C(x+y,x);}
int main(){
	std::cin>>X1>>X2>>X3>>X4>>X5>>X6>>Y1>>Y2>>Y3>>Y4>>Y5>>Y6;
	A[0]=(point){X1-1,Y1-1,1},A[1]=(point){X1-1,Y2,-1},A[2]=(point){X2,Y1-1,-1},A[3]=(point){X2,Y2,1};
	B[0]=(point){X6+1,Y6+1,1},B[1]=(point){X5,Y6+1,-1},B[2]=(point){X6+1,Y5,-1},B[3]=(point){X5,Y5,1};
	for(int i=*fac=1;i<=3000000;++i)fac[i]=(LoveLive)fac[i-1]*i%md;
	iv[3000000]=pow(fac[3000000],md-2);
	for(int i=2999999;~i;--i)iv[i]=(i+1LL)*iv[i+1]%md;
	for(int i=X3;i<=X4;++i)
	for(int s=0;s<4;++s)
	for(int t=0;t<4;++t){
		ans=(ans+(LoveLive)calc(i-A[s].x,Y3-A[s].y-1)*calc(B[t].x-i,B[t].y-Y3)%md*(2LL*md-i-Y3)%md*(md+A[s].fh*B[t].fh))%md;
		ans=(ans+(LoveLive)calc(i-A[s].x,Y4-A[s].y)*calc(B[t].x-i,B[t].y-Y4-1)%md*(i+Y4+1)%md*(md+A[s].fh*B[t].fh))%md;
	}
	for(int i=Y3;i<=Y4;++i)
	for(int s=0;s<4;++s)
	for(int t=0;t<4;++t){
		ans=(ans+(LoveLive)calc(X3-A[s].x-1,i-A[s].y)*calc(B[t].x-X3,B[t].y-i)%md*(2LL*md-i-X3)%md*(md+A[s].fh*B[t].fh))%md;
		ans=(ans+(LoveLive)calc(X4-A[s].x,i-A[s].y)*calc(B[t].x-X4-1,B[t].y-i)%md*(i+X4+1)%md*(md+A[s].fh*B[t].fh))%md;
	}
	std::cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 23680
using System;
using System.Collections.Generic;

namespace abc148_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var a = CIn.ReadInt();
      var b = CIn.ReadInt();

      Console.WriteLine(MathTools.Lcm(a, b));
    }
  }

  class MathTools
  {
    public static long Gcd(long a, long b)
    {
      while (b != 0)
      {
        var mod = a % b;
        a = b;
        b = mod;
      }
      return a;
    }

    public static long Lcm(long a, long b)
    {
      return a * b / Gcd(a, b);
    }

    public static List<long> PrimeNumbers(long n)
    {
      var list = new List<long>();
      var sieve = new bool[n + 1];

      for (var i = 2; i <= n; i++)
      {
        if (!sieve[i])
        {
          list.Add(i);
          for (var j = i * 2; j <= n; j += i)
          {
            sieve[j] = true;
          }
        }
      }
      return list;
    }

    public static List<long> PrimeFactors(long n)
    {
      var list = new List<long>();
      var primeNumbers = PrimeNumbers((long)Math.Sqrt(n));

      foreach (var p in primeNumbers)
      {
        if (n == 1)
        {
          break;
        }
        while (n % p == 0)
        {
          n /= p;
          list.Add(p);
        }
      }
      if (n > 1)
      {
        list.Add(n);
      }
      return list;
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }
  }
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int A, B, M;
  string s;

  cin >> A >> B >> M;

  vector<int> a(A);
  vector<int> b(B);
  vector<int> x(M);
  vector<int> y(M);
  vector<int> z(M);
  vector<int> ans(M);
  for(int i = 0; i < A; i++){
    cin >> a[i];
  }
  for(int i = 0; i < B; i++){
    cin >> b[i];
  }
  for(int i = 0; i < M; i++){
    cin >> x[i] >> y[i] >> z[i];
  }
  for(int i = 0; i < M; i++){
    // cout << "total = " << a[x[i] -1] << " + "<< b[y[i] -1] << " - " << z[i] << endl;
    ans[i] = a[x[i]-1] + b[y[i]-1] - z[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  // cout << "a = " << a[0] << ", b = " << b[0] << endl;
  // ans[ans.size()] = a[0] + b[0];
  // cout << " ans.. " <<   ans[ans.size()] << endl;
  // int n = ans.size();
  // cout << " n.. " <<   n << endl;

  // for(int i = 0; i <= n; i++){
  //   cout << ans[i] << endl;
  // }
  sort(ans.begin(), ans.end());

  if(ans[0] <= (a[0] + b[0])){
    cout << ans[0] << endl;
  }else{
    cout << (a[0] + b[0]) << endl;
  }

  // cout << " --- "  << endl;
  // cout << ans[0] << endl;
  // cout << ans[1] << endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include <string.h>

int main()
{
    char card[2];
    int i, j, taro, mark, number, str[4][13] = { 0 };
    scanf("%d", &taro);
    for (i = 0; i<taro ; i++){
        scanf("%s %d", card, &number);
        if (strcmp(card,  "S") == 0){ mark = 0; }
        else if (strcmp(card, "H") == 0){ mark = 1; }
        else if (strcmp(card, "C") == 0){ mark = 2; }
        else if (strcmp(card, "D") == 0){ mark = 3; }
        str[mark][number - 1] = 1;
    }

    for (i = 0; i<4; i++){
        for (j = 0; j<13; j++){
            if (str[i][j] == 0){
                if (i == 0){ mark = 'S'; }
                else if (i == 1){ mark = 'H'; }
                else if (i == 2){ mark = 'C'; }
                else if (i == 3){ mark = 'D'; }
                printf("%c %d\n", mark, j + 1);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

class Main {
    private static char[] input;
    private static int ptr;
    private static boolean isBalancedRec() {
        while (true) {
            if (Character.isLetter(input[ptr]) || input[ptr] == ' ') {
                ptr++;
            } else if (input[ptr] == '(' || input[ptr] == '[') {
                final char right = input[ptr] == '(' ? ')' : ']';
                ptr++;
                if (isBalancedRec() && input[ptr] == right) {
                    ptr++;
                } else {
                    return false;
                }
            } else if (input[ptr] == ')' || input[ptr] == ']' || input[ptr] == '.') {
                break;
            }
        }
        return true;
    }

    private static boolean isBalanced(String input) {
        Main.input = input.toCharArray();
        Main.ptr = 0;
        return isBalancedRec() && Main.input[Main.ptr] == '.';
    }

    private static void solve() {
        final Scanner scanner = new Scanner(System.in).useDelimiter("\n");

        while (true) {
            String string = scanner.next();
            if (string.equals(".")) {
                break;
            }
            System.out.println(isBalanced(string) ? "yes" : "no");
        }
    }

    public static void main(String... args) {
        solve();
    }
}

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

#define ll long long

const int mxN = 2e5;

int main()
{
    ll n, a[mxN], tot = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        tot ^= a[i];
    }

    for (int i = 0; i < n; i++)
    {
        cout << (tot^a[i]) << " ";
    }
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int a[5],l[N];

int main()
{
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",l+i);

	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			for(int k=j+1;k<n;k++)
			{
				bool ok=false;
				a[0]=l[i],a[1]=l[j],a[2]=l[k];
				if(a[0]+a[1]>a[2]&&a[1]+a[2]>a[0]&&a[0]+a[2]>a[1])
					ok=true;
				ok&=(a[0]==a[1]||a[1]==a[2]||a[0]==a[2]?false:true);

				if(ok==true)
					ans++;//,cout<<i<<" "<<j<<" "<<k<<endl;
			}
	printf("%d\n",ans);
}


Measured memory_bytes: 3816
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int n;
    cin>>n;
    ll a[n];
	rep(i,0,n)cin>>a[i];
	ll mincnt=inf,cnt=0;
	rep(i,1,101){
		cnt=0;
		rep(j,0,n){
			cnt=cnt+pow(a[j]-i,2);
		}
		if(mincnt>cnt)mincnt=cnt;
	}
	cout<<mincnt<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
   
int main()
{
 char str[21];
 int i;

 scanf("%s", str);
 for(i=strlen(str) - 1; i>=0; --i){
   putchar(str[i]);
 }
 printf("\n");
  
 return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
 int N,L;
  
  cin >> N >> L;
  
  vector<string>s(N);
  
  rep(i,N){
    cin >> s.at(i);
	}
  
  sort(s.begin(),s.end());
  
  rep(i,N){
    cout << s.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long int ll;

int main(){
    ll n,m;
    std::cin >> n >> m;
    vector<pair<ll,ll>> d(m);
    for( auto& v : d ){
        std::cin >> v.first >> v.second;
    }
    sort( d.begin(), d.end(), [](const pair<ll,ll>& lhs, const pair<ll,ll>& rhs){
        return (lhs.second==rhs.second) ? lhs.first < rhs.first : lhs.second < rhs.second;
    });
    ll pre, cnt = 0;
    for( auto v : d ){
        if ( pre == v.second ){continue;}
        if ( pre <= v.first ){
            pre = v.second;
            cnt++;
        }
    }
    std::cout << cnt << std::endl;
}

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

int main() {
  int N; string S;
  cin >> N >> S;
  int level = 0, beginc = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == '(') level++;
    else {
      if (--level < 0) {
        level = 0;
        beginc++;
      }
    }
  }
  cout << string(beginc, '(') << S << string(level, ')');
}

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
const int m = 1e9 + 7;
long long mod(long long x) {
	return (x % m + m) % m;
}
long long binpow(long long a, long long b) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mod(res * a);
        a = mod(a * a);
        b >>= 1;
    }
    return res;
}
long long add(long long a, long long b) {
	return mod(mod(a) + mod(b));
}
long long mul(long long a, long long b) {
	return mod(mod(a) * mod(b));
}
long long sub(long long a, long long b) {
	return mod(mod(a) - mod(b));
}
int main() {
	long long n;
	cin >> n;
	long long ten = binpow(10, n);
	long long eight = binpow(8, n);
	long long nine = binpow(9, n);
	cout << sub(add(eight, ten), mul(2ll, nine)) << "\n"; 
	
}


Measured memory_bytes: 3516
n, x = map(int, input().split())
A = list(map(int, input().split()))

count = 0
for i in range(1,n):
    if A[i-1] + A[i] > x:
        dif = (A[i-1] + A[i]) - x
        count += dif
        if A[i] >= dif:
            A[i] = A[i] - dif
        else:
            A[i-1] = dif - A[i]
            A[i] = 0

print(count)

Measured memory_bytes: 14252
import sys
# from math import sqrt, gcd, ceil, log
# from bisect import bisect
# from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	n, k = read(); arr = sorted(read())
	print(sum(arr[:k]))



if __name__ == "__main__":
	solve()

Measured memory_bytes: 9128
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;

#define EPS 1e-8
#define INF 1e5

typedef complex<double> P;

int dl[]={-1,-1,-1,0,0,1,1,1};
int dr[]={-1,0,1,-1,1,-1,0,1};

namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
bool EQ(const P& a, const P& b)
{
	return abs(a - b) < EPS;
}


double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}


struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}

P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  return m[0] + B / A * (m[1] - m[0]);
}

class State
{
public:
	int l,r;
	double c;
	State(int l, int r, double c)
	:l(l),r(r),c(c)
	{
	}
	
	bool operator<(const State& s) const
	{
		return c>s.c;
	}
};


bool v[5000][5000];


int main()
{
	int N;
	cout << setprecision(3) << setiosflags(ios::fixed);
	while(cin >> N, N)
	{
		vector<P> pts;
		for(int i=0; i<N; i++)
		{
			double x,y;
			cin >> x >> y;
			pts.push_back(P(x,y));
		}
		
		for(int i=1; i<N-1; i++)
		{
			L hori = L(P(-INF, pts[i].imag()), P(INF, pts[i].imag()));
			for(int j=0; j<N-1; j++)
			{
				if(j==i || j+1 == i) continue;
				L line = L(pts[j], pts[j+1]);
				
				if(intersectLS(hori,line))
				{
					P xp = crosspoint(hori,line);
					pts.push_back(xp);
				}
			}
		}
		

		sort(pts.begin(), pts.end());
		pts.erase(unique(pts.begin(), pts.end(),EQ), pts.end());
		
		int sz=pts.size();
		
		priority_queue<State> q;
		q.push(State(0,sz-1, 0));
		
		memset(v,0,sizeof(v));
		
		while(!q.empty())
		{
			State s=q.top(); q.pop();
			if(v[s.l][s.r]) continue;
			v[s.l][s.r]=1;
			
			if(s.l==s.r)
			{
				cout << s.c << endl;
				break;
			}
			
			for(int i=0; i<8; i++)
			{
				int tl=s.l+dl[i], tr=s.r+dr[i];
				if(tl<0||tr<0||tl>=sz||tr>=sz) continue;
				if(fabs(pts[tl].imag() - pts[tr].imag()) > EPS) continue;
				
				if(v[tl][tr]) continue;
				
				q.push(State(tl,tr,s.c+abs(pts[tl]-pts[s.l])+abs(pts[tr]-pts[s.r])));
			}
		}
	}
}

Measured memory_bytes: 25000
#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
 
/*---------------------------------------------------------------------------------------------------*/
 
void solve()
{
    int n;
    string s;
    cin >> s;
    n = s.size();

    if (s[n - 1] == 's') s += "es";
    else s += "s";
    cout << s;
} 
 
signed main()
{
  FAST
  int T=1;
//   cin >> T;
  while(T--) solve();
  return 0;
}

Measured memory_bytes: 3664
N,M=map(int,input().split())
H=list(map(int,input().split()))
good=[1]*N
for _ in range(M):
  A,B=map(int,input().split())
  if H[A-1]>H[B-1]:
    good[B-1]=0
  elif H[B-1]>H[A-1]:
    good[A-1]=0
  else:
    good[A-1]=0
    good[B-1]=0
count=0
for i in range(N):
  if good[i]==1:
    count+=1
print(count)


Measured memory_bytes: 20044
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long x,h;
  cin>>x;
  	int rem=x/500;
 	h=(x/500)*1000;
  	x=x%500;
  	h+=(x/5)*5;
  	cout<<h;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        int digit =0;
        String x=sc.nextLine();
        if(x.equals("0")) break;
        for(int i=0;i<x.length();i++) {
        char c=x.charAt(i);
        digit += c -'0';
        }
        System.out.println(digit);
        }
    }
}


Measured memory_bytes: 26412
#include <stdio.h>
#include <queue>
using namespace std;
int main(){
    int n,k,top=1<<30,now=0,temp,f[100010];
    queue<int> q;
    scanf("%d%d",&n,&k);
    for(int i=0;i<=k;i++)f[i]=0;
    for(int i=0;i<n;i++){
        scanf("%d",&temp);
        if(temp<=k){
            if(f[temp]==0)now++;
            f[temp]++;
            q.push(temp);
            while(q.front()>k)q.pop();
            while(f[q.front()]>1){
                f[q.front()]--;
                q.pop();
                while(q.front()>k)q.pop();
            }
            if(now==k)if(q.size()<top)top=(int)q.size();
        }
        else q.push(temp);
        //printf("%d\n",q.size());
    }
    if(top==(1<<30))printf("0\n");
    else printf("%d\n",top);
}

Measured memory_bytes: 3268
N = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
Alice = 0
Bob = 0
for i in range(1,N+1):
    if i%2 !=0:
        Alice+=li[i-1]
    elif i%2 == 0:
        Bob += li[i-1]
ans = Alice-Bob
print(ans)

Measured memory_bytes: 3064
from collections import Counter
 
n = int(input())
XY = [list(map(int,input().split())) for i in range(n)]
ball = []
 
for i,xy in enumerate(XY):
	for j,xxyy in enumerate(XY):
		# print(i,j)
		if i == j:
			continue
		ball.append([xy[0]-xxyy[0],xy[1]-xxyy[1]])
 
ball.sort()
 
count = 1
ans = 0
inf = float("inf")
xx = inf
yy = inf
for x,y in ball:
	if x == xx and y == yy:
		count += 1
	else:
		ans = max(ans,count)
		count = 1
		xx = x
		yy = y
ans = max(ans,count)
if n == 1:
	ans = 0
print(n-ans)

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define all(v) v.begin(),v.end() 
#define rev(v) v.rbegin(),v.rend()
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define inp 200005
#define en "\n"
using namespace std;
using namespace __gnu_pbds;

signed main() 
{
    ssd
    int i,j,k,n;
    cin>>n;
    vector<double> v(n+5);
    for(i=1;i<=n;i++) cin>>v[i];

    double dp[n+5][n+5]={};
    dp[0][0] = 1.0;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<=n;j++)
        {
            if(j==0)
            {
                dp[i][0] = dp[i-1][0] * (1-v[i]);
                continue;
            }
            dp[i][j] = dp[i-1][j-1]*v[i] + dp[i-1][j]*(1-v[i]);
        }
    }
    double ans=0;
    for(i=n/2+1; i<=n; i++) ans += dp[n][i];  
    cout << fixed << setprecision(12) << ans;
    return 0;             
}

Measured memory_bytes: 74296
n = int(input())
for i in range(1,n+1):
    x = i
    if x % 3 == 0:
        print(' {}'.format(i), end='')
    else:
        while x:
            if x % 10 == 3:
                print(' {}'.format(i), end='')
                break
            else:
                x //= 10
print('')

Measured memory_bytes: 7860
#include <iostream>
#include <string>

using namespace std;

int main(){

    int result = 0;
    int num = 0;
    cin >> num;
    int numArray[num];
    int aSum = 0;
    int bSum = 0;


    for (int i = 0; i < num; i++) {
        cin >> numArray[i];
    }

    for (int i = 0; i < num; i++) {
        for (int j = 0; j < num; j++) {
            if (numArray[j] < numArray[i]) {
                int temp = numArray[i];
                numArray[i] = numArray[j];
                numArray[j] = temp;
            
            }
        }
    }


    

    for (int r = 0; r < num; r += 2) {
        aSum += numArray[r];
    }


    for (int i = 1; i < num; i += 2) {
        bSum += numArray[i];
    }

    

    cout << (aSum - bSum) << endl;
    

    
    



    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n)
        cin >> a[i];
    ll ac = 0;
    REP(i, n){
        ac ^= a[i];
    }
    vector<ll> ans(n);
    REP(i, n){
        ans[i] = ac ^ a[i];
    }
    REP(i, n)
        cout << (i==0?"":" ") << ans[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 5936
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値(N)
		int numN = scan.nextInt();

		//入力値(N)
		long[] listA = new long[numN];
		long[] listB = new long[numN-1];

		for (int i = 0; i < numN-1; i++) {
			listB[i] = scan.nextLong();
		}

		listA[0] = listB[0];
		listA[numN-1] = listB[numN-2];

		for (int i = 1; i < numN-1; i++) {
			listA[i] = Math.min(listB[i-1],listB[i]);
		}

		long sum = 0L;
		for (int i = 0; i < numN; i++) {
			sum += listA[i];
		}

		System.out.println(sum);
	}
}

Measured memory_bytes: 23380
use std::io;

fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().split(' ').flat_map(str::parse).collect()
}

fn main() {
    let l1 = read::<u32>();

    let x = l1.first().unwrap();

    println!("{}", x * x * x);
}



Measured memory_bytes: 5024
h,w=map(int,input().split())
s=eval('input(),'*h)
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':continue
        for y,x in((i-1,j),(i+1,j),(i,j-1),(i,j+1)):
            if h>y>=0 and w>x>=0 and s[y][x]=='#':
                break
        else:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    int ans = 0;
    string S;
    cin >> S;
    int N = S.size();
    rep(i,N){
        if(i % 2 == 0){
            if(S[i] == 'p'){
                --ans;
            }
        }
        else{
            if(S[i] == 'g'){
                ++ans;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
public class Main {

  private static void solve() {
    long a = nl();
    long b = nl();
    long k = nl();

    long d1 = Math.min(k, a);
    long d2 = Math.max(0, k - d1);

    System.out.println((a - d1) + " " + Math.max(0, (b - d2)));


  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 22740
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){

  int n;
  cin >> n;

  vector<int> data;

  int i = 11;
  int tmp = 2;
  bool ismod = false;
  while(data.size() != n){
    ismod = false;
    tmp = int(sqrt(i));
    for (int j = 2; j <= tmp; j++){
      if (i % j == 0){
        ismod = true;
        break;
      }
    }
    if (!ismod){
      data.push_back(i);
    }
    i += 10;
  }
  for (int j; j < n; j++){
    cout << data[j] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
/*
	*	Created By: 'Present_Sir'
	*	Created On: Sunday 05 July 2020 02:36:58 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;


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

    map<string,int> mp;
    for(int i=0; i<n; i++){
        string s;
        cin>>s;
        mp[s]++;
    }

    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3656
x = input().split()

a = int(x[0])
b = int(x[1])
c = int(x[2])

if a <= b <= c :
    print(a,b,c)
elif a <= c <= b :
    print(a,c,b)
elif b <= a <= c :
    print(b,a,c)
elif b <= c <= a :
    print(b,c,a)
elif c <= a <= b :
    print(c,a,b)
else :
    print(c,b,a)

Measured memory_bytes: 6724
/*! if g++ -g alds_1_7_b.cpp -o alds_1_7_b.out; then ./alds_1_7_b.out < alds_1_7_b.test; fi
 */

#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



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



class node{
public:
  int id, left, right, parent, depth, height;
  node(): id(-1), left(-1), right(-1), parent(-1), depth(-1), height(-1){}
  void print(){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",
           id, parent, sibling(), degree(), depth, height, type().c_str());
  }
  int sibling();
  int degree(){
    int ret = 0;
    if(left >= 0) ret++;
    if(right >= 0) ret++;
    return ret;
  }
  string type(){
    if(parent == -1) return "root";
    if(left == -1 && right == -1) return "leaf";
    return "internal node";
  }
};

vector<node> tree(0);

int node::sibling(){
    if(parent == -1) return -1;
    if(tree[parent].left == id) return tree[parent].right;
    return tree[parent].left;
}

void find_depth(int id, int d){
  tree[id].depth = d;
  if(tree[id].left >= 0){
    find_depth(tree[id].left, d+1);
  }
  if(tree[id].right >= 0){
    find_depth(tree[id].right, d+1);
  }
}

int find_height(int id){
  node& nd = tree[id];
  bool has_l = nd.left  >= 0;
  bool has_r = nd.right >= 0;
  if(has_l) find_height(nd.left);
  if(has_r) find_height(nd.right);
  if(has_l && has_r){
    nd.height = max(tree[nd.left].height, tree[nd.right].height) + 1;
  } else if(has_l){
    nd.height = tree[nd.left].height + 1;
  } else if(has_r){
    nd.height = tree[nd.right].height + 1;
  } else{
    nd.height = 0;
  }
  return nd.height;
}

int main(){
  int n;
  cin >> n;
  tree.resize(n);
  for (size_t i = 0; i < (size_t)n; i++) {
    int id, l, r;
    cin >> id >> l >> r;
    tree[id].id = id;
    tree[id].left = l;
    tree[id].right = r;
    if(l >= 0){
      tree[l].parent = id;
    }
    if(r >= 0){
      tree[r].parent = id;
    }
  }
  for(int i = 0; i < n; i++){
    if(tree[i].parent == -1){
      find_depth(i, 0);
      find_height(i);
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    tree[i].print();
  }

  return 0;
}

Measured memory_bytes: 1200
using System;

namespace HelloWorld
{
    class Program
    {
        static void Main()
        {
            string alpha = Console.ReadLine();
            string[] beta = alpha.Split(' ');
            int x = int.Parse(beta[0]);
            int y = int.Parse(beta[1]);
            int c = int.Parse(beta[2]);
            int count = 0;
            for (int a = x; a <= y; a++)
            {
                if (c % a == 0) count++;
            }
            Console.WriteLine(count);
        }

    }
}



Measured memory_bytes: 18028
//file_name:ABC70_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    ll g = a[0];

    ll ans = g;

    rep(i,n){
        ll x = ans;
        ll y = a[i];

        while(true){
            if(y%x==0){
                g = x;
                break;
            }
            ll xx = x;
            x = y%x;
            y = xx;
        }
        ans = x;
    }



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



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

int main() {
	int N, A[100010], B; cin >> N;
	for(int i=0; i<N; ++i) cin >> A[i];
	for(int i=0; i<N; ++i){
	    cin >> B;
	    A[i] -= B;
	}
	sort(A, A+N);
	long P=0;
	int ans=0;
	while(A[ans]<0){
	    P -= A[ans];
	    ++ans;
	}
	sort(A+ans, A+N, greater<int>());
	while(P>0 && N>ans){
	    P -= A[ans];
	    ++ans;
	}
	if(P>0) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			String[] s = stdIn.next().split(",");
			int[] l = new int[10];
			int v1 = Integer.valueOf(s[10]);
			int v2 = Integer.valueOf(s[11]);
			for(int i = 0; i < 10; ++i)
			{
				l[i] = Integer.valueOf(s[i]);
			}
			int posA = 0;
			int posB = 0;
			for(int i = 0; i < 10; ++i)
			{
				posB += l[i] * 1000;
			}
			int speedA = v1;
			int speedB = v2;
			while(posA < posB)
			{
				posA += speedA;
				posB -= speedB;
			}
			int dist = 0;
			for(int i = 0; i < 10; ++i)
			{
				dist += l[i] * 1000;
				if(posA <= dist)
				{
					System.out.println(i + 1);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,n) for(int i=a;i<n;i++)
#define pb(v) push_back(v)

int main() {
	//code
	
     ios_base::sync_with_stdio(false); 
     cin.tie(NULL);
      int n,b;
      cin>>n;
      int a[n];
      
      f(i,0,n)
      cin>>a[i];
      int dp[n+3];
      dp[0]=0;
      dp[1]=abs(a[1]-a[0]);
      for(int i=2;i<n;i++)
      {
	  
          dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
         
     }
      cout<<dp[n-1]<<endl;
 return 0;

}

Measured memory_bytes: 1024
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 9
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353

n = I()
A = LI()
S = sorted([(A[k], k + 1) for k in range(n)], reverse=True)
ans = 0
dp = [[-INF] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for j in range(n):
        if i and i <= S[i + j - 1][1]:
            dp[i][j] = max(dp[i][j], dp[i - 1][j] + S[i + j - 1][0] * abs(i - S[i + j - 1][1]))
        if j and S[i + j - 1][1] <= n - j + 1:
            dp[i][j] = max(dp[i][j], dp[i][j - 1] + S[i + j - 1][0] * abs(n - j + 1 - S[i + j - 1][1]))
        if i + j == n:
            ans = max(ans, dp[i][j])
            break

print(ans)




Measured memory_bytes: 116800