akhauriyash/Code-Regression huggingface dataset:
import numpy as np

a, b, x = map(int, input().split())

V = a**2 * b
if 0 <= x < V / 2:
    c = x / a / b * 2
    rad = np.arctan(b / c)
elif V / 2 <= x <= V:
    c = (V - x) / a**2 * 2
    rad = np.arctan(c / a)
deg = rad * (180 / np.pi)
print(deg)

Measured memory_bytes: 12740
#include<stdio.h>
#include<math.h>

int isprime(int);

int main(){

  int n, m, i, l[10000];

  scanf("%d",&n);

  //int l[n];
  for( i = 0; i < n; i++){
    scanf("%d",&l[i]);
    if(isprime(l[i]) == 1)
      m++;
  }
  printf("%d\n",m);
  return 0;
}

int isprime(int x){
  int i = 3;
  if( x == 2)
    return 1;
  if( x < 2 || x % 2 == 0)
    return 0;
  while( i <= sqrt(x)){
    if( x % i == 0)
      return 0;
    i = i +2;
  }
  return 1;
}

Measured memory_bytes: 628
using System;
using System.Linq;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var a = input[0];
            var b = input[1];
            var c = input[2];
            var x = input[3];
            var y = input[4];

            var z = Math.Min(x, y);
            long ans = 0;

            if(a + b >= 2 * c)
            {
                for(int i = 0; i < z; i++)
                {
                    x--;
                    y--;
                    ans += 2 * c;
                }

                if(x > 0)
                {
                    if(a >= 2 * c)
                    {
                        while(x > 0)
                        {
                            x--;
                            ans += 2 * c;
                        }
                    }
                    else
                    {
                        while(x > 0)
                        {
                            x--;
                            ans += a;
                        }
                    }
                }
                else
                {
                    if (b >= 2 * c)
                    {
                        while (y > 0)
                        {
                            y--;
                            ans += 2 * c;
                        }
                    }
                    else
                    {
                        while (y > 0)
                        {
                            y--;
                            ans += b;
                        }
                    }
                }
            }

            else
            {
                ans += a * x + b * y;
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 28176
n,k = map(int,input().split())
h = []
for i in range(n):
    p = int(input())
    h.append(p)
h.sort()
ans = 10**9
for i in range(n-k+1):
    a = abs(h[i]-h[i+k-1])
    if ans > a:
        ans = a
print(ans)

Measured memory_bytes: 7384
#include<cstdio>
long long x,y;
int main()
{
	scanf("%lld%lld",&x,&y);
	if(x==1&&y==1)printf("1\n");
	else if(x==1||y==1)printf("%lld\n",x*y-2);
	else printf("%lld\n",(x-2)*(y-2));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007
#define INF MOD
typedef long long ll;
typedef pair<int,int> P;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
//#define int ll


signed main(){
    int D[11][5]={{0,3,5,6,8},{1,2,4,7,10},{0,3,6,8,9},{2,4,5,7,10},{0,1,3,6,9},{2,5,7,8,10},{1,3,4,6,9},{0,2,5,8,10},{1,4,6,7,9},{0,2,3,5,8},{1,4,7,9,10}};
    int n,k,Ans=0;
    cin >> n >> k;
    n--;n--;
    Ans = 5*((int)(n/11));
    REP(i,5){
        if(D[k][i]<n%11)Ans++;
    }
    cout <<Ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,0,n) cin>>a[i];
    int ctr=0,x=1;
    bool flag=0;
    rep(i,0,n){
        if(a[i]==x) ctr++,x++,flag=1;
    }
    cout<<(flag==1?n-ctr:-1)<<'\n';
}
    
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
a, b, c = sorted([int(n) for n in input().split()])

resa = c - a
resb = c - b

if resa % 2 == resb % 2:
    ans = (b - a) // 2 + (c - b)
else:
    ans = 1 + (b + 1 - a) // 2 + (c - b)

print(ans)

Measured memory_bytes: 2940
#include <stdio.h>
#define limit 50

int N,M;
int a[limit],b[limit];

int graph[limit][limit];
int flag[limit];

void dfs(int v){
  flag[v] = 1;
  for(int v2 = 0;v2 < N;v2++){
    if(graph[v][v2] == 0) continue;
    if(flag[v2] == 1) continue;
    dfs(v2);
  }
}

int main(void){
  int ans = 0;
  scanf("%d%d",&N,&M);

  for(int i = 0;i < limit;i++){
    for(int j = 0;j < limit;j++){
      graph[i][j] = 0;
    }
  }
  for(int i = 0;i < M;i++){
    scanf("%d%d",&a[i],&b[i]);
    a[i]--; b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = 1;
  }

  for(int i = 0;i < M;i++){
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = 0;

    for(int j = 0;j < N;j++) flag[j] = 0;

    dfs(0);

    int bridge = 0;
    for(int j = 0;j < N;j++)
      if(flag[j] == 0)
        bridge = 1;
    if(bridge) ans++;

    graph[a[i]][b[i]] = graph[b[i]][a[i]] = 1;
  }

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

  return 0;
}

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

using namespace std;

int main()
{
    long long s,n,minn=999999999999,maxn=-999999999999;
    scanf("%lld",&n);
    for(long long i=0;i<n;i++){
        scanf("%lld",&s);
        maxn=max(maxn,s-minn);
        minn=min(s,minn);
    }
    printf("%lld\n",maxn);
    return 0;
}



Measured memory_bytes: 3212
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

   private static final String INPUT_FILE_PATH = "";
   
   static final int MOD = (int) (1e9 + 7);

   static void solve(InputReader in, PrintWriter out) {
      int s = in.nextInt();

      if (s < 3) {
         out.println(0);
         return;
      }

      long[] dp = new long[s + 1];
      dp[0] = 1;
      dp[3] = 1;
      for (int i = 4; i <= s; i++) {
         for (int j = 3; j <= i; j++) {
            dp[i] += dp[i - j];
            dp[i] %= MOD;
         }
      }
      out.println(dp[s]);
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

      public String nextToken() {
         while (st == null || !st.hasMoreTokens()) {
            try {
               st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }
         return st.nextToken();
      }

      public int nextInt() {
         return Integer.parseInt(nextToken());
      }

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

      public double nextDouble() {
         return Double.parseDouble(nextToken());
      }
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


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

using namespace std;

int digits(long long a){
	int cnt = 0;
	while(a) cnt++, a /= 10;
	return cnt;
}

int f(long long a, long long b){
	return max(digits(a), digits(b));
}


int main(){
	long long n;

	scanf("%lld", &n);

	int ans = 10000000;
	for(long long i = 1; i*i <= n; i++){
		if(n % i == 0){
			ans = min(ans, f(i, n/i));
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
def main():
    cnt = 0

    def merge(A, l, mid, r):
        nonlocal cnt
        n1 = mid - l
        n2 = r - mid
        L = [A[l + i] for i in range(n1)]
        R = [A[mid + i] for i in range(n2)]
        L.append(1 << 60)
        R.append(1 << 60)
        i = 0
        j = 0
        for k in range(l, r):
            if L[i] <= R[j]:
                cnt += 1
                A[k] = L[i]
                i = i + 1
            else:
                cnt += 1
                A[k] = R[j]
                j = j + 1

    def merge_sort(A, left, right):
        if left+1 < right:
            mid = (left + right) // 2
            merge_sort(A, left, mid)
            merge_sort(A, mid, right)
            merge(A, left, mid, right)

    N = int(input())
    S = [int(i) for i in input().split()]
    merge_sort(S, 0, N)
    print(*S)
    print(cnt)


if __name__ == '__main__':
    main()



Measured memory_bytes: 63712
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans,i,j;
  cin >> n;
  ans=0;
  vector<int> a(n);
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  for(i=0;i<n;i++){
    if(a[i]==a[i+1]){
      for(j=i;j<n;j++){
        if(a[i]!=a[j+1])break;
      }
      ans+=(j-i+1)/2;
      i=j;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#!python3

iim = lambda: map(int, input().rstrip().split())

inf = 10**18 + 1

def cnt_val(a, b, x):
    ans = 0
    la, lb = len(a), len(b)
    J = (i for i in range(lb)) if a == b else (-1 for i in range(la))

    j = lb - 1
    for i, k in enumerate(J):
        xa = a[i]

        for j in range(j, k, -1):
            x1 = b[j] * xa
            if x1 <= x:
                break
        else:
            break
        ans += j - k

    return ans

def resolve():
    N, K = iim()
    A = [[] for i in range(3)]
    for x in input().split():
        x = int(x)
        if x < 0:
            i = 0
        elif x == 0:
            i = 1
        else:
            i = 2

        A[i].append(x)

    a0 = len(A[0]) * len(A[2])
    s1 = len(A[1])
    a1 = s1 * (2*N - s1 -1) // 2
    K1 = K - 1

    if a0 < K1 < a0 + a1:
        print(0)
        return

    if K1 < a0:
        A[0].sort()
        A[2].sort(reverse=True)
        #print(A[0], A[2])
        lo, hi = A[0][0]*A[2][0], A[0][-1] * A[2][-1] + 1
        #print((lo, hi), K1)
        while lo < hi:
            mid = (lo + hi) // 2
            k = cnt_val(A[0], A[2], mid)
            #print((lo, hi), mid, k, K1)
            if k <= K1:
                lo = mid + 1
            else:
                hi = mid
        print(lo)
        return

    A0 = list(map(lambda x: -x, A[0]))
    A0.sort()
    A[2].sort()
    K3 = K - a0 - a1 - 1
    #print(A[0], A[2], a0, a1, K3)
    lo, hi = 0, 10**18
    while lo < hi:
        mid = (lo + hi) // 2
        k3 = cnt_val(A0, A0, mid) + cnt_val(A[2], A[2], mid)
        #print((lo, hi), k3, K3)
        if k3 <= K3:
            lo = mid + 1
        else:
            hi = mid
    print(lo)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 97364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define debug(x) cerr<<#x<<' '<<x<<'\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=2e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int n,k,h[maxn];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>k;
    rep(i,1,n) cin>>h[i];
    sort(h+1,h+1+n);
    ll sum=0;
    per(i,n-k,1) sum+=h[i];
    cout<<sum<<'\n';
    return 0;
}




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

int main() {
  int n, l;
  scanf("%d %d", &n, &l);
  l--;
  int first = 1 + l, last = n + l;
  if (1 + l <= 0 && 0 <= n + l)
    return printf("%d\n", n * (first + last) / 2), 0;
  printf("%d\n", n * (first + last) / 2 - (first < 0 ? last : first));
  return 0;
}

Measured memory_bytes: 256
from sys import stdin

data = [int(stdin.readline().rstrip()) for _ in range(5)]
data2 = []

for d in data:
    while(True):
        dstr = str(d)
        if int(dstr[-1]) == 0:
            break
        d+=1
    data2.append(d)


mati = -1
mati_index = -1
keta = -1

for i, d in enumerate(data):
    dstr = str(d)
    lastn = int(dstr[-1])
    this_mati = 0
    
    if int(dstr[-1]) == 0:
        this_mati = 0
    else:
        this_mati = 10 - lastn

    if this_mati > mati:
        mati = this_mati
        mati_index = i

res = 0

for i in range(5):
    if i == mati_index:
        continue
    res += data2[i]

res += data[mati_index]

print(res)


Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;
#define M(x,y) ((x)>(y)?(x):(y))
#define m(x,y) ((x)<(y)?(x):(y))

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	rep(i, 1000) {
		if (a < 1) { printf("No"); return 0; }
		if (c < 1) { printf("Yes"); return 0; }
		c -= b;
		if (a < 1) { printf("No"); return 0; }
		if (c < 1) { printf("Yes"); return 0; }
		a -= d;
	}
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int s, w; cin >> s >> w;
	if(w >= s) cout << "unsafe\n";
	else cout << "safe\n";
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 200005
struct Node
{
	int x,y;
};
vector<Node> a;
vector<int> b;
int f[N];
bool cmp(Node x,Node y)
{
	return y.x*(x.y+1)<x.x*(y.y+1);
}
signed main()
{
	int n=read(),T=read();
	for(int i=1;i<=n;i++)
	{
		int x=read(),y=read();
		if(x) a.pb((Node){x,y});
		else b.pb(y+1);
	}
	sort(a.begin(),a.end(),cmp);
	sort(b.begin(),b.end());
	for(int i=1;i<b.size();i++)
	{
		b[i]+=b[i-1];
	}
	for(int i=1;i<=30;i++) f[i]=T+5;
	for(int i=0;i<a.size();i++)
	{
		for(int j=30;j>0;j--)
		{
			int R=(f[j-1]+1)*(a[i].x+1)+a[i].y;
			if(R<f[j]) f[j]=R;
		}
	}
	// for(int i=0;i<=30;i++) printf("%lld ",f[i]); cout<<"\n";
	int ans=0;
	for(int i=0;i<=30;i++)
	{
		if(f[i]<=T)
		{
			int R=i+(upper_bound(b.begin(),b.end(),T-f[i])-b.begin());
			if(R>ans) ans=R;
		}
	}
	cout<<ans<<endl;
	return 0;
}



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

int main( void )
{
	int i, j;

	bool isPrime[50001 + 1];
	isPrime[2] = true;
	for ( i = 3; i < 50001; i += 2 )
	{
		isPrime[i] = true;
	}

	for ( i = 3; i < 50001; i += 2 )
	{
		for ( j = i + i; j < 50001; j += i )
		{
			isPrime[j] = false;
		}
	}

	int cnt = 1;
	int primes[5500];
	primes[0] = 2;
	for ( i = 3; i < 50001; i += 2 )
	{
		if ( isPrime[i] )
		{
			primes[cnt] = i;
			cnt++;
		}
	}

	int n;
	while ( cin >> n && n != 0 )
	{
		int kotae = 0;
		for ( i = 0; i < cnt; i++ )
		{
			if ( primes[i] <= n / 2 )
			{
				if ( isPrime[n-primes[i]] )
					kotae++;
			}
		}
		cout << kotae << endl;
	}

	return 0;
}

Measured memory_bytes: 936
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll n;
    cin >> n;
    ll maxl = 0;
    ll sum = 0;
    for (ll i = 0; i < n; ++i) {
        ll l;
        cin >> l;
        maxl = max(maxl, l);
        sum += l;
    }

    if (sum - maxl > maxl ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    if S[0]==S[2]:
        print("Yes")
    else:
        print("No")

main()


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

using namespace std;
int main()
{
    int a;
    cin>>a;
    if(a == 25){
        cout<<"Christmas";
    }
    else if(a == 24){
        cout<<"Christmas Eve";
    }
    else if(a == 23){
        cout<<"Christmas Eve Eve";
    }
    else{
        cout<<"Christmas Eve Eve Eve";
    }
    return 0;
}

Measured memory_bytes: 3516
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                int weight = int.Parse(line);
                for(int i = 0; i < 10; i++)
                {
                    if ((weight & (1 << i)) != 0)
                    {
                        if ((weight & ((1 << i) - 1)) != 0)
                            Console.Write(' ');
                        Console.Write(1 << i);
                    }
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 5604
#include <stdio.h>
int main()
{
    int A[1000000]={0}, n, i, j, k, v, cnt=0, m, G[100]={0};
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }
    i = 0;
    G[0] = 1;
    while(1){
        if(G[i] > n){
            m = i;
            break;
        } else {
            G[i+1] = (3 * G[i]) + 1;
            i++;
        }
    }
    for(i = 0; i < m; i++){
        for(j = G[m-1-i]; j < n; j++){
            v = A[j];
            k = j -G[m-1-i];
            while(k >= 0 && A[k] > v){
                A[k + G[m-1-i]] = A[k];
                k = k - G[m-1-i];
                cnt++;
            }
            A[k + G[m-1-i]] = v;
        }
    }
    printf("%d\n", m);
    for(i =0; i < m; i++){
        if(i == m-1){
            printf("%d\n", G[m-1-i]);
        } else {
            printf("%d ", G[m-1-i]);
        }
    }
    printf("%d\n", cnt);
    for(i = 0; i < n; i++){
        printf("%d\n", A[i]);
    } 
    return 0;
}

Measured memory_bytes: 4516
#include <iostream>
int main()
{
  for (auto i = 0; i < 81; i++) {
    std::cout << (i / 9 + 1) << 'x' << (i % 9 + 1)
	      << '=' << ((i / 9 + 1) * (i % 9 + 1)) << std::endl;
  }
}



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

#define PI 4*atan(1)
#define INF 1e8

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int main(){
  int n, r;
  while(cin >> n >> r, n || r){
    vector<int> card(n);
    for(int i = 0; i < n; i++)card[i] = i + 1;
    int p, c;
    for(int i = 0; i < r; i++){
      cin >> p >> c;
      p--;
      for(int j = p; j < p + c; j++){
        int tmp;
        tmp = card[card.size() - p - c];
        card.erase(card.begin() + card.size() - p - c);
        card.push_back(tmp);
      }
    }
    cout << card[n - 1] << endl;
  }
}

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

using namespace std;

int main(){

  string S;
  string res;

  cin >> S;

  for(int i=0; i<3; ++i){
    if (S[i] == S[i+1]){
      res = "Bad";
      break;
    }else{
      res = "Good";
    }
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b,c;
 cin >> a>> b>> c;
 bool yon = c>=a && c<=a+b;
 if(yon){
     cout << "YES" << endl;
 }else{
     cout << "NO" << endl;
 }
 return 0;
}

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

int main() {
  string s;
  int cnt = 0;
  cin >> s;
  
  if (s[0] == '1') cnt += 1;
  if (s[1] == '1') cnt += 1;
  if (s[2] == '1') cnt += 1;

  cout << cnt;
}

Measured memory_bytes: 256
using System;

namespace B___Comparing_Strings
{
    class Program
    {
        static void Main (string[] args)
        {
            var ab = Console.ReadLine ().Split (' ');
            switch (ab[0].CompareTo (ab[1]))
            {
                case -1:
                    for (var i = 0; i < int.Parse (ab[1]); i++)
                    {
                        Console.Write (ab[0]);
                    }
                    Console.WriteLine ();
                    break;

                case 0:
                    for (var i = 0; i < int.Parse (ab[1]); i++)
                    {
                        Console.Write (ab[0]);
                    }
                    Console.WriteLine ();
                    break;

                case 1:
                    for (var i = 0; i < int.Parse (ab[0]); i++)
                    {
                        Console.Write (ab[1]);
                    }
                    Console.WriteLine ();
                    break;
            }
        }
    }
}

Measured memory_bytes: 13280
N = int(input())
ans = []
for i in range(N):
    q = i+1
    count = 0
    if q == 1:
        continue
    while True:
        if q%2 != 0:
            break
        q = q//2
        count += 1
    ans.append(count)

if len(ans) > 0:
    max_count = max(ans)
    print(ans.index(max_count)+2)
else:
    print(1)

Measured memory_bytes: 9192
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var ABC = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (a, b, c) = (ABC[0], ABC[1], ABC[2]);

        var ans = Math.Max(c - (a - b), 0);

        WriteLine(ans);
    }
}


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(m);
    vector<int> d(m);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < m; i++){
        cin >> c[i] >> d[i];
    }
    int nearcheck = 0;
    int mindist = 400000000;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(mindist > (abs(a[i]-c[j]) + abs(b[i]-d[j]) )){
                mindist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
                nearcheck = j;
            }
        }
        cout << nearcheck+1 << endl;
        mindist = 400000000;
        nearcheck = 0;
    }
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $x);

if($a * $a * $b / 2.0 <= $x) {
    $ans = atan(2 * ($a * $a * $b - $x) / ($a * $a * $a));
} else {
    $ans = M_PI / 2 - atan(2 * $x / ($a * $b * $b));
}
printf("%.10f", $ans * 180 / M_PI);


Measured memory_bytes: 4728
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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;}

int main(){
	string s,t;
	cin >> s >> t;
	
	int n = (int)s.size();

	
	
	
	REP(i,n){
		bool flag = true;
		REP(j,n){
			if(s[j] != t[(i+j)%n]) flag = false;
		}
		if(flag){
			cout << "Yes\n";
			return 0;
		}
	}
	
	cout << "No\n";

	
	return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");

		int a = Integer.parseInt(tmpArray[0]);
		int b = Integer.parseInt(tmpArray[1]);

		System.out.println(Math.max(a*b, Math.max(a+b, a-b)));

	}

}


Measured memory_bytes: 21204
#include<iostream>
#include<set>
using namespace std;
set<int> a;
int main() {
	int n,t;
	cin>>n;
	for(int i=1; i<=n; i++){cin>>t;a.insert(t);}
	cout<<(a.size()==n?"YES":"NO")<<endl;
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define maxn 1000010
using namespace std;

int n;
int check(int x){
	int ret=0;
	for(int i=1;i<=x;i++)
		if(x%i==0)
			ret++;
	return ret;
}
int main(){
	int cnt=0;
	cin>>n;
	for(int i=1;i<=n;i+=2)
		if(check(i)==8)
			cnt++;
	cout<<cnt<<endl;
	return 0;
}

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

#define INF INT_MAX

using namespace std;

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

int main(void){
 	cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    int ans = 0;
    if(a <= 5)
    {
        ans  = 0;
    }else if(a <= 12){
        ans = b/2;
    }else{
        ans = b;
    }
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = list(str(x) for x in input())
l = len(n)
op_cnt = l - 1
for i in range(2 ** op_cnt):
  op = ['-'] * op_cnt
  for j in range(op_cnt):
    if ((i >> j) & 1):
      op[op_cnt-1 - j] = '+'

  formula = ''
  for j in range(op_cnt):
    formula += n[j] + op[j]
  formula += n[op_cnt]
  if eval(formula) == 7:
    print(formula + '=7')
    break


Measured memory_bytes: 38384
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
n=int(input())
for i in range(10000):
    if is_prime(n)==True:
        print(n)
        break
    n=n+1
    

Measured memory_bytes: 2940
import sys
input = sys.stdin.readline

MOD = 10 ** 9 + 7

S = input()

a, ab, abc = [0] * 3
c = 1

for s in S:
    if s == "A":
        a = (a + c) % MOD
    elif s == "B":
        ab = (ab + a) % MOD
    elif s == "C":
        abc = (abc + ab) % MOD
    elif s == "?":
        abc = (3 * abc + ab) % MOD
        ab = (3 * ab + a) % MOD
        a = (3 * a + c) % MOD
        c = (3 * c) % MOD
print(abc % MOD)


Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int n;

int main(){
  double ans = 0.0;
  cin >> n;
  REP(i,n){
    double a;
    string b;
    cin >> a >> b;
    if(b=="JPY") ans += a;
    else ans += a*380000.0;
  }
  cout << fixed << setprecision(10) << ans <<endl;
  return 0;
}


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

#define deb(x) cout << #x << " " << x << "\n";
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define endl "\n"
#define ll long long
#define vi vector<int>

// memset(arr, value, size);

vi v[100005];
int i, a, b, m, n, ans[100005];

int main() {
	cout << "Yes" << endl;
	queue<int> q;
	cin >> n >> m;
	fo(i, m) {
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	ans[1] = 1;
	q.push(1);
	while (q.size()) {
		a = q.front();
		q.pop();
		for (auto b : v[a]) {
			if (!ans[b]) {
				ans[b] = a;
				q.push(b);
			}
		}
	}

	Fo(i, 1, n) {
		cout << ans[i + 1] << endl;
	}

	return 0;
}

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

bool check(int y, int x, int H, int W) {
  return y >= 0 && y < H && x >= 0 && x < W;
}

int main() {
  int H, W;
  cin >> H >> W;
  
  char field[H][W];
  char changed[H][W];
  
  for (int i = 0; i < H; i++) 
    for (int j = 0; j < W; j++) 
      cin >> field[i][j];
  
  for (int i = 0; i < H; i++) {
    int count = 0;
    for (int j = 0; j < W; j++) {
     
      if (field[i][j] == '#') {
        changed[i][j] = '#';
        continue;
      }
      
      else {
        for (int sq_i = -1; sq_i <= 1; sq_i++) {
          for (int sq_j = -1; sq_j <= 1; sq_j++) {
            if (!check(i+sq_i, j+sq_j, H, W)) continue;
            
            if (field[i+sq_i][j+sq_j] == '#') count++;
          }
        }  
      }
      changed[i][j] = '0' + count;
      count = 0; 
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << changed[i][j];
    }
    cout << endl;
  } 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mp make_pair
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
void init() {
  int n, w;
  cin >> n >> w;
  int maxval=0;
  vector<int> weight(n), val(n);
  for (int i = 0; i < n; i++)
    cin >> weight[i] >> val[i];
  for (auto x : val)
    maxval += x;
 vector<int> dp(maxval + 1,1e9+1); // dp[j] min total weight that can be obtained with value exactly j
 dp[0]=0;
  for (int i = 0; i < n; i++) {
    for (int j = maxval; j >= val[i]; j--)
      dp[j] = min(dp[j], weight[i] + dp[j - val[i]]);
  }
//   for(auto x:dp)    cout<<x<<" ";
  int res = 0;
  for (int i = 0; i <= maxval; i++) {
    if (dp[i] <= w)
      res = max(res, i);
  }
  cout << res << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;


// 2011/10/23

// 0137 
public class Main {

	static int dataSet = 1;
	
	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		int a = readIntArray()[0];
		
		System.out.printf("Case %d:\n", dataSet++);
		for(int i = 0; i < 10; i++) {
			a = a * a;
			int r = a / 100;
			r = r % 10000;
			System.out.printf("%d\n", r);
			a = r;
		}
		
		
//		System.out.printf("%d\n", sum / size);
		
		return true; // ³íI¹ Ö
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "1:15:";

			inputStr = inputStr.replace(":", "\n");

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		//int N = Integer.MAX_VALUE;
		int N = readIntArray()[0];

		for(int i = 0; i < N; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè1sªÌæØè¶æØèÅÌ®lðÇÞ
	// EOFÌêÍnullðÔ·
	private static int[] readIntArray() throws IOException {

		String s = null;
		for(;;) {
			s = reader.readLine();
//			log.printf("%s\n", s);
			if (s == null)
				return null;
			s = s.trim();
			if (s.length() != 0) // ¦¦¦@Ç¤àËRósðÇÞ±Æª éBÇÝòÎ·Æ¤Ü­¢­çµ¢BBBB
				break;
		}
		
		String[] sp = s.split("[ ,]"); // æØè¶ÍXy[X©J}
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <stack>
using namespace std;
int main(){
    int N,count=0;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a,a+N);
    long long w=0,h=0;
    for(int i=0;i<N;i++){
        count++;
        if(a[i]!=a[i+1]){
            if(count>=4){
                w=a[i];
                h=a[i];
            }else if(count>=2){
                w=h;
                h=a[i];
            }
            count=0;
        }
    }
    cout << h*w << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, w, h;

int main()
{
	cin >> n >> h >> w;
	cout << (n - h + 1) * (n - w + 1) << endl;

	return 0;
}


Measured memory_bytes: 256
import queue
n,m = map(int,input().split())

adj = [[] for i in range(n)]
dist = [-1]*n
for i in range(m):
    a,b = map(int,input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
    
q = queue.Queue()
dist[0] = 0
q.put(0)

while not q.empty():
    x = q.get()
    
    for f in adj[x]:
        if dist[f] != -1:
            continue
        
        dist[f] = dist[x] + 1
        q.put(f)
     
if dist[n-1] == 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 41104
n=int(input())
if n==1:
	print(1)
	exit()
xy = sorted([list(map(int,input().split())) for i in range(n)])
p=q=0
ans=0
dic={}
for i in range(n-1):
	for j in range(i+1,n):
		p = xy[i][0]-xy[j][0]
		q = xy[i][1]-xy[j][1]
		if (p,q) in dic:
			dic[(p,q)]+=1
		else:
			dic[(p,q)]=1
print(n-max(dic.values()))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ri register int
using namespace std;
inline int read(){
	#define gc getchar
	bool f=1;
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))f^=ch==gc(),ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return f?ans:-ans;
	#undef gc
}
const int mod=998244353;
typedef long long ll;
inline int add(int a,int b){return (a+=b)<mod?a:a-mod;}
inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
inline int mul(int a,int b){return (ll)a*b%mod;}
inline void Add(int&a,int b){(a+=b)<mod?a:a-=mod;}
inline void Dec(int&a,int b){(a-=b)<0?a+=mod:a;}
inline void Mul(int&a,int b){a=(ll)a*b%mod;}
inline int ksm(int a,int p){int ret=1;for(;p;p>>=1,Mul(a,a))if(p&1)Mul(ret,a);return ret;}
const int N=1e5+5;
int n;
string s[N];
int main(){
	n=read();
	for(ri i=1;i<=n;++i)cin>>s[i],sort(s[i].begin(),s[i].end());
	sort(s+1,s+n+1);
	ll ans=0,cnt=0;
	for(ri i=1;i<=n;++i){
		if(s[i]!=s[i-1]){
			ans+=(ll)cnt*(cnt-1)/2;
			cnt=1;
		}
		else ++cnt;
	}
	ans+=(ll)cnt*(cnt-1)/2;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi>
#define pb push_back
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,i;
    cin>>n;
    vi v(n);
    for(i=0;i<n;i++)v[i]=i+1;
    vi p(n),q(n);
    for(i=0;i<n;i++)cin>>p[i];
    for(i=0;i<n;i++)cin>>q[i];
    int a=0,b=0;
    if(v==p)a=1;
    if(v==q)b=1;
    i=2;
    while(next_permutation(v.begin(),v.end()) && (a==0 || b==0)){
        if(v==p)a=i;
        if(v==q)b=i;
        i++;
    }
    cout<<abs(a-b)<<endl;
    return 0;
}

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

#define ll long long
#define NIL 0
#define INF 1e18
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vl vector<ll>
#define vvl vector<vector<ll>> 
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define pb push_back
#define F first
#define S second
#define pp pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rpk(i,k,n) for(int i=k;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++) 
#define RPK(i,k,n) for(int i=k;i<=n;i++) 
#define ritr(i,gr) for(auto i=gr.begin();i!=gr.end();i++)

int V, E, i, j, k, u, v, x, y, p, q, r;
vi *g;
vb sn;
vi d;

void add_edge(int a,int b) {g[a].pb(b);} 

int dfs_util(int s) {
    sn[s] = true;
    ritr(i, g[s]) {
        int to = *i;
        if(!sn[to]) {d[to] = dfs_util(to);}
        d[s] = max(d[s], d[to]+1);
    }
    return d[s];
}

void dfs() {
    int res = 0;
    sn.assign(V+1, false);
    d.assign(V+1,0);

    REP(i,V) 
        if(!sn[i]) {d[i] = max(d[i], dfs_util(i)); res = max(d[i], res);}
    cout<<res<<endl;
}

int main() {
    cin>>V>>E;
    g = new vi[V+1];
    rep(i,E) {
        cin>>x>>y;
        add_edge(x,y);
    }
    dfs();

}


Measured memory_bytes: 8832
#include "cstdio"
#include "algorithm"
using namespace std;
#define ri register int
int b[101];
int main()
{
	int n,m,ans=0,c,a,b;
	scanf("%d %d %d %d",&n,&m,&a,&b);
	printf("%d",n*m-(b*n)-(a*m)+(a*b));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N,M,K;
ll SA[200005];
ll SB[200005];
ll ans;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>M>>K;
rep1(i,N+1){
    ll A; cin>>A;
    SA[i]=SA[i-1]+A;
}
rep1(i,M+1){
    ll B; cin>>B;
    SB[i]=SB[i-1]+B;
}
rep(x,N+1){
    ll time=K-SA[x];
    if(time>0){
        ll in=upper_bound(SB,SB+1+M,time)-SB;
        ans=max(ans,x+in-1);
    }else if(time==0){
        ans=max(ans,x);
    }
}
cout<<ans<<endl;

}
    


Measured memory_bytes: 6708
import copy
H, W = map(int, input().split())
c = [list(map(int, input().split())) for i in range(10)]
A = [list(map(int, input().split())) for i in range(H)]
# cost = [[-1]*10 for i in range(10)]
# for j in range(10):
#     cost[j] = [[c[i][j], i] for i in range(10)]
cost = [-1]*10
cost[1] = 0

dp = [[-1]*10 for i in range(10)]
for i in range(10):
    dp[i][i] = 0


def search_cost(i, j, reached):
    # if dp[i][j] != -1:
    #     return dp[i][j]
    if cost[i] != -1:
        return cost[i]
    tmp_list = copy.copy(reached)
    tmp_list.append(i)
    ret = c[i][j]

    for k in range(10):
        if k == i or k == 1 or k in reached:
            continue
        else:
            tmp = c[i][k] + search_cost(k, j, tmp_list)
            ret = min(tmp, ret)
            if ret <= 2:
                break
            #print("i:"+str(i) + "k:" + str(k) + "j:"+str(j) + "=" + str(tmp))

    # dp[i][j] = ret
    # for i in range(10):
    #     print(dp[i])
    return ret


for i in range(10):
    if i == 1:
        continue
    else:
        if c[i][1] <= 2:
            dp[i][1] = c[i][1]
            cost[i] = c[i][1]
        else:
            cost[i] = search_cost(i, 1, [])
ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += cost[A[i][j]]
print(ans)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while (a>0 && c>0)
	{
		c-=b;
		if (c<=0)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		a-=d;
		if (a<=0)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().start();
    }
    void start(){
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[]a = new int[t];
        for(int i = 0; i < a.length;i++){
        	a[i] = in.nextInt();
        }

        int min = a[0];
        int maxRieki = Integer.MIN_VALUE;
        for(int i = 1; i < a.length; i++){
            int rieki = a[i] - min;
            if(a[i] < min) min = a[i];
            if(rieki > maxRieki) maxRieki = rieki;
        }
        System.out.println(maxRieki);
    }
}

Measured memory_bytes: 100600
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long[] ai = new long[(int) n];
		long max = -1000001;
		long min = 1000001;
		long sum = 0;
		for (int i = 0; i < n; i++) {
			ai[i] = scan.nextLong();
			if (max < ai[i]) {
				max = ai[i];
			}
			if (min > ai[i]) {
				min = ai[i];
			}
			sum = sum + ai[i];
		}
		System.out.print(min + " ");
		System.out.print(max + " ");
		System.out.println(sum);
	}
}

Measured memory_bytes: 41852
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll mod = 1e9+7;
vector<ll> g[100009];
ll n;
ll w[100009];
ll b[100009];
void dfs(ll v, ll p){
    b[v] = w[v] = 1;
    for(auto u : g[v]){
        if(u == p)
            continue;
        dfs(u, v);
        b[v] = b[v]*w[u]%mod;
        w[v] = w[v]*((b[u]+w[u])%mod)%mod;
    }
}
int main() {
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    cin >> n;
    for(ll i = 0; i < n-1; ++i){
        ll t1, t2;
        cin >> t1 >> t2;
        g[t1].pb(t2);
        g[t2].pb(t1);
    }
    dfs(1, -1);
    cout << (w[1]+b[1])%mod << "\n";
}

Measured memory_bytes: 11392
const { count } = require("console");

function main(lines) {
  const S = s();

  const N = S.length;
  const ans =  isPalindrome(S)
    && isPalindrome(S.slice(0, (N-1)/2))
    && isPalindrome(S.slice((N+1)/2))
    ? 'Yes' : 'No';
  
  return ans;
}

function isPalindrome(s) {
  return s == s.split('').reverse().join('');
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);

const ans = main(lines);
console.log( ans );

Measured memory_bytes: 30560
import math
import copy

neko = "Yes"
w = input()
for a in ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']:
    nya = len(w)
    if (nya-len(w.replace(a,'')))%2:
        neko = "No"
        break
print(neko)

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

void newline() {cout << endl;}
template <typename t> void display(t input){cout << input;}
template <typename t> void put(t input){display(input); newline();}
void iput(int input){display(input); newline();}

// Vectorの中から最小値を再帰で見つける    
int search_min(vector<int> ss){
  if (ss.size() == 0){
    return -1; // 見つからなかった場合は-1を返す
  } else {
    auto iter_min = min_element(ss.begin(), ss.end());
    if((*iter_min % 10) == 0){
      // 見つかった最小値が10の倍数なら削除して再帰
      ss.erase(iter_min);
      return search_min(ss);
    } else {
      // 目当ての値が見つかればそれを返す
      return *iter_min;
    }
  }
}

int main() {
  int n;
  cin >> n; // n
  vector<int> ss; // s_i
  for(int i=0; i<n; i++){ // 入力を受け取る
    int n;
    cin >> n;
    ss.push_back(n);
  }
  int sum = 0; // s_iの総和
  for(auto iter=ss.begin(); iter < ss.end(); iter++){
    sum += *iter;
  }
  if(sum%10 != 0){
    iput(sum); // 総和が10の倍数でないばあいそれを出力
  } else {
    int min = search_min(ss);
    if (min == -1){
      iput(0); // s_iの中から10の倍数しか含まれていなかった場合
               // 0を出力
    } else {
      iput(sum - min); // 総和 - (s_i の中の最小値)
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    cin>>a>>b>>c;
    for(long long i=a;i<=a*1000;i+=a)
    {
        if(i%b==c) 
     	{
     		cout<<"YES";
     		return 0;
     	}
    }
    cout<<"NO";
 	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> G[100];

int main() {
  ll N, K;
  cin >> N >> K;
  if (K > (N-1)*(N-2)/2) {
    cout << "-1" << endl;
    return 0;
  }
  
  cout << N*(N-1)/2 - K << endl;
  
  for (ll i = 2; i <= N; i++) {
    cout << 1 << " " << i << endl;
  }
  
  ll p = 0;
  
  for (ll i = 2; i <= N-1; i++) {
    for (ll j = i+1; j <= N; j++) {
      if (p < (N-1)*(N-2)/2-K) {cout << i << " " << j << endl;}
      p++;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
    int n,k;
    int m[105];
    memset(m,0,sizeof(m));
    cin>>n>>k;
    int i,j;
    for(i=0;i<k;i++)
    {
        int d;
        cin>>d;
        for(j=0;j<d;j++)
        {
            int a;
            cin>>a;
            m[a-1]++;
        }
    }
    int s=0;
    for(i=0;i<n;i++)
    {
        if(m[i]==0)
        {
            s++;
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3612