akhauriyash/Code-Regression huggingface dataset:
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))
def div(x):#約数配列
    div=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            div.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      div.append(x)
    return div
def div2(x):#素因数分解配列
    div2=[]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div2.append(check)
            x/=check
        check+=1
    if x != 1:
      div2.append(x)
    return div2

def main():
    #x,y = map(int,input().split())           x=1,y=2
    #a = input().split()                      a=['1','2','3',...,'n']
    #a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    #li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    #複数行の「1 2 3 4」型の入力を一配列に
    #x = sorted([list(map(int, input().split())) for _ in range(n)])
    #ソート x.sort(key=lambda y:y[1])
    # print("Yes")  print("No")  x=[[0 for _ in range(n)] for _ in range(n)]
    n,m = map(int,input().split()) 
    time=1900*m+100*(n-m)
    print(time*(2**m))

main()

Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <string.h>
#include <string>
#include <limits.h>
#include <algorithm>
#include <set>
#include <ctime>
#include <cmath>
#include <assert.h>
#include <stack>
using namespace std;
#define SZ(x) ((int)(x).size())
#define rep(i,a,n) for (int i=a; i<(int)n; i++)
#define per(i,n,a) for (int i=n; i>=a; i--)
#define hk push_back
#define pk pop_back
#define mp make_pair
#define PI 3.141592653589793
#define clr(a) memset(a, 0, sizeof(a))
#define clr1(a) memset(a, -1, sizeof(a))
#define c_false ios_base::sync_with_stdio(false); cin.tie(0)
typedef vector<int> VI;
typedef vector< pair<int, int> > VIP;
typedef vector< pair<int, pair<int, int> > > VIPP;
typedef vector<string> VS;
typedef vector <double> VD;
typedef vector <bool> VB;
typedef long long ll;
#define MAX_V 1000
const ll mod = 1000000007;
ll powmod(ll a, ll b) {
	ll res = 1; a %= mod; for (; b; b >>= 1){ if (b & 1)res = res*a%mod; a = a*a%mod; }return res;
}

int n, a[100005];

