akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef long double ld;
    ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
    ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
    #define endl '\n'
    #define max3(a,b,c) max(a,max(b,c))
    #define FOR(i,a,n,j) for(int i=a;i<n;i+=j)

    const int INF = 1e9+9;




    int main()
    {
        int n,k;
        cin>>n>>k;
        int dp[n+5];
        vector<int> v(n);
        FOR(i,0,n,1){
            cin>>v[i];
            dp[i] = INF;
        }
        v.push_back(INF);
        dp[0] = 0;
        FOR(i,0,n,1){
            FOR(j,1,k+1,1){
                if(i+j < n) dp[i+j]= min(dp[i+j], dp[i]+abs(v[i]-v[i+j]));
            }
        }

        cout<< dp[n-1] <<endl;

        return 0;
    }
        // gotcha;


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

int main()
{
	ll n;

	cin >> n;

	ll waru = 1e9 + 7;

	ll ans = 1;
	ll hachi = 1;
	ll kyu = 1;

	for (int i = 0; i < n; i++)
	{
		ans *= 10;
		hachi *= 8;
		kyu *= 9;
		if (ans >= waru)
			ans %= waru;
		if (hachi >= waru)
			hachi %= waru;
		if (kyu >= waru)
			kyu %= waru;
	}

	ans = ans + hachi - 2 * kyu;
	ans %= waru;

	if(ans < 0)
		ans += waru;
	if (ans < 0)
		ans += waru;
	if (ans < 0)
		ans += waru;

	cout << ans;

	// cout << ans;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char const* argv[])
{
  int64_t N, Q;
  std::string S;
  std::cin >> N >> Q;
  std::cin >> S;
  std::vector<int64_t> sum(N, 0);

  for (int i = 0; i < N - 1; i++)
    sum[i + 1] = sum[i] + (((S[i] == 'A') && (S[i + 1] == 'C')) ? 1 : 0);

  int64_t l, r;
  for (int i = 0; i < Q; i++) {
    std::cin >> l >> r;
    std::cout << sum[r - 1] - sum[l - 1] << '\n';
  }

  return 0;
}


Measured memory_bytes: 1856
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int i = sc.nextInt();
			int h = i / 3600;
			int m = i % 3600 / 60;
			int r = i % 60;
			 System.out.println(h + ":" + m + ":" + r);
		}  
}



Measured memory_bytes: 26352
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    cin.ignore();
    vector<string> name(n);
    pair<double,string> pp[50];
    rep(i,n){
      int p,a,b,c,d,e,f,s,m;
      cin>>pp[i].second>>p>>a>>b>>c>>d>>e>>f>>s>>m;
      int t=a+b+c+(d+e)*m;
      int in=f*s*m-p;
      pp[i].first=(double)in/t;
      pp[i].first*=-1;
    }
    sort(pp,pp+n);
    rep(i,n)cout<<pp[i].second<<endl;
    cout<<"#"<<endl;
  }
}

Measured memory_bytes: 3160
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n;
	static boolean[] prime;
	public static void main(String[] args) {
		makePrime();
		while(read()){
			solve();
		}
	}

	static boolean read(){
		if(!sc.hasNext())return false;
		n = sc.nextInt();
		return true;
	}
	static void solve(){
		int res = 0;
		for(int i = 2; i <= n; i++){
			if(prime[i])res++;
		}
		System.out.println(res);
	}
	
	static void makePrime(){
		prime = new boolean[1000001];
		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;
		for(int i = 2; i < prime.length; i++){
			if(prime[i]){
				for(int j = i*2; j < prime.length; j = j + i){
					prime[j] = false;
				}
			}
		}
	}
}

Measured memory_bytes: 13000
package main

import (
  "fmt"
)

func main() {
  var a, b int
  var i, j int
  
  fmt.Scanf("%d %d", &a, &b)

  max := a + b
  i = a - b
  j = a * b
  
  if(max < i) {
    max = i
  }
  
  if(max < j) {
    max = j
  }
  
  fmt.Println(max)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define int long long int
const int mod = 1000000007;
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;


signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int x;
    cin>>x;
    if(x == 1)
        cout<<0<<endl;
    else
    {
        cout<<1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/agc004_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll A, B, C;
  cin >> A >> B >> C;
  
  if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
    cout << 0 << endl;
    return 0;
  } else {
    ll a = (A / 2 + 1) * B * C - (A / 2) * B * C;
    ll b = (B / 2 + 1) * A * C - (B / 2) * A * C;
    ll c = (C / 2 + 1) * A * B - (C / 2) * A * B;
    cout << min(a, min(b, c)) << endl;
  }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << "\n";
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;
 
const double EPS = 1e-10;
const double PI = acos( -1.0 );
 
int a, b;
 
int main() {
    while ( scanf( "%d %d", &a, &b ) != EOF ) {
        a += b;
        int ans = 0;
        while ( true ) {
            if ( a / 10 == 0 && a % 10 == 0 ) {
                break;
            }
            ans++;
            a /= 10;
        }
        printf( "%d\n", ans );
    }
    return 0;
}

Measured memory_bytes: 1188
#include<stdio.h>
#define Max 100005
#define None -1
typedef struct {
  int parent,left,right;
}Node;
Node Tree[Max];
int n,Depth[Max];
void print_out(int);
int dep(int ,int);
int main(){
  int i,j,d,v,c,r;
  int l=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    Tree[i].parent=None;
    Tree[i].left=None;
    Tree[i].right=None;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)Tree[v].left=c;
      else Tree[l].right=c;
      l=c;
      Tree[c].parent=v;
    }
  }
  for(i=0;i<n;i++){
    if(Tree[i].parent==None)r=i;
  }
  dep(r,0);
  for(i=0;i<n;i++)print_out(i);
  return 0;
}
int dep(int u,int p){
  Depth[u]=p;
  if(Tree[u].right!=None)dep(Tree[u].right,p);
  if(Tree[u].left!=None)dep(Tree[u].left,p+1);
}
void print_out(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",Tree[u].parent);
  printf("depth = %d, ",Depth[u]);
  if(Tree[u].parent == None)printf("root, ");
  else if(Tree[u].left == None)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i = 0,c=Tree[u].left;c!=None;i++,c=Tree[c].right){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

Measured memory_bytes: 5300
#include <bits/stdc++.h>
#define IOS                 ios::sync_with_stdio(false); cin.tie(nullptr)
#define deb(x)              cout << #x << " = " << x << endl
#define deb2(x, y)          cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define f0(i, a, n)         for(i = a; i < n; i++)
#define f1(i, a, n)         for(i = a; i <= n; i++)
#define tc(t)               int t; cin >> t; while(t--)
#define ini(x, y)           memset(x, y, sizeof(x))
#define all(x)              x.begin(),x.end()
#define sz(x)               x.size()
#define ll                  long long int
#define vi                  vector<int>
#define si                  set<int>
#define pb                  emplace_back
#define ppb                 pop_back
#define mp                  make_pair
#define M                   1000000007
#define endl                '\n'
#define bits(x)             __builtin_popcountll(x)
#define zrbits(x)           __builtin_ctzll(x)

using namespace std;

void solve() {
        ll n, i;
        cin >> n;
        ll a[n];
        f0(i, 0, n) {
                cin >> a[i];
        }

        ll ans = 0;
        ll sum = 0;
        ll x;
        for(i = n-1; i >= 0; i--) {
                x = (a[i] * sum) % M;
                ans = (ans + x) % M;
                sum = (sum + a[i]) % M;
        }
        cout << ans << endl;
}

int main () {
        IOS;
        // tc(t)
        solve();
        return 0;
}

Measured memory_bytes: 5116
n, x = map(int,input().split())

if n >= 3:
    if 1 < x < 2*n-1:
        print("Yes")
        A = [0] * (2*n-1)
        V = [0] * (2*n-1 + 1)
        A[n-1] = x
        A[n-2] = x-1
        A[n] = x+1
        V[x-1] = 1
        V[x] = 1
        V[x+1] = 1
        if x == 2:
            A[n-3] = x+2
            V[x+2] = 1
        else:
            A[n+1] = x-2
            V[x-2] = 1
        # print(A)
        j = 0
        for i in range(1, 2*n-1 + 1):
            while j < 2*n-1 and A[j] != 0:
                j += 1
            if V[i] == 0:
                A[j] = i

        for i in A:
            print(i)
    else:
        print("No")
else:
    if n==2 and x==2:
        print("Yes")
        print(1)
        print(2)
        print(3)
    else:
        print("No")

Measured memory_bytes: 49884
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;


int main() {
	int N;
	cin >> N;
	int count4 = 0;
	int count2 = 0;
	rep(i, N) {
		int x;
		cin >> x;
		if (x % 4 == 0)count4++;
		else if (x % 4 != 0 && x % 2 == 0)count2++;
	}
	int n = 2 * count4 + count2;
	if (n >= N||count4>=N/2) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>

const long N = 1e9 + 7;

long powmod(long x, long y) {
  long res = 1;
  for (int i = 0; i < y; ++i) {
    res = res * x % N;
  }
  return res;
}

int main() {
  long s;
  std::cin >> s;
  long ans = powmod(10, s) - powmod(9, s) - powmod(9, s) + powmod(8, s);
  ans %= N;
  ans = (ans + N) % N;
  std::cout << ans << std::endl;
}


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

#define eb emplace_back
#define INF 1LL<<62
#define FLT_INF pow(10.0, 16)

using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<int, int>;

template <typename A> string to_string(const A& v);
string to_string(const string& s) { return '"'+ s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(const pair<A, B>& p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A> string to_string(const A& v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T>& val) {
  sort(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T>& val) {
  sort(val.begin(), val.end(), greater<T>());
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...);
#endif

#define COMMON_MOD pow(10, 9) + 7
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;

int main() {

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

  ll n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    char t;
    cin >> t;
    if (i == (k - 1)) {
      t += ('a' - 'A');
    }

    cout << t;
  }



  cout << endl;
  return 0;
}


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

using namespace std;

int cnt = 0;

void insertionSort(int *a, int n, int g) {
    int v, j;
    for (int i = g; i < n; i++) {
        v = a[i];
        j = i - g;
        while (j >= 0 && a[j] > v) {
            a[j + g] = a[j];
            j = j - g;
            cnt++;
        }
        a[j + g] = v;
    }
}

void shellSort(int *a, int n) {
    int m = 0;
    int s = 1;

    while ((n/s) > 0) {
        s *= 2;
        m++;
    }
    int g[20];
    for (int k = 0, t = 1; k < m; k++) {
        g[k] = n / t;
        t *= 2;
    }
    for (int i = 0; i < m; i++) {
        insertionSort(a, n, g[i]);
    }
    cout << m << endl;
    for (int i = 0; i < m; i++) {
        if (i != m - 1) {
            cout << g[i] << " ";
        } else {
            cout << g[i] << endl;
        }
    }
    cout << cnt << endl;
    for (int i = 0; i < n; i++) {
        cout << a[i] << endl;
    }
}

int main() {
    int n;
    int a[1000000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    shellSort(a, n);
    return 0;
}



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

using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = 1; i < s.length(); i++) {
		if (s[i - 1] == 'A' && s[i] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  
  int plug = 1;
  for (int i=0 ; ; i++){
    if (plug >= b){
      cout << i << endl;
      break;
    }
    plug += a-1;
  }
}

Measured memory_bytes: 3624
def main():
    N, K, Q = (int(i) for i in input().split())
    A = [int(input()) for i in range(Q)]
    minus = [K-Q for i in range(N)]
    for a in A:
        minus[a-1] += 1
    for mi in minus:
        if mi > 0:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 56792
#include <stdio.h>
int main(void)
{
	int H,W,i,j;
	while(1)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)
		{
			break;
		}
		for (i = 0; i < H; i++)
		{
			for (j = 0; j < W; j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	} 

	return 0;
}

Measured memory_bytes: 572
n, k = (int(v) for v in input().split())
vals = [int(v) for v in input().split()]

max_val = 0
for disc in range(max(k - len(vals), 0), k):
    pick = k - disc
    for lp in range(pick+1):
        if pick > lp:
            jewel = vals[:lp] + vals[-(pick-lp):]
        else:
            jewel = vals[:lp]
        neg = sum([j < 0 for j in jewel])
        if neg <= disc:
            reward = sum([j for j in jewel if j > 0])
        else:
            reward = sum(sorted(jewel)[disc:])
        if reward > max_val:
            max_val = reward
print(max_val)

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

char ch_trans(char c, int n)
{
    if (c - 'A' + n >= 26) {
        return static_cast< char >('A' + (c - 'A' + n - 26));
    } else {
        return static_cast< char >(c + n);
    }
}

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        cout << ch_trans(s[i], n);
    }
    cout << endl;
    return 0;
}

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

int main(int argc, char const *argv[])
{
    int a, b, c;
    short count = 0;

    cin >> a >> b >> c;

    for(int i = a; i <= b; i++)
    {
        if(c % i == 0)
        {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

set<int> d;

bool ok(int x) {
    int n = d.size();
    while (x>0) {
        int b = x%10;
        x/=10;
        if (d.count(b)) {
            return false;
        }
    }
    return true;
}

int main () {

    int n,k;cin>>n>>k;


    rep(i,k) {
        int a;cin>>a;
        d.insert(a);
    }

    int i = n;

    while (1) {
        if (ok(i)) {
            cout<<i<<endl;
            return 0;
        } else {
            i++;
        }
    }

}

Measured memory_bytes: 256
#pragma GCC target ("avx2") 
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define fast_az_fuk ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long 
#define int ll 
#define ull unsigned ll
#define ld long double 
#define pb push_back 
#define pf push_front
#define dll deque<ll> 
#define vll vector<ll> 
#define pll pair<ll,ll> 
#define mapll map<ll,ll>
#define endl "\n" 
#define all(v) v.begin(),v.end() 
#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;
void swap(auto*,auto*);
const ll N=2e3; ll fact[N+1];
const ll p=1e9+7;
ull power(ll x,ull y)
{
    ull res=1;
    while(y)
    {
        if(y&1) res=(res*x)%p;
        x=(x*x)%p; y>>=1;
    }
    return res;
}
ll nCr(ll n,ll r){
    ll ans=fact[n];
    ans=(ans*power(fact[r],p-2))%p;
    ans=(ans*power(fact[n-r],p-2))%p;
    return ans;
}
int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast_az_fuk
    fact[0]=1;
    for(ll i=1;i<=N;i++) fact[i]=(fact[i-1]*i)%p;
    ll s; cin>>s;
    ll ans=0;
    for(ll i=1;i;i++){
        if(s-3*i<0) break;
        if(s-3*i==0) {ans=(ans+1)%p; break;}
        ans=(ans+nCr(i+s-3*i-1,i-1))%p;
    }
    cout<<ans<<endl;
    return 0;
}
void swap(auto &a,auto &b)
{
    auto temp=a; a=b; b=temp;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> a(3);
  for(int i = 0; i < 3; i+=1){
    cin>>a[i];
  }
  sort(a.begin( ),a.end( ));
  if(a[0]==5 && a[1]==5 && a[2]==7){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
n, k = map(int, input().split())
A = sorted(map(int, input().split()))

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


smallest_ball = A[0]
for a in A[1:]:
    smallest_ball = gcd(smallest_ball, a)

print("POSSIBLE" if (A[-1]-k) %
      smallest_ball == 0 and k <= A[-1] else "IMPOSSIBLE")

Measured memory_bytes: 14224
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
  const n = Number(lines.shift());
  const res = [];
  for (let i = 0; i < n; i++) {
    res[i] = [];
    for (let j = 0; j < n; j++) {
      res[i][j] = 0;
    }
  }

  lines.forEach((l, i) => l.split(' ').splice(2).forEach(e => res[i][e-1] = 1));
  console.log(res.map(r => r.join(' ')).join('\n'));
})();


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

int main(){
  int i, n, key;
  cin >> n;
  int a[n];
  for(i=0; i<n; i++)
    cin >> a[i];

  for(int k=0; k<n-1; k++)
    cout << a[k] << " ";
  cout << a[n-1] << endl;
  
  for(int j=1; j<n; j++){
    key = a[j];
    i = j-1;
    while(i>=0 && a[i]>key){
      a[i+1] = a[i];
      i--;
    }
    a[i+1] = key;
    
    for(int k=0; k<n-1; k++)
      cout << a[k] << " ";
    cout << a[n-1] << endl;
    
  }
  
  return 0;
}

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

int main(){
  map<string,int> mp;
  int n,m;
  mp[""]=0;
  cin >> n;
  for(string s;n--;++mp[s])cin >> s;
  cin >> m;
  for(string s;m--;--mp[s])cin >> s;
  int ans=0;
  for(auto& e:mp)ans=max(ans,e.second);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      
      // 整数の取得
	  int a = sc.nextInt();
      int b = sc.nextInt();
      
      if((a*b)%2==1){
        System.out.println("Odd");
      }else{
        System.out.println("Even");
      }
    }
}

Measured memory_bytes: 35848
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    int s[13];
    int h[13];
    int c[13];
    int d[13];
    
    for(int i = 0;i < 13;i++) {
        s[i] = 0;
        h[i] = 0;
        c[i] = 0;
        d[i] = 0;
    }
    
    cin >> n;
    for(int i = 0;i < n;i++) {
        char C;
        int a;
        cin >> C >> a;
        switch(C) {
            case 'S':
            s[a - 1] = 1;
            break;
            case 'H':
            h[a - 1] = 1;
            break;
            case 'C':
            c[a - 1] = 1;
            break;
            case 'D':
            d[a - 1] = 1;
            break;
        }
    }
    
    for(int i = 0;i < 13;i++)
        if(!s[i])
            cout << "S " << i + 1 << endl;
    for(int i = 0;i < 13;i++)
        if(!h[i])
            cout << "H " << i + 1 << endl;
    for(int i = 0;i < 13;i++)
        if(!c[i])
            cout << "C " << i + 1 << endl;
    for(int i = 0;i < 13;i++)
        if(!d[i])
            cout << "D " << i + 1 << endl;
            
}


Measured memory_bytes: 3020
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.util.Collection;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        E solver = new E();
        solver.solve(1, in, out);
        out.close();
    }

    static class E {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            int C = in.nextInt();
            char[] S = in.next().toCharArray();


            int p = 0;
            int[] a1 = new int[N];
            int cnt = 1;
            while (p < N) {
                while (p < N && S[p] == 'x') p++;
                if (p >= N) break;
                a1[p] = cnt++;
                p += C + 1;
                if (cnt > K) break;
            }

            p = N - 1;
            int[] a2 = new int[N];
            cnt = K;
            while (p >= 0) {
                while (p >= 0 && S[p] == 'x') p--;
                if (p < 0) break;
                a2[p] = cnt--;
                p -= C + 1;
                if (cnt < 0) break;
            }
            TreeSet<Integer> ans = new TreeSet<>();
            for (int i = 0; i < N; i++) {
                if (a1[i] > 0 && a1[i] == a2[i]) ans.add(i + 1);
            }
            ans.stream().sorted().forEach(out::println);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

    }
}



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

int main(){
  int a;
  cin >> a;
  cout << 3 * a * a << endl;
}

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

class C
{
	static void Main()
	{
		var s753 = new[] { "3", "5", "7" };
		var n = Console.ReadLine();
		var d = n.Length;

		var r = 0;
		var s = new[] { "" };
		for (int i = 1; i <= d; i++)
		{
			s = s753.SelectMany(c => s.Select(x => c + x)).ToArray();
			r += s.Count(x => (i < d || x.CompareTo(n) <= 0) && s753.All(x.Contains));
		}
		Console.WriteLine(r);
	}
}


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

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void solve(){
    uint32_t N ;
    cin >> N;
    if( N % 1000){
        cout << 1000 - N % 1000 << endl;
    }else{
        cout << 0 << endl;
    }
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define pb push_back
#define in(x) int x; cin>>x;
#define inn(x, y) int x, y; cin>>x>>y;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

//bool primes[1000001];vi prime;
//void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
//if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}

//int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}

int32_t main(void){
	IOS;
	
	inn(n, d);
	int sum = 0;
	rep(i, 0, d)
	{
		in(temp);
		sum+=temp;
	}
	int ans = (n-sum >= 0)? n-sum : -1;
	cout<<ans;
}

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

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



Measured memory_bytes: 3092
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if abs(a-b) > k or abs(a-c)>k or abs(a-d)>k or abs(a-e)>k or abs(b-c)>k or abs(b-d)>k or abs(b-e)>k or abs(c-d)>k or abs(c-e)>k or abs(d-e)>k:
  print(':(')
else:
  print('Yay!')

Measured memory_bytes: 3064
#include "math.h"
#include<stdio.h>
#include<map>
#include<string>
#include<iostream>
#include<vector>

using namespace std;

int main(void){
	long long N;
    long long menu[4];
	long long min = 1000000000000000;
	long long result = 0;

	cin>>N;
    cin>>menu[0];
    cin>>menu[1];
    cin>>menu[2];
    cin>>menu[3];
    cin>>menu[4];

	for(int i=0; i<5; i++){
		if(menu[i] < min){
			min = menu[i];
		}
	}
	
	result = N/min + (N%min == 0 ? 0 : 1) + 4;
	
	cout<<result<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


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

int n;
int a[1000001];

void solve(int v){
	int cnt=0,cnt2=0;
	for(int i=0;i<n;i++){
		if(a[i]%2==0)cnt++;
		else cnt2++;
	}
	if(cnt%2==1){
		printf("%s\n",v%2==0?"First":"Second");
		return;
	}else{
		if(cnt2!=1){
			printf("%s\n",v%2==1?"First":"Second");
			return;
		}else{
			for(int i=0;i<n;i++){
				if(a[i]%2==1){
					if(a[i]==1){
						printf("%s\n",v%2==1?"First":"Second");
						return;
					}
					a[i]--;
				}
			}
			int gc=a[0];
			for(int i=1;i<n;i++){
				gc=gcd(gc,a[i]);
			}
			for(int i=0;i<n;i++){
				a[i]/=gc;
			}
			solve(v+1);
			return;
		}
	}
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	if(n==1){
		printf("%s\n",a[0]==1?"Second":"First");
	}else{
		solve(0);
	}
	return 0;
}


Measured memory_bytes: 640
def numtoalpha(n):
	
	if n <= 26:
		return chr(96+n)
	elif n % 26 == 0:
		return numtoalpha(n//26-1) + chr(96+26)
	else :
		return numtoalpha(n//26) + chr(96+(n%26))

if __name__ == '__main__':

	n = int(input())

	print(numtoalpha(n))


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

int main(){
	int c;
	cin >> c;
	if (1 <= c % 100 && c % 100 <= 12) {
		if (1 <= c / 100 && c / 100 <= 12) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "YYMM" << endl;
		}
	}
	else {
		if (1 <= c / 100 && c / 100 <= 12) {
			cout << "MMYY" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>
#include <cstdio>
#include <stack>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
//priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint n;

bool judge(llint x,llint y,llint z){
  if(x<y+z){
    if(y<x+z){
      if(z<x+y)return true;
    }
  }
  return false;
}

void solve(){
  cin >> n;
  llint L[n];
  for(int i=0;i<n;i++)cin >> L[i];
  sort(L,L+n);
  llint ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i>=j)continue;
      ans+=lower_bound(L,L+n,L[i]+L[j])-(L+j)-1;
    }
  }
  cout << ans << endl;
}

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


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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
//const ll M = 1000000000+7;

ll cnt = 0; 

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

struct BIT {
  private:
   vector<ll> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 

int main(){ 
  ll k;
  cin>> k;

  ll ans =0;

  rep(i,k){
    rep(j,k){
      ll tmp = __gcd(i+1, j+1);
      rep(l,k){
	ans += __gcd(tmp, l+1);
      }
    }
  }
  
  cout << ans << endl;
 
  
}


Measured memory_bytes: 3636
//M-SOLUTIONS 2020
#include <stdio.h>
int main(){
	int x;
	scanf("%d",&x);
	
	if(x <= 400 || x <600){
		printf("8");
	}
	else if(x <= 600 || x <800){
		printf("7");
	}
	else if(x <= 800 || x <1000){
		printf("6");
	}		
	else if(x <= 1000 || x <1200){
		printf("5");
	}	
	else if(x <= 1200 || x <1400){
		printf("4");
	}	
	else if(x <= 1400 || x <1600){
		printf("3");
	}	
	else if(x <= 1600 || x <1800){
		printf("2");
	}
	else if(x <= 1800 || x <2000){
		printf("1");
	}
	
	return 0;
}


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

int main(){
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    vector<int> b(n);
    for (int i = 0; i < n-1; i++){
        b.at(i) = a.at(i+1)-a.at(i);
    }
    b.at(n-1) = a.at(0) + k - a.at(n-1);
    sort(b.begin(), b.end());
    int ans = 0;
    for (int i = 0; i < n-1; i++){
        ans += b.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
module ModInt
  MOD = 10 ** 9 + 7

  def to_mod(a); a % MOD; end
  def add(a, b); (a + b) % MOD; end
  def mul(a, b); (a * b) % MOD; end
  def inv(a); a.pow(MOD - 2, MOD); end
  def div(a, b); mul(a, inv(b)); end
end

MOD = 10 ** 9 + 7

# MODを法とした階乗、組み合わせ
class ModCombination
  attr_reader :fac, :inv, :finv, :mod

  def initialize(n, mod: MOD)
    @mod = mod
    @fac = [1, 1]
    @inv = [1, 1]
    @finv = [1, 1]

    (2..n).each do |i|
      @fac[i] = fac[i - 1] * i % mod
      @inv[i] = mod - inv[mod % i] * (mod / i) % mod
      @finv[i] = finv[i - 1] * inv[i] % mod
    end
  end

  def combination(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0

    fac[n] * (finv[k] * finv[n - k] % mod) % mod
  end

  def repeated_combination(n, k)
    combination(n + k - 1, k)
  end
end

n, m, k = gets.split.map(&:to_i)
ft = ModCombination.new(n * m)

# https://www.wolframalpha.com/input/?i=sum%28n*%28x-n%29%29%2C+n%3D1+to+x-1&lang=ja
def choose_pair(x)
  x * (x - 1) * (x + 1) / 6
end

include ModInt
x_sum = to_mod(choose_pair(n) * m * m)
y_sum = to_mod(choose_pair(m) * n * n)
pat = ft.combination(n*m-2,k-2)
ans = mul(x_sum + y_sum, pat)
puts ans


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

const int N = 100005;

int n;
int a[N], b[N];
long long sumA, sumB;
int res;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i], sumA += a[i];
	for (int i = 1; i <= n; ++i) cin >> b[i];

	vector < pair<int,int> > vec;
	for (int i = 1; i <= n; ++i) {
		if (a[i] < b[i]) sumA -= b[i];
		else vec.push_back(make_pair(a[i], b[i]));
	}
	
	sort(vec.begin(), vec.end(), [&](pair<int,int> p, pair<int,int> q) {
		return p.first - p.second < q.first - q.second;
	});
	
	for (auto p : vec) sumB += p.second;
	
	if (sumA < sumB) return cout << -1 << endl, 0;
	
	for (auto p : vec) {
		sumB += p.first - p.second;
		if (sumB <= sumA) ++res;
	}
	
	cout << n - res << endl;
}


Measured memory_bytes: 2168
// 累積和 + 二分探索
// key以下を満たす最大のインデックスを返す二分探索
func binarySearch(_ key: Int) -> Int{
    var (l, r): (Int, Int) = (0, NMK[1]+1)

    while r-l > 1 {
        let i: Int = (l + r) / 2

        if isOK(idx: i, key: key) { l = i }
        else { r = i }
    }
    return l
}
// key以下かどうか
func isOK(idx: Int, key: Int) -> Bool {
    if csumB[idx] <= key { return true }
    else { return false }
}

let NMK: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
let As: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
let Bs: [Int] = readLine()!.split(separator: " ").map { Int($0)! }

var sum: Int = 0
let csumA: [Int] = [0] + As.map { sum += $0; return sum }
sum = 0
let csumB: [Int] = [0] + Bs.map { sum += $0; return sum }
var (a, b, res): (Int, Int, Int) = (0, 0, 0)

for a in 0...NMK[0] {
    if csumA[a] > NMK[2] { break }
    b = binarySearch(NMK[2]-csumA[a])
    res = max(res, a + b)
}
print(res)  // (๑•ૅㅁ•๑)

Measured memory_bytes: 26264
#include <bits/stdc++.h>
#define mod 1000000009
using namespace std;

typedef long long i64;

vector <int> adia[1010];
int lvl[1010];

void dfs(int nod, int tata, int l)
{
    int fii = 0;

    for (auto i : adia[nod]) {
        if (i != tata) {
            fii++;
            dfs(i, nod, l + 1);
        }
    }
    lvl[l] = max(lvl[l], fii);
}

pair <int, i64> solve(int nod1, int nod2 = 0)
{
    memset(lvl, 0, sizeof lvl);
    if (nod2 == 0)
        dfs(nod1, 0, 1);
    else {
        dfs(nod1, nod2, 1);
        dfs(nod2, nod1, 1);
    }
    int h = 0;
    i64 niv = 1 + (nod2 != 0);
    int nivmod = niv;

    for (int i = 1; lvl[i]; i++) {
        h = i;
        niv *= lvl[i];
        nivmod = 1LL * nivmod * lvl[i] % mod;
    }

    if (niv % mod != nivmod)
        return { 1e9, 1e9 };
    return { h + 1, niv };
}

int main()
{
    vector <pair <int, int>> edges;

    int n, a, b;
    cin >> n;

    for (int i = 1; i < n; i++) {
        cin >> a >> b;
        adia[a].push_back(b);
        adia[b].push_back(a);
        edges.push_back({ a, b });
    }

    pair <int, i64> ans = { 1e9, 1e9 };

    for (int i = 1; i <= n; i++)
        ans = min(ans, solve(i));

    for (auto i : edges)
        ans = min(ans, solve(i.first, i.second));

    cout << ans.first << ' ' << ans.second << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int lot[13][30];
int lotrun(int s, int m);
int main(){
	int a;
	for(;;){
		int n,s,g,m;
		cin >>n;
		if(!n){break;}
		cin >>s>>g>>m;
		for(int i=0; i<13; i++){for(int j=0; j<30; j++){lot[i][j] = 0;}}
		for(int i=0; i<m; i++){for(int j=0; j<n-1; j++){scanf("%1d",&lot[j+1][i]);}}
		if(g == lotrun(s,m)){cout <<"0"<<endl;goto jump;}
		for(int i=0; i<m; i++){
			for(int j=1; j<n; j++){
				bool f = false;
				if(!lot[j-1][i] && !lot[j][i] && !lot[j+1][i]){lot[j][i] = 1;f = true;}
				if(g == lotrun(s,m)){cout <<i+1<<" "<<j<<endl;goto jump;}
				if(f){lot[j][i] = 0;}
			}
		}
		cout <<"1"<<endl;
		jump:;
	}
	return 0;
}
int lotrun(int s,int m){
	for(int i=0; i<m; i++){
		if(lot[s-1][i]){s--;}
		else if(lot[s][i]){s++;}
	}
	return s;
}

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

bool compare_by_second(pair<int,int> a, pair<int,int> b)
{
  if (a.second != b.second) {
    return a.second < b.second;
  }
  return a.first < b.first;
}

int main()
{
  int n, m; cin >> n >> m;
  vector<pair<int, int>> v(m);
  rep(i, m) {
    int a,b; cin>>a>>b;
    a--; b--;
    v[i] = make_pair(a, b);
  }
  sort(v.begin(),v.end(), compare_by_second);
  int x = v[0].second;
  int y = v[0].first;
  int ans = 1;
  rep(i, m) {
    y = max(y, v[i].first);
    if (y >= x) {
      x = v[i].second;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, n);
	OUT(n + n * n + n * n * n);
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  
  for(int i=0; i<N; i++){
    cin >> d.at(i); 
  }
  
  sort(d.begin(), d.end());
  
  int count = 1;
  for(int i=0; i<N-1; i++){
    if(d.at(i) < d.at(i+1))
      count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int MinIndex(int array[], int N)
{
	int i;
	int tmp;
	int index;

	tmp = array[0];
	index = 0;
	for(i=1; i<N; i++)
	{
		if(array[i]<tmp)
		{
			tmp = array[i];
			index = i;
		}
	}
	return index;
}
int MaxIndex(int array[], int N)
{
	int i;
	int tmp;
	int index;

	tmp = array[0];
	index = 0;
	for(i=1; i<N; i++)
	{
		if(array[i]>tmp)
		{
			tmp = array[i];
			index = i;
		}
	}
	return index;
}

int main()
{
	int N;
	int A[MAX], B[MAX];
	int i;
	int index;

	scanf("%d", &N);

	for(i=0; i<N; i++)scanf("%d %d", &A[i], &B[i]);
	
	printf("%d\n", A[MaxIndex(A, N)] + B[MinIndex(B, N)]);

	return 0;
}


Measured memory_bytes: 896
hw=list(map(int,input().split()))
h=hw[0]
w=hw[1]

city=[]
distance=0
distance_all=[]

for i in range(h):
    city.append(list(map(int,input().split())))

for i in range(h):
    for j in range(w):
        for x in range(h):
            for y in range(w):
                distance=distance+min(abs(x-i),abs(y-j))*city[x][y]
        distance_all.append(distance)
        distance=0

print(min(distance_all))



Measured memory_bytes: 5604
n, x, y = map(int,input().split())
x, y = x-1, y-1
d=[0 for i in range(n)]

for i in range(n):
    for j in range(i+1,n):
        m = min(abs(i-j), abs(x-i)+abs(y-j)+1, abs(x-j)+abs(y-i)+1)
        d[m] += 1
for i in range(n-1):
    print(d[i+1])

Measured memory_bytes: 9176
using System;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int r = int.Parse(input[0]);
        int D = int.Parse(input[1]);
        int xo = int.Parse(input[2]);

        int[] xn = new int[11];
        xn[0] = xo;
        for(int i = 0; i < 10; i++)
        {
            xn[i + 1] = r * xn[i] - D;
        }

        for(int j = 1; j < 11; j++)
        {
            Console.WriteLine(xn[j]);
        }
    }
} 

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

int main() {
  int h, w;
  cin>>h>>w;
  string s[h];
  for (int i=0; i<h; i++) cin>>s[i];

  map<char, int> m;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      ++m[s[i][j]];
    }
  }
  int cnt2 = 0;
  int cnt_odd = 0;
  for (auto i: m) {
    int j = i.second;
    if (j % 4 == 0) {
      continue;
    } else if (j % 2 == 0) {
      ++cnt2;
    } else {
      ++cnt_odd;
      if ((j - 1) % 4 != 0) {
        ++cnt2;
      }
    }
  }

  if (h % 2 == 0 && w % 2 == 0) {
    if (cnt2 == 0 && cnt_odd == 0) {
      cout<<"Yes"<<endl;
    } else {
      cout<<"No"<<endl;
    }
  } else if (w % 2 == 0) {
    if (cnt_odd == 0 && cnt2 <= w / 2 && (w - 2 * cnt2) % 2 == 0) {
      cout<<"Yes"<<endl;
    } else {
      cout<<"No"<<endl;
    }
  } else if (h % 2 == 0) {
    if (cnt_odd == 0 && cnt2 <= h / 2 && (h - 2 * cnt2) % 2 == 0) {
      cout<<"Yes"<<endl;
    } else {
      cout<<"No"<<endl;
    }
  } else {
    if (cnt_odd != 1) {
      cout<<"No"<<endl;
      return 0;
    }
    if (cnt2 > (h + w - 2) / 2) {
      cout<<"No"<<endl;
      return 0;
    }
    if ((h + w - 2 - 2 *  cnt2) % 2 == 0) {
      cout<<"Yes"<<endl;
    } else {
      cout<<"No"<<endl;
    }

  }
}

Measured memory_bytes: 256
import java.math.*;
import java.io.*;
import java.util.*;
public class Main {

	static int[] w;
	static int[] v;
	static int n;
	static int W;
	static int[][] dp;
	
	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());
		n=Integer.parseInt(st.nextToken());
		W=Integer.parseInt(st.nextToken());
		w=new int[n];
		v=new int[n];
		dp=new int[n+1][W+1];
		for(int i=0;i<n;i++){
			st=new StringTokenizer(br.readLine());
			v[i]=Integer.parseInt(st.nextToken());
			w[i]=Integer.parseInt(st.nextToken());
			Arrays.fill(dp[i],-1);
		}
		
		
		for(int i=0;i<=W;i++){
			dp[n][i]=0;
		}for(int i=n-1;i>=0;i--){
			for(int j=0;j<=W;j++){
				if(j<w[i]){
					dp[i][j]=dp[i+1][j];
				}
				else{
					dp[i][j]=Math.max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
				}
			}
		}
		System.out.println(dp[0][W]);
		
		
	}
	
}

Measured memory_bytes: 29072
#include<cstdio>
#include<vector>
#include<algorithm>
int main(){
    int n;
    std::vector<std::pair<int,int>> vxy,vpq;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        vxy.push_back({x,y});
    }
    std::sort(vxy.begin(),vxy.end());
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            vpq.push_back({vxy[j].first-vxy[i].first, vxy[j].second-vxy[i].second});
        }
    }
    int num_cost0_max=0;
    for(auto &pq:vpq){
        int num_cost0=0;
        int p=pq.first,q=pq.second;
        for(auto &xy:vxy){
            int x=xy.first,y=xy.second;
            for(auto &next_xy:vxy){
                if(next_xy.first==x-p&&next_xy.second==y-q){
                    num_cost0++;
                }
            }
        }
        num_cost0_max=std::max(num_cost0,num_cost0_max);
    }
    printf("%d\n",n-num_cost0_max);
    return 0;
}

Measured memory_bytes: 256