int main()
{
	c_false;
	cin >> n;
	rep(i, 1, n + 1) cin >> a[i];
	int ans = 0;
	rep(i, 1, n + 1) {
		int j = a[i], k = a[j];
		if (i == k) ans++;
	}
	ans /= 2;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
# coding: utf-8
N=int(input())
CSF=[]

for i in range(N-1):
    CSF.append(list(map(int,input().split())))

for i in range(N):
    T=[]
    for j in range(i,N):
        if j==i:
            T.append(0)
        else:
            Next_T=max(-(-T[-1]//CSF[j-1][2])*CSF[j-1][2],CSF[j-1][1])+CSF[j-1][0]
            T.append(Next_T)
    
    print(T[-1])


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define M 100005
using namespace std;
int f[M]={0},ff[M]={0};
struct edge{int u,next;}e[M]={0}; int head[M]={0},use=0;
void add(int x,int y){use++;e[use].u=y;e[use].next=head[x];head[x]=use;}
int n,cnt=0; 

void dfs(int x){
	for(int i=head[x];i;i=e[i].next) dfs(e[i].u);
	cnt=0; for(int i=head[x];i;i=e[i].next) ff[++cnt]=f[e[i].u];
	if(!head[x]) return;
	sort(ff+1,ff+cnt+1);
	f[x]=ff[1]+1;
	for(int i=2;i<=cnt;i++){
		f[x]=max(f[x],ff[i])+1;
	}
}

int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		int x; scanf("%d",&x);
		add(x,i);
	}
	dfs(1);
	cout<<f[1]<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>  // ver1.9.5
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int XOR(int a,int b){bitset<64>z(a),x(b),c;c=z^x;return c.to_ullong();}  //  XOR

signed main() {
  cout << fixed << setprecision(8);
  int n,m;
  cin >> n >> m;
  Vi a(n,1),now(n);
  now[0] = 1;
  int out,in;
  
  rep(i,0,m){
    cin >> out >> in;
    out--,in--;
    
    a[out]--;
    if(now[out]==1) now[in] = 1;
    if(a[out]==0) now[out] = 0;
    a[in]++;
  }
  
  cout << count(ALL(now), 1) << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int n, m;
vector<LL>a;

vector<LL>accum(const vector<LL>&imos)
{
	vector<LL>ret;
	LL tot = 0;
	for (int i = 0; i < imos.size(); ++i)
	{
		tot += imos[i];
		ret.push_back(tot);
	}
	return ret;
}

int main(void)
{
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
	{
		LL aa;
		cin >> aa;
		--aa;
		a.push_back(aa);
	}
	vector<LL>imos(m + 2, 0);//最後の2つの要素は番兵＝処理を行わない
	for (int i = 1; i < n; ++i)
	{
		LL S = a[i - 1];
		LL T = a[i];
		LL dif = T - S;
		if (dif < 0)
		{
			dif += m;
			if (dif == 1)
			{
				imos[0]++;
				imos[1]--;
				continue;
			}
			imos[0] += (T + 1);
			imos[1] -= (T + 2);
			imos[T + 1] += dif;
			imos[T + 2] -= (dif - 1);
			imos[S + 2]--;
		}
		else
		{
			if (dif == 1)
			{
				imos[0]++;
				imos[1]--;
				continue;
			}
			imos[0] += dif;
			imos[1] -= dif;
			imos[S + 2]--;
			imos[T + 1] += dif;
			imos[T + 2] -= (dif - 1);
		}
	}
	imos = accum(imos);
	imos = accum(imos);
	LL ans = LLONG_MAX;
	for (int i = 0; i < m; ++i)
	{
		ans = min(ans, imos[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using ll = long long;
int main()
{
  int N, K;
  std::cin >> N >> K;
  auto cb = [](const ll n){return n*n*n;};
  std::cout << (K%2==1?cb(N/K):cb(N/K)+cb((N+K/2)/K)) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,i,p,t;
	cin>>a>>b;
	p=a;
	t=b;
	for(i=1;i<b;i++)
	{
		a=a+p*pow(10,i);
	}
	for(i=1;i<p;i++)
	{
		b=b+t*pow(10,i);
	}
	if(t>p)
	cout<<a;
	else
	cout<<b;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cassert>
using namespace std;

class state{
public:
  int x,y,n;
  state(int y=0, int x=0, int n=0):y(y),x(x),n(n){}
  bool operator < (const state &s) const {return n > s.n;}
};

const int INF = (1<<29);
typedef pair<int,int> P;
int r,h,w,rx,ry,a[500][500],nowl,cntr;//,minl;
int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
bool f[500][500];
vector<int> numr[2],numl[2];
priority_queue<state> Q;
set<P> s;

bool check(int y, int x){
  if(y < 0 || y >= h) return false;
  if(x < 0 || x >= w) return false;
  return true;
}

void dfs(int y, int x){
  f[y][x] = true;
  cntr++;
  for(int i=0;i<4;i++){
    int ny = y + dy[i];
    int nx = x + dx[i];
    if(check(ny,nx) && !f[ny][nx]){
      if(a[ny][nx] <= nowl) dfs(ny,nx);
      else{
	//minl = min(minl,a[ny][nx]);
	if(s.find(P(ny,nx)) == s.end()){
	    Q.push(state(ny,nx,a[ny][nx]));
	    s.insert(P(ny,nx));
	  }
	  
      }
    }
  }
}

void solve(int k){
  nowl = 1;
  numr[k].clear();
  numl[k].clear();
  s.clear();
  fill(f[0],f[500],false);
  //Q.clear();
  Q.push(state(ry,rx,1));
  cntr = 0;
  while(!Q.empty()){
    state u = Q.top();
    Q.pop();
    nowl = u.n;
    /*
    minl = INF;
    for(int i=0;i<Q.size();i++){
      if(a[][] <= nowl){
	if(!f[Q[i].first][Q[i].second]) dfs(Q[i].first,Q[i].second);
	Q.erase(Q.begin()+i);
	i--;
	}
	}*/
    if(f[u.y][u.x]) continue;
    dfs(u.y,u.x);

    numr[k].push_back(cntr);
    numl[k].push_back(nowl);
    //if(cntr == h * w || cntr >= r) return;
    //nowl = minl;
  }
}

int main(){
  while(cin >> r && r){
    int ans = INF;
    for(int k=0;k<2;k++){
      cin >> w >> h >> rx >> ry;
      rx--;
      ry--;
      for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	  cin >> a[i][j];
      solve(k);

      //for(int i=0;i<numr[k].size();i++) cout << numr[k][i] << ' ' << numl[k][i] << endl;
      //cout << endl;

    }
    for(int i=0;i<numr[0].size();i++){
      if(numr[0][i] >= r){
	ans = min(numl[0][i],ans);
	break;
      }
      int cnt = r - numr[0][i];
      int pos = upper_bound(numr[1].begin(), numr[1].end(), cnt) - numr[1].begin();
      if(pos < numr[1].size()) ans = min(ans,numl[0][i] + numl[1][pos]);
      pos = max(0,pos-1);
      if(numr[0][i] + numr[1][pos] >= r) ans = min(ans,numl[0][i] + numl[1][pos]);
    }
    int pos = upper_bound(numr[1].begin(), numr[1].end(), r) - numr[1].begin();
    if(pos < numr[1].size()) ans = min(ans,numl[1][pos]);
    pos = max(0,pos-1);
    if(numr[1][pos] >= r) ans = min(ans,numl[1][pos]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 9848
import std.stdio, std.conv, std.array,std.string,std.algorithm;

void main()
{
    auto n=readln.chomp.to!int;
    long ans=1;
    for(int i=1;i<=n;i++){
        ans*=i;
        ans%=1000000000+7;
    
    }
    writeln(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	ll x;
	cin >> x;
	for (ll a = -1000; a <= 1000; a++) {
		for (ll b = -1000; b <= 1000; b++) {
			if (a*a*a*a*a - b*b*b*b*b == x) {
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main{

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

      int[][][] rooms = new int[4][3][10];
      for( int i = 0; i < 4; i++ ) {
        for( int j = 0; j < 3; j++ ) {
          Arrays.fill(rooms[i][j], 0);
        }
      }
      String[] lines = br.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int b,f,r;

      for(int i = 0; i < n; i++) {
        lines = br.readLine().split(" ");
        b = Integer.parseInt(lines[0]) - 1;
        f = Integer.parseInt(lines[1]) - 1;
        r = Integer.parseInt(lines[2]) - 1;
        rooms[b][f][r] += Integer.parseInt(lines[3]);
      }

      StringBuilder result = new StringBuilder(400);
      String sep = "####################\n";
      for(int i = 0; i < 4; i++ ) {
        for( int j = 0; j < 3; j++ ) {
          for( int k = 0; k < 10; k++ ){
            result.append(" " +rooms[i][j][k]);
          }
          result.append("\n");
        }
        if( i != 3) result.append(sep);
      }
      System.out.print(result);
    }
  }
}


Measured memory_bytes: 24360
S=int(input())
a=S//100
b=S%100
if a==0 or a>=13:
  if b==0 or b>=13:
    print("NA")
  else:
    print("YYMM")
else:
  if b==0 or b>=13:
    print("MMYY")
  else:
    print("AMBIGUOUS")  

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

int main(){
  int n,i,j,a;
  string s;
  cin >> n >> a;
  n%=500;
  if(n>a)cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i = 0, j, k, n;

	scanf("%d", &n);
        int array[n];
	while(i < n)  scanf("%d", &array[i++]);  
	for(i = 0; i < n; i++){
		j = i;
		while(j > 0 && array[j] < array[j-1]){
			k = array[j];
			array[j] = array[j-1];
			array[j-1] = k;
			j--;
		}
		for(j = 0; printf("%d", array[j]), j < n-1; j++)  printf(" ");
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
int main() {
 int k, x;
  cin >> k >> x;
  for (int i = x - k + 1; i <= x + k - 1; i++) {
   if (i > x - k + 1) cout << " ";
    cout << i;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    vector<int>v(n);rep(i,n)cin>>v[i];
    vector<int>hoge;
    sort(all(v));
    rep(i,v.size()){
        if(i==0)continue;
        string temp=to_string(v[i])+to_string(v[0]);
        string foo=to_string(v[0])+to_string(v[i]);
        hoge.push_back(stoi(temp));
        hoge.push_back(stoi(foo));
    }
    sort(all(hoge));
    cout<<hoge[2]<<endl;
}

Measured memory_bytes: 3264
N,M=map(int,input().split())
ls3 = []
for i in range(M):
    ls1=list(map(int,input().split()))
    ls1.pop(0)
    ls3.append(ls1)
ls2 = list(map(int,input().split()))

kk = 0
for i in range(2**N):
    ls4 = [0]*M
    for j in range(N):
        if (i>>j&1):
            for k in range(M):
                if j+1 in ls3[k]:
                    ls4[k] += 1
    ii = 0
    for l in range(M):
        if ls4[l] % 2==ls2[l]:
            ii += 1

    if ii == M:
        kk += 1
print(kk)

Measured memory_bytes: 74120
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi a(n+1), b;

		for(int i=1;i<=n;i++)
		{
			scanf("%d", &a[i]);
		}

		int m=0, last=0;
		b=a;
		for(int i=n;i>=1;i--)
		{
			for(int j=i*2;j<=n;j+=i)
			{
				b[i]^=b[j];
			}
			if(b[i])
			{
				m++;
				last=max(last, i);
			}
		}

//printf("b[]=");for(int mb:b) printf("%d ", mb); printf("\n");

		printf("%d\n", m);
		if(m>0)
		{
			for(int i=1;i<n;i++)
			{
				if(i==last) break;
				if(b[i]) printf("%d ", i);
			}
			printf("%d\n", last);
		}
	}
	return 0;
}


Measured memory_bytes: 2432
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

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

func main() {
	n := nextInt()

	c := 0
	for i := 0; i < n; i++ {
		x := nextInt()
		if x == c+1 {
			c++
		}
	}

	if c == 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(n - c)
	}
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pb push_back
#define ff first
#define ss second
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define sz(x) (int)(x).size()
#define EPS 0.000000001 //1e-9
using pii=pair<int,int>;
const long long INF=1e18;

template <class A, class B> ostream& operator<<(ostream& os, const pair<A,B> p) {return os << "(" << p.first << "," << p.second << ")";} 

void dprint(string s) {cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w = s.find(','); cout << "[" << s.substr(0,w) << ": " << t << "] "; dprint(s.substr(w+1, (int)s.size()-w), u...);} 

#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...) "KEEP CALM" 
#endif

const int N=1e6+5; // Don't forget to CHANGE this value ACC. TO Q.

int sq(int a)
{return a*a;}

double dist(int x, int y, int a=0, int b=0)
{
    return sqrt((double)sq(x-a)+(double)sq(y-b));
}

int32_t main()
{
    IOS;
    int n; double d; cin>>n>>d;
    int ans=0;
    while(n--)
    {
        int x, y; cin>>x>>y;
        if(dist(x, y)<=d)
            ans++;
    }
    cout<<ans;
    return 0;
}

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

using namespace std;
typedef long long LL;

int main(){
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  int work[200010]={0};
  vector<int> ans;
  int num=0;
  rep(i,N){
    if(S[N-i-1]=='o'){
      num++;
      work[N-i-1]++;
      i+=C;
    }
    if(num==K+1){
      cout << endl;
      return 0;
    }
  }
  num=0;
  rep(i,N){
    if(S[i]=='o'){
      num++;
      if(work[i]) ans.emplace_back(i+1);
      i+=C;
    }
    if(num==K) break;
  }
  int n=ans.size();
  if(!n) cout << endl;
  else{
    rep(i,n-1) cout << ans[i] << " ";
    cout << ans[n-1] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3448
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int N, L;
    scan(N, L);
    auto a = iota(N).map!(i => L + i).array.sort!"abs(a) < abs(b)";
    debug {
        writeln(a);
    }
    auto ans = a[1 .. $].sum();
    writeln(ans);
}














void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
"""    Arnab Chanda    """

from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7

a = input()

c = ord(a)

if c >= 97:
    print('a')
else:
    print('A')

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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

ll gcd(ll x,ll y){
  if(!(x%y))return y;
  else return gcd(y,x%y);
}

ll lcs(ll x,ll y){
  return (x*y)/gcd(x,y);
}

int main() {
  ll n,m;cin >> n >> m;
  ll a[n];
  rep(i,n){ll as;cin >> as;a[i]=as/2;}
  ll lcm=a[0];
  reps(i,n-1)lcm=lcs(lcm,a[i]);
  if(m<lcm){cout << 0;return 0;}
  for(auto A:a){
    if ( lcm / A % 2 == 0 ) {
      cout << 0;
      return 0;
    }
  }
  ll ans = ((m/lcm)+1)/2;
  cout <<ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 200010;
const int INF = INT_MAX/2;


int n,m,k;
int A[maxn], B[maxn];

vector <int> At, Bt;

int32_t main() {
	cin >> n >> m >> k;
	for (int i = 0; i< n;i++) {
		cin >> A[i];
	}
	for (int i =0;i<m;i++) {
		cin >> B[i];
	}
	
	int sum = 0;
	for (int i =0; i < n;i++) {
		sum += A[i];
		At.push_back(sum);
	}
	
	sum = 0;
	for (int i =0;i<m;i++) {
		sum += B[i];
		Bt.push_back(sum);
	}
	
	int ans = 0;
	ans = upper_bound(Bt.begin(), Bt.end(), k) - Bt.begin();
	
	for (int i =0;i<n;i++) {
		int timeleft = k - At[i];
		if (timeleft < 0) continue;
		
		int Btake = upper_bound(Bt.begin(), Bt.end(), timeleft) - Bt.begin();
		ans = max(ans, i+1 + Btake);
	}
	
	cout << ans;
	
}









Measured memory_bytes: 11024
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);

#ifdef BUGGY
	bool DEBUG = 1;
#endif
#ifndef BUGGY
	bool DEBUG = 0;
#endif

const int MAX_LIMIT = 4;

string S;
int a[MAX_LIMIT];

int main()
{
	cin >> S;

	for(int i = 0; i < MAX_LIMIT; i++) {
		a[i] = S[i] - '0';
	}

	for(int i = 0; i < (1<<(MAX_LIMIT - 1)); i++) {
		int thisAns = a[0];
		for(int j = 0; j < MAX_LIMIT - 1; j++) {
			if(i&(1<<j)) {
				thisAns += a[j + 1];
			} else {
				thisAns -= a[j + 1];
			}
		}

		if(thisAns == 7) {
			for(int j = 0; j < MAX_LIMIT - 1; j++) {
				printf("%d", a[j]);
				char ch = '-';
				if(i&(1<<j)) {
					ch = '+';
				}
				printf("%c", ch);
			}
			printf("%d=7\n", a[MAX_LIMIT - 1]);
			return 0;
		}
	}

	return 0;
}
/*
	Powered by Buggy Plugin
*/

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

int a, b, c, d, e, k;

int main()
{
  cin >> a >> b >> c >> d >> e >> k;

  if ((e-a) > k) cout << ":(" << endl;
  else cout << "Yay!" << 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();
  int C = sc.nextInt();
  if(A+B+C == 17 &&((A==5 && B==7)||(A==7 && B==5)||(A==5 && B==5)))
    System.out.println("YES");
  else System.out.println("NO");
}
}


Measured memory_bytes: 23892
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a;cin>>a;
  cout<<a*a;
}


Measured memory_bytes: 26940
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    int a[4][4];

    for(i=1; i<=3; i++)
    {
        for(j=1; j<=3; j++) cin>>a[i][j];
    }

    cin>>n; int ara[n+9];
    for(i=1; i<=n; i++) cin>>ara[i];

    bool flag = false;

    for(i=1; i<=3; i++)
    {
        int cnt = 0;
        for(j=1; j<=3; j++)
        {
            for(k=1; k<=n; k++)
            {
                if(ara[k]==a[i][j]){
                    cnt++; break;
                }
            }
        }
        if(cnt==3) flag = true;

        cnt = 0;
        for(j=1; j<=3; j++)
        {
            for(k=1; k<=n; k++)
            {
                if(ara[k]==a[j][i]){
                    cnt++; break;
                }
            }
        }
        if(cnt==3) flag = true;

    }

    int cnt = 0;
    for(i=1; i<=3; i++){
    for(j=1; j<=n; j++){
        if(ara[j]==a[i][i]){ cnt++; break;}
        }
    }

    if(cnt==3) flag = true;

    cnt = 0;
    for(i=1; i<=3; i++){
    for(j=1; j<=n; j++)
        if(ara[j]==a[i][3-i+1]){ cnt++; break;}
    }

    if(cnt==3) flag = true;

    if(flag) cout<<"Yes\n";
    else
        cout<<"No\n";

   // main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};





template<class T>
struct BIT {
    ll n;
    vector<T> bit;

    BIT(ll num) : bit(num+1, 0) { n = num; }

    void add(ll i, T w) {
        for (ll x = i; x <= n; x += x & -x) {
            bit[x] += w;
        }
    }

    T sum(ll i) {
        T ret = 0;
        for (ll x = i; x > 0; x -= x & -x) {
            ret += bit[x];
        }
        return ret;
    }
};



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll n,k;
    ll a[200010]={};
    ll sum[200010]={};
    cin>>n>>k;
    rep(i,n){
        cin>>a[i];
        sum[i+1]=sum[i]+a[i];
    }
    ll b[200010]={};
    b[0]=0;
    rep2(i,1,n+1){
        b[i]=sum[i]-i*k;
    }
    ll c[200010]={};
    rep(i,n+1) c[i]=b[i];
    sort(c,c+n+1);
    map<ll,ll> m;
    rep(i,n+1) m[c[i]]=i+1;
    BIT<ll> bit(n+1);
    ll ans=0;
    rep(j,n+1){
        ans += bit.sum(m[b[j]]);
        bit.add(m[b[j]],1);
    }
    cout<<ans<<endl;


    
    return 0;
}

Measured memory_bytes: 22656
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    int N;
    int sh[18][18];
    MEMSET(sh, 0);
    int a, x, y;
    cin>>N;
    rep(i, N){
        cin>>a;
        rep(j, a){
            cin>>x>>y;
            sh[i][x-1]=(y+1);
        }
    }
    int type=pow(2, N);
    int count, Maxim=0;
    rep(k, type){
        count=0;
        bool isOK=true;
        rep(i, N){
            if((int)(k/pow(2, i))%2==1){
                //cout<<i<<endl;
                count++;
                rep(j, N){
                    if(sh[i][j]==1 && (int)(k/pow(2, j))%2==1) isOK=false;
                    if(sh[i][j]==2 && (int)(k/pow(2, j))%2==0) isOK=false;
                }
            }
        }
        //cout<<((isOK)?100:10)<<endl;
        //cout<<endl;
        if(isOK==false) continue;
        else Maxim=max(Maxim, count);
    }
    cout<<Maxim<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    map<string,vector<pair<int,int>>> review;
    rep(n,0,N){
        string s; cin>>s;
        int p; cin>>p;
        review[s].push_back(make_pair(p,n+1));
    }

    for(auto r:review){
        sort(ToEnd(r.second));
        _rep(i,r.second.size()-1,0) cout<<r.second.at(i).second<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x4 = x1 - (y2 - y1);
  int y4 = x2 - x1 + y1;
  int x3 = x2 - (y2 - y1);
  int y3 = y2 + (x2 - x1);
  printf("%d %d %d %d\n", x3, y3, x4, y4);
}

Measured memory_bytes: 3252
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &bb) {
    for (int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &bb) {
    for (int i = 0;i < bb.size();i++) {
        std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    int n, a; cin >> n >> a;
    vector<int> da(n);
    vector<int> pos(0), neg(0);
        rip(i,n,0) {
        cin >> da[i];
        da[i] -= a;
        if(da[i] < 0) neg.push_back(-da[i]);
        else pos.push_back(da[i]);
    }
    vector<vector<ll>> dp1(pos.size()+1, vector<ll>(3000));
    dp1[0][0] = 1;
    rip(i,pos.size(), 0) {
        rip(j, 3000, 0) {
            dp1[i+1][j] += dp1[i][j];
            if(j + pos[i] < 3000) dp1[i+1][j+pos[i]] += dp1[i][j];
        }
    }
    vector<vector<ll>> dp2(neg.size()+1, vector<ll>(3000));
    dp2[0][0] = 1;
    rip(i,neg.size(), 0) {
        rip(j, 3000, 0) {
            dp2[i+1][j] += dp2[i][j];
            if(j + neg[i] < 3000) dp2[i+1][j+neg[i]] += dp2[i][j];
        }
    }
    ll ans = 0;
    rip(i,3000, 0){
        ans += 1LL * dp1.back()[i] * dp2.back()[i];
    }
    // rip(i,pos.size(), 0) cout << dp1[i][0] << endl;
    cout << ans-1 << endl;
}

Measured memory_bytes: 4628
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  int n,m;
  cin>>n>>m;
  vector<vector<int>> G(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  for(vector<int> ans:G){
    cout<<ans.size()<<"\n";
  }

  return 0;
}


Measured memory_bytes: 256
n,m = gets.chomp.split.map(&:to_i)
ls = m.times.map{gets.chomp.split.map(&:to_i)}
path = Array.new(n){Array.new}
flag = false

ls.each do |a,b|
  a -= 1
  b -= 1
  path[a] << b
  path[b] << a
end
stack = path[0]
stack.each do |i|
  if path[i].include?(n-1)
    flag = true
  end
end

puts flag ? "POSSIBLE" : "IMPOSSIBLE"

Measured memory_bytes: 27132
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#define ios std::ios::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define PI acos(-1.0)
#define EPS 1e-9 //epsilon 10^-9, checking for equality 
#define pb push_back
#define fi first
#define se second
#define go(i,a,n) for(int i=a;i<n;i++)
#define og(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(i,n) go(i,0,n)
#define per(i,n) og(i,0,n)
#define sz(x) (x.size())
#define isort(x) sort(x.begin(),x.end())
#define dsort(x) sort(x.rbegin(),x.rend())
#define all(x) x.begin(),x.end()
#define rall(x) (x).rbegin(),(x).rend()
#define pr(x) cout<<(x)<<endl
#define exist(e,s) ((s).find(e)!=(s).end()) //Element e in structure s
#define existstr(c,s) ((s).find(c) !=string::npos) //Character in structure
#define fo(x,s) for(auto &x:s) //for all x in structure s
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vector<int> > vvi;
typedef vector< vector<ll> > vvll;
typedef pair<int,int> ii;
typedef pair<int, pair<int,int> > iii;
typedef pair<ll,ll> pll;
typedef vector<ii> vii;
typedef vector<iii> viii;
const int inf=1e9+7; //10^9 +7
void solve();
//Many functions are taken from geeksforgeeks and other websites
inline void rvi(vi& v, int n){int temp; go(i,0,n){cin>>temp;v.pb(temp);}}
inline void rvll(vll& v, int n){ll temp;go(i,0,n){cin>>temp;v.pb(temp);}}
inline void prvi(vi&a){go(i,0,a.size()){cout<<a[i]<<" ";}cout<<endl;}
inline void prvll(vll&a){go(i,0,a.size()){cout<<a[i]<<" ";}cout<<endl;}
inline void prmii(map<int,int>& m){for(auto x:m){cout<<x.fi<<" "<<x.se<<endl;}cout<<endl;}
inline vi iprefixsum(vi& a){vi b;b.pb(a[0]);go(i,1,a.size()){b.pb(a[i]+b[i-1]);}return b;}
inline vi isuffixsum(vi& a){vi b(sz(a));b[sz(a)-1]=a[sz(a)-1];og(i,0,sz(a)-1){b[i]=a[i]+b[i+1];}return b;}
inline vll llprefixsum(vll& a){vll b;b.pb(a[0]);go(i,1,a.size()){b.pb(a[i]+b[i-1]);}return b;}
inline vll llsuffixsum(vll& a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];og(i,0,sz(a)-1){b[i]=a[i]+b[i+1];}return b;}
int main(){ios;solve();return 0;}
//--------SOLVE---------------------------------------------------------------------
string toString(int n)
{
    string str;
    stringstream ss;
    ss << n;
    ss >> str;
    return str;
}
 
// Method to convert n to base negBase
string toNegativeBase(int n, int negBase)
{
    //  If n is zero then in any base it will be 0 only
    if (n == 0)
        return "0";
 
    string converted = "";
    while (n != 0)
    {
        // Get remainder by negative base, it can be
        // negative also
        int remainder = n % negBase;
        n /= negBase;
 
        // if remainder is negative, add abs(base) to
        // it and add 1 to n
        if (remainder < 0)
        {
            remainder += (-negBase);
            n += 1;
        }
 
        // convert remainder to string add into the result
        converted = toString(remainder) + converted;
    }
 
    return converted;
}


void solve()
{
 	int n;
 	cin>>n;
 	int negBase=-2;
 	cout << toNegativeBase(n, negBase)<<endl;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,c;
  cin>>a;
 b=0;
  c=0;
  vector<long long>vec(a);
  for(long long i=0;i<a;i++){
    cin>>vec.at(i);
    b+=vec.at(i);
  }
  b-=vec.at(a-1);
  c+=vec.at(a-1);
  long long e=abs(b-c);
  for(long long j=a-2;j>0;j--){
    b-=vec.at(j);
    c+=vec.at(j);
    long long f=abs(b-c);
    if(f<e){
      e=f;
    }
  }
    cout<<e<<endl;
}

Measured memory_bytes: 1792
k = int(input())
if k % 2 == 0:
    print(-1)
else:
    mod = 7 % k
    counter = 1
    memo = 1
    mod_map = set()
    mod_map.add(mod)
    while mod != 0:
        memo = ((memo % k) * (10 % k)) % k
        mod = (mod + 7 * memo) % k
        if mod not in mod_map:
            mod_map.add(mod)
        else:
            counter = -1
            break
        counter += 1
        if mod == 0:
            break
    print(counter)


Measured memory_bytes: 77956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> card(N);
  for(int i=0; i<N; i++){
   cin >> card.at(i); 
  }
  
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());
  int A,B;
  
  for(int i=0; i<N/2; i++){
    A +=card.at(2*i);
      B +=card.at(2*i+1);
  }
  
  if(N%2 == 1){
   A += card.at(N-1);
  }
  
  cout << A-B << endl;
  
}

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

using namespace std;
int ok(int a, int b, int c)
{
    return (__gcd(a, __gcd(b, c)));
}
int main()
{
    int n;
    long long res = 0;
    cin >> n;
    for (int a = 1; a <= n; a++)
        for (int b = 1; b <= n; b++)
            for (int c = 1; c <= n; c++) res += ok(a, b, c);
    cout << res;
    return 0;
}


Measured memory_bytes: 3620
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
if s[-1] == "s":
  s += "es"
else:
  s += "s"
print(s)

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

ll n, w;
ll wt[102], val[102];
ll dp[102][100002];
bool vis[102][100002];

ll func( int pos, int baki ) {
  if (baki == 0) return 0;
  if (pos >= n) return 2e9;

  if ( vis[pos][baki] ) return dp[pos][baki];
  vis[pos][baki] = 1;
  
  ll res = 2e9;
  if ( baki - val[pos] >= 0 )
      res = wt[pos] + func( pos + 1, baki - val[pos] );

  res = min(
      res, 
      func(pos + 1, baki)
  );
  return dp[pos][baki] = res;
}

int main() {
  cin >> n >> w;
  for (int i = 0; i < n; ++i) cin >> wt[i] >> val[i];

  for (int i = 100000; i >= 0; --i) {
    if ( func(0, i) <= w ) {
       cout << i << endl;
       break;
    }
  }
  return 0;
}

Measured memory_bytes: 88320
n, z, w = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

# ref: http://drken1215.hatenablog.com/entry/2019/05/11/133400
# dp[山札からとった枚数][後手かどうか] := その状態からスタートしたときの、最終的なカードの数値の差の最適値（先手なら最大値、後手なら最小値）
dp = Array.new(n) { Array.new(2, 0) }
(n - 1).downto(0) do |i|
  # 先手
  y = i == 0 ? w : a[i - 1]
  dp[i][0] = (y - a[n - 1]).abs # のこりすべてとる
  (i + 1).upto(n - 1) do |j|
    dp[i][0] = [dp[i][0], dp[j][1]].max
  end

  # 後手
  x = i == 0 ? z : a[i - 1]
  dp[i][1] = (x - a[n - 1]).abs # のこりすべてとる
  (i + 1).upto(n - 1) do |j|
    dp[i][1] = [dp[i][1], dp[j][0]].min
  end
end

p dp[0][0]


Measured memory_bytes: 2172
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;

using namespace std;
int MOD = 1000000007;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a;
  cin >> a;
  int lena = a.size();
  int cnta = 0;
  REP(i,lena) {
    if( a[i] == 'A' ) cnta++;
  }
  if( cnta == 3 || cnta == 0 ) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<int> v(N);
    priority_queue<int> q;
    rep(i, N) {
        cin >> v[i];
        q.push(v[i]);
    }

    int max = q.top();
    for(int i = 0; i < N; i++) {
        int now = v[i];
        if(v[i] != max) {
            printf("%d\n", max);
        } else {
            q.pop();
            int ans = q.top();
            printf("%d\n", ans);
            q.push(now);
        }
    }
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    vector<string> f(n);
    vector<int> w(n), s(n), ord(n);
    for (int i = 0; i < n; i++) {
      cin >> f[i] >> w[i] >> s[i];
      ord[i] = i;
    }
    double G = 1e9;
    vector<int> ans(n);
    do {
      int sum = 0, no = 0;
      for (int i = n - 1; i >= 0; i--) {
        if (s[ord[i]] < sum) no++;
        sum += w[ord[i]];
      }
      if (no) continue;
      int tmp = 0;
      for (int i = 0; i < n; i++) {
        tmp += (i + 1) * w[ord[i]];
      }
      double g = 1. * tmp / sum;
      if (G - g > 1e-10) {
        G = g;
        ans = ord;
      }
    } while (next_permutation(ord.begin(), ord.end()));
    for (int i = 0; i < n; i++) {
      cout << f[ans[i]] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ep emplace_back
#define st first
#define sc second

using namespace std;

const ll mod = 998244353;
const int e = 3*1005;
const int base = 311;
// dung igt thay cho gt luc tinh giai thua
// 10
// cach tao hoan vi tu n so : n*(n+1)/2;

ll a[e];
ll dp[e][e][3];

int main()
{
    ll n, s;
    cin >> n >> s;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
    }
    dp[1][0][0] = 1;
    for(int i=1; i<=n; i++)
    {
        for(int j=0; j<=s; j++)
        {
           (dp[i+1][j][0] += dp[i][j][0]) %= mod;
           (dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
           (dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= mod;
           if(j + a[i] <= s)
           {
               (dp[i+1][j + a[i]][1] = dp[i][j][0] + dp[i][j][1]) %= mod;
               (dp[i+1][j + a[i]][2] = dp[i][j][0] + dp[i][j][1]) %= mod;
           }
        }
    }
    cout << dp[n+1][s][2];

}


Measured memory_bytes: 213120
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'

const int N = 51;
int w,h;
int board[N][N];

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

void dfs(int x, int y){
    board[x][y] = 0;
    for(int i = 0; i < 8; i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(nx >= 0 && nx < h && ny >= 0 && ny < w){
            if(board[nx][ny] == 1) dfs(nx,ny);
        }
    }
}

void solve(){
    rep(i,h){
        rep(j,w) {
            cin >> board[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(board[i][j] == 1) {
                ans++;
                dfs(i,j);
            }
        }
    }
    cout << ans << endl;
}

signed main() {
    while(true){
        cin >> w >> h;
        if(w == 0 && h == 0) return 0;
        solve();
    }
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll gcd(ll a, ll b){
	if(a < b)swap(a,b);
	if (b == 0)return a;
	return gcd(b, a%b);
}

ll a,b,c,d;

int main(){
	cin >> a >> b >> c >> d;
	a--;
	ll num1 = b - (b / c + b / d - b / (c*d/gcd(c,d)));
	ll num2 = a - (a / c + a / d - a / (c*d/gcd(c,d)));
	// cout << num1 << " " << num2 << endl;
	cout << num1 - num2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int ih, im, is, oh, om, os, value[] = {3600, 60, 1};;
  int dif, res[3]={0}, i, j = 0;

  while(j != 3){
  scanf("%d%d%d%d%d%d", &ih,&im,&is,&oh,&om,&os);

  dif = (oh*3600+om*60+os)-(ih*3600+im*60+is);

  i = 0;
  while(dif != 0){
    if(dif - value[i] >= 0){
      dif -= value[i];
      res[i]++;
    }
    else
      i++;
  }
  printf("%d %d %d\n", res[0], res[1], res[2]);
  res[0] = res[1] = res[2] = 0;
  j++;
  }
  return 0;
}

Measured memory_bytes: 600