akhauriyash/Code-Regression huggingface dataset:
import collections

class MaxFlow:
    """Dinic Algorithm: find max-flow
       complexity: O(EV^2)
       used in GRL6A(AOJ)
    """
    class Edge:
        def __init__(self, to, rev, cap):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V):
        """ V: the number of vertexes
            E: adjacency list
            source: start point
            sink: goal point
        """
        self.V = V
        self.E = [[] for _ in range(V)]

    def add_edge(self, fr, to, cap):
        self.E[fr].append(self.Edge(to, len(self.E[to]), cap))
        self.E[to].append(self.Edge(fr, len(self.E[fr])-1, 0))

    def dinic(self, source, sink):
        """find max-flow"""
        INF = float('inf')
        maxflow = 0
        while True:
            self.bfs(source)
            if self.level[sink] < 0:
                return maxflow
            self.itr = [0] * self.V
            while True:
                flow = self.dfs(source, sink, INF)
                if flow > 0:
                    maxflow += flow
                else:
                    break

    def dfs(self, vertex, sink, flow):
        """find augmenting path"""
        if vertex == sink:
            return flow
        for i in range(self.itr[vertex], len(self.E[vertex])):
            self.itr[vertex] = i
            e = self.E[vertex][i]
            if e.cap > 0 and self.level[vertex] < self.level[e.to]:
                d = self.dfs(e.to, sink, min(flow, e.cap))
                if d > 0:
                    e.cap -= d
                    self.E[e.to][e.rev].cap += d
                    return d
        return 0

    def bfs(self, start):
        """find shortest path from start"""
        que = collections.deque()
        self.level = [-1] * self.V
        que.append(start)
        self.level[start] = 0

        while que:
            fr = que.popleft()
            for e in self.E[fr]:
                if e.cap > 0 and self.level[e.to] < 0:
                    self.level[e.to] = self.level[fr] + 1
                    que.append(e.to)

N = int(input())
G = MaxFlow(300)

AB = []
for i in range(1,N+1):
	a,b = input().split()
	a_i = int(a)
	b_i = int(b)
	AB.append((a_i,b_i))

	G.add_edge(0,i,1)

CD = []
for j in range(N+1,2*N+1):
	c,d = input().split()
	c_i = int(c)
	d_i = int(d)
	CD.append((c_i,d_i))

	G.add_edge(j,2*N+1,1)


for n in range(1,N+1):
	for m in range(N+1,2*N+1):
		if((AB[n-1])[0]<(CD[m-(N+1)])[0] and (AB[n-1])[1]<(CD[m-(N+1)])[1]):
			G.add_edge(n,m,1)

flow_value = G.dinic(0,2*N+1)
print(int(flow_value))

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

using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}int sum = 0;
	for (int i = 1; i < n-1; i++) {
		if (p[i] < p[i + 1] && p[i - 1] < p[i])sum++;
		if (p[i + 1] < p[i] && p[i] < p[i - 1])sum++;
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int a,b,c;
	cin>>a>>b;
	for(int i=1;i<=1000;i++)
	{
		if(i*0.08-fmod(i*0.08,1)==a&&i*0.1-fmod(i*0.1,1)==b)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------


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

    if ((a <= 0) && (b >= 0)) printf("Zero\n");
    else if (a > 0) printf("Positive");
    else {
        if ((b-a) & 1) printf("Positive\n");
        else printf("Negative\n");
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
string s;
int q,t[200010],f[200010],m;
char c[200010];
vector<char>a,b;
signed main(){
    cin>>s>>q;
    rep(i,q){
        cin>>t[i];
        if(t[i]==1){
            m++;
        }
        if(t[i]==2){
            cin>>f[i]>>c[i];
            if(f[i]==1){
                if(m%2==0)a.pb(c[i]);
                else b.pb(c[i]);
            }
            if(f[i]==2){
                if(m%2==0)b.pb(c[i]);
                else a.pb(c[i]);
            }
        }
    }
    vector<char>ans;
    reverse(all(a));
    for(char C:a)ans.pb(C);
    for(char C:s)ans.pb(C);
    for(char C:b)ans.pb(C);
    if(m%2)reverse(all(ans));
    for(char C:ans)cout<<C;
    cout<<endl;
    return 0;
}

Measured memory_bytes: 5560
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7

def sol():
    H, W = map(int, input().split())
    chars = []

    for _ in range(H):
        chars += list(input().strip())

    cnt = Counter(chars)

    if H % 2 == 0 and W % 2 == 0:
        for _, c in cnt.items():
            if c % 4 != 0:
                print('No')
                return
        print('Yes')
        return
    elif H % 2 == 0 or W % 2 == 0:
        twoCount = 0
        if H % 2 == 0:
            twoCount = H // 2
        else:
            twoCount = W // 2
        for _, c in cnt.items():
            if c % 4 == 0:
                continue
            if c % 2 == 0:
                twoCount -= 1
            else:
                print('No')
                return
        if twoCount >= 0:
            print('Yes')
        else:
            print('No')
        return
    else:
        oneCount = 0
        twoCount = H // 2 + W // 2
        for _, c in cnt.items():
            if c % 4 == 1:
                oneCount += 1
                continue
            if c % 4 == 3:
                oneCount += 1
                twoCount -= 1
                continue
            if c % 4 == 0:
                continue
            if c % 2 == 0:
                twoCount -= 1
                continue
            print('No')
            return
        if oneCount == 1 and twoCount >= 0:
            print('Yes')
        else:
            print('No')


sol()

Measured memory_bytes: 3444
import sys
import pprint

N = sys.stdin.readline()
S = sys.stdin.readline()

N = int(N.strip())
S = S.strip()

#print (N)
#print (S)

mydict = {}

for x in range(N):
	if S[x] in mydict:
		mydict[S[x]] += 1
	else:
		mydict[S[x]] = 1

#pprint.pprint(mydict)

count_1 = 0
c = 1

for k in mydict:
		c *= mydict[k] + 1


print((c - 1) % (10**9 + 7), end="")

Measured memory_bytes: 3828
import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int r = Integer.parseInt(sc.next());
    int d = Integer.parseInt(sc.next());
    int x = Integer.parseInt(sc.next());

    int xBefore = x;
    int xNext = 0;
    for (int i = 1; i <= 10; i++) {
      xNext = r * xBefore - d;
      System.out.println(xNext);
      xBefore = xNext;
    }
  }

}


Measured memory_bytes: 21844
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
inline int read()
{
    int sum=0,t=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-') t=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        sum=sum*10+ch-'0';
        ch=getchar();
    }
    return sum*t;
}
int a,b;
int main()
{
    cin>>a>>b;
    cout<<a+b/2<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
number = []
five_number = []

tmp = int(math.sqrt(55555))
count = 0

for i in range(2, tmp):
    count = 0
    for k in range(2, i):
        if i % k == 0:
            count = 1

    if count == 0:
        number.append(i)
        if i % 5 == 1:
            five_number.append(i)

for i in range(tmp, 55555):
    count = 0
    if len(five_number) == 55:
        break
    for k in number:
        if i % k == 0:
            count = 1

    if count == 0 and i % 5 == 1:
        five_number.append(i)

print(*five_number[0:n:])


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

int main(){
  priority_queue<int> Q;
  string n;
  while(cin >> n && n != "end"){
    if(n == "insert"){
      int a;
      cin >> a;
      Q.push(a);
    }
    if(n == "extract"){
      int m = Q.top();
      Q.pop();
      cout << m << endl;
    }  
  }
}

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

int main(){
    int N, M;
    cin >> N;
    vector<int> T(N);
    for(int i=0; i<N; i++){
        cin >> T[i];
    }
    cin >> M;
    typedef pair<int, int> effect;
    vector<effect> X(M);
    for(int i=0; i<M; i++){
        int index, val;
        cin >> index >> val;
        X[i] = effect(index-1, val);
    }

    int sum=0;
    for(int i=0; i<N; i++){
        sum += T[i];
    }

    for(int i=0; i<M; i++){
        effect eff = X[i];
        int ans = sum - T[eff.first] + eff.second;
        cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

typedef struct star{
    int x, y;
} star_t;

int solve(star_t *stars, star_t *unko, int m, int n, int dx, int dy) {
    int i, j;
    for (i = 0; i <= m; i++) {
        if (j == -1)
            return 0;
        else {
            if (i == m)
                return 1;
        }
        for (j = 0; j <= n; j++) {
            if (j == n) {
                j = -1;
                break;
            }
            if (unko[j].x - stars[i].x == dx && unko[j].y - stars[i].y == dy) {
                break;
            }
        }
    }
}

int main(){
    while (1) {
        int n, m, i, j;
        star_t stars[200];
        star_t unko[1000];
        scanf("%d", &m);
        if (m == 0)
            break;
        for (i = 0; i < m; i++) {
            scanf("%d %d", &stars[i].x, &stars[i].y);
        }
        scanf("%d", &n);
        for (i = 0; i < n; i++) {
            scanf("%d %d", &unko[i].x, &unko[i].y);
        }

        for (i = 0; i < n; i++) {
            int dx = unko[i].x - stars[0].x;
            int dy = unko[i].y - stars[0].y;
            printf("");
            if ( solve(stars, unko, m, n, dx, dy) ) {
                printf("%d %d\n", dx, dy);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 608
/*
/// https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_a
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
const int N =2e6+6;
const int mod = 1e9+7;
void solve(){
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
    while(t--)solve();
    return 0;
}
*/
///*
/// https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_b
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
const int N =2e6+6;
const int mod = 1e9+7;
void solve(){
    ll a,v;
    ll b,w;
    ll T;
    cin>>a>>v>>b>>w>>T;
    ll d1 = v*T;
    ll d2 = w*T;
    d2+= abs(b-a);
//    cout<<d1<<" "<<d2<<endl;
    if(d2>d1)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
    while(t--)solve();
    return 0;
}

//*/
/*
/// https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_c
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
const int N =2e6+6;
const int mod = 1e9+7;
int a[N];
int b[N];
void solve(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)a[i] = 0;
    for(int it = 1;it<=min(k,50);it++){
        for(int i=1;i<=n;i++){
            int x = max(1,i-a[i]);
            int y = min(n+1,i+a[i]+1);
            b[x] ++;
            b[y]--;
        }
        for(int i=1;i<=n;i++){
            b[i]+=b[i-1];
            a[i] = b[i];
        }
        for(int i=0;i<=n+1;i++)b[i] = 0;
    }
    for(int i=1;i<=n;i++)cout<<a[i]<<" ";
    cout<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
    while(t--)solve();
    return 0;
}
*/


Measured memory_bytes: 3640
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;

int main() {
	double n, m, d;
	cin >> n >> m >> d;
	double cnt = 2 * n - 2 * d;
	if (d == 0)cnt = cnt / 2;
	printf("%.8f", cnt*(m - 1) / (n*n));
	
	return 0;
}

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

int main() {
	int n; cin >> n;
	int la[5][20] = { 0 };
	int num;
	char mark;

	for (int i = 0; i < n; ++i) {
		cin >> mark >> num;
		if (mark == 'S') la[0][num - 1] = 1;
		else if (mark == 'H') la[1][num - 1] = 1;
		else if (mark == 'C') la[2][num - 1] = 1;
		else la[3][num - 1] = 1;
	}

	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 13; ++j) {
			if (!la[i][j]) {
				if (!i) printf("S %d\n", j + 1);
				else if (i == 1) printf("H %d\n", j + 1);
				else if (i == 2) printf("C %d\n", j + 1);
				else printf("D %d\n", j + 1);
			}
		}
	}
}


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

#define MAX 100002

int main() {
  int n;
  int a, b;
  int v[MAX] = {};
  
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a >> b;
    v[a] ++;
    v[b+1] --;
  }

  int now = 0;
  int ans = 0;
  for(int i=0; i<MAX; i++) {
    now += v[i];
    if(i <= now+1) ans = i-1;
  }

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

Measured memory_bytes: 1560
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

int main(){
    int n;
    scanf("%d", &n);
    multiset<int> S, T;
    rep(i, 1<<n){
        int a;
        scanf("%d", &a);
        S.insert(a);
    }
    
    T.insert(*S.rbegin());
    S.erase(--(S.end()));
    vector<int> v;
    while(!S.empty()){
        for(auto t=T.begin(); t!=T.end(); ++t){
            auto s = S.lower_bound(*t);
            if(s == S.begin()){
                printf("No\n");
                return 0;
            }
            --s;
            v.push_back(*s);
            S.erase(s);
        }
        for(int x: v) T.insert(x);
        v.clear();
    }
    printf("Yes\n");
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T,class U>
istream& operator >> (istream&is, P<T,U>&p){
  is >> p.first >> p.second;
  return is;
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v){
    is >> e;
  }
  return is;
}

int main(){
  int n,k; cin >> n >> k;
  vector<int> v(n); cin >> v;
  for(int i = 0; i < n-1; ++i){
    if(v[i] + v[i+1] >= k){
      cout << "Possible" << endl;
      for(int j = 1; j < i+1; ++j){
	cout << j << endl;
      }
      for(int j = n-1; j >= i+1; --j){
	cout << j << endl;
      }
      return 0;
    }
  }
  cout << "Impossible" << endl;
}


Measured memory_bytes: 3788
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(int[]), sx = rd[0], sy = rd[1], tx = rd[2], ty = rd[3];
  auto x = tx - sx, y = ty - sy;

  write('U'.repeat.take(y));
  write('R'.repeat.take(x));
  write('D'.repeat.take(y));
  write('L'.repeat.take(x));
  write("L");
  write('U'.repeat.take(y+1));
  write('R'.repeat.take(x+1));
  write("D");
  write("R");
  write('D'.repeat.take(y+1));
  write('L'.repeat.take(x+1));
  write("U");
  writeln;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d;
    double f;
    scanf("%d %d",&a,&b);
    c=a/b;
    d=a%b;
    f=(double)a/b;
    printf("%d %d %.5lf\n",c,d,f);
    return 0;
}



Measured memory_bytes: 2036
using System;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');


            int a = int.Parse(array[0]);

            int b = int.Parse(array[1]);

            int t = int.Parse(array[2]);

            int bis;

            bis = t / a;

            bis = bis * b;

            Console.WriteLine(bis);
        }
    }
}


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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);

void solveA() {
	int a[3];
	for(int i = 0; i < 3; i++) 
		cin >> a[i];
	int ans = 10000000;
	do {
		int here = 0;
		for(int i = 1; i < 3; i++)
			here += abs(a[i] - a[i-1]);
		ans = min(here, ans);
	} while(next_permutation(a,a+3));
	cout << ans << endl;
}
void solveB() {
	FAST;
	string s, t;
	cin >> s >> t;
	int n = s.size();
	for(int i = 0; i < n; i++) {
		string tmp = "";
		for(int j = i; j < n; j++)
			tmp += s[j];
		for(int j = 0; j < i; j++)
			tmp += s[j];
		if(tmp == t) { cout << "Yes\n"; return; }
	} cout << "No\n";
	return;
}
void solveC() {
	int n;
	scanf("%d", &n);
	ll ret = 0;
	for(int i = 0; i < n; i++) {
		int x; scanf("%d", &x);
		ret += x-1;
	} printf("%lld\n", ret);
}
void solveD() {

}

int main() {
	//solveA();
	//solveB();
	solveC();
	//solveD();
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
//#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010
#define md 1000000007//998244353

#define _vcppunko4(tuple) _getname4 tuple
#define _getname4(_1,_2,_3,_4,name,...) name
#define _getname3(_1,_2,_3,name,...) name
#define _trep2(tuple) _rep2 tuple
#define _trep3(tuple) _rep3 tuple
#define _trep4(tuple) _rep4 tuple
#define _rep1(n) for(lint i=0;i<n;++i)
#define _rep2(i,n) for(lint i=0;i<n;++i)
#define _rep3(i,a,b) for(lint i=a;i<b;++i)
#define _rep4(i,a,b,c) for(lint i=a;i<b;i+=c)
#define _trrep2(tuple) _rrep2 tuple
#define _trrep3(tuple) _rrep3 tuple
#define _trrep4(tuple) _rrep4 tuple
#define _rrep1(n) for(lint i=n-1;i>=0;i--)
#define _rrep2(i,n) for(lint i=n-1;i>=0;i--)
#define _rrep3(i,a,b) for(lint i=b-1;i>=a;i--)
#define _rrep4(i,a,b,c) for(lint i=a+(b-a-1)/c*c;i>=a;i-=c)
template<class T>
istream& operator>>(istream& is,vector<T>& vec);
template<class T,size_t size>
istream& operator>>(istream& is,array<T,size>& vec);
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p);
template<class T>
ostream& operator<<(ostream& os,vector<T>& vec);
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p);
template<class T>
istream& operator>>(istream& is,vector<T>& vec){ for(T& x: vec) is>>x;return is; }
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p){ is>>p.first;is>>p.second;return is; }
//template<class T>
//ostream& operator<<(ostream& os,vector<T>& vec){ os<<vec[0];rep(i,1,vec.size())os<<' '<<vec[i];return os; }
//template<class T>
//ostream& operator<<(ostream& os,deque<T>& deq){ os<<deq[0];rep(i,1,deq.size())os<<' '<<deq[i];return os; }
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p){ os<<p.first<<" "<<p.second;return os; }

inline void in(){}
template <class Head,class... Tail>
inline void in(Head&& head,Tail&&... tail){ cin>>head;in(move(tail)...); }
template <class T>
inline bool out(T t){ cout<<t<<'\n';return 0; }
inline bool out(){ cout<<'\n';return 0; }
template <class Head,class... Tail>
inline bool out(Head head,Tail... tail){ cout<<head<<' ';out(move(tail)...);return 0; }

#define rep(...) _vcppunko4((__VA_ARGS__,_trep4,_trep3,_trep2,_rep1))((__VA_ARGS__))
#define rrep(...) _vcppunko4((__VA_ARGS__,_trrep4,_trrep3,_trrep2,_trrep1))((__VA_ARGS__))
#define lin(...) lint __VA_ARGS__;in(__VA_ARGS__)
#define stin(...) string __VA_ARGS__;in(__VA_ARGS__)
#define vin(type,name,size) vector<type> name(size);in(name)

int main(){
	char a;in(a);
	if(a=='A')cout<<"T\n";
	if(a=='T')cout<<"A\n";
	if(a=='C')cout<<"G\n";
	if(a=='G')cout<<"C\n";
}

//sub-EOF


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str, str2, p;
		int a, b;
		str2 = "";// ??????????¨????
		StringBuilder sb = new StringBuilder();
		StringBuilder sb2 = new StringBuilder();// ????????¨
		sb.append(scan.next());// ???????????????
		int x = scan.nextInt();// ???????????????
		char c;

		List<String> list = new ArrayList<String>();

		// ???????????????????????????
		for (int count = 0; count < x; count++) {
			// ????????????????????¶?????¨?????????
			switch (scan.next()) {
			case "print":// a~b?????????????????????
				a = scan.nextInt();
				b = scan.nextInt();
				str = new String(sb);
				sb2.append(str.substring(a, b + 1));// sb2?????\???
				sb2.append("\n");
				break;
			case "reverse":// a~b?????§??????????????????????????????
				a = scan.nextInt();
				b = scan.nextInt();
				// ????????????str?????????????????\??????
				str = new String(sb).substring(a, b+1);
				// ????????°??????????????????????????????????????\??????
				for (int count2 = 0; count2 < str.length(); count2++) {
					// ?????????????????????
					c = str.charAt(count2);
					// ????????????????´?(String)
					list.add(String.valueOf(c));
				}

				// ??????????????????
				for (int count3 = str.length(); count3 > 0; count3--) {
					str2 = str2 + list.get(count3 - 1);

				}

				// a~b???????????????????????????????????¨????????????
				sb.replace(a, b+1, str2);

				break;
			case "replace":// a~b?????§???????????????p???????????????
				a = scan.nextInt();// 1
				b = scan.nextInt();// 3
				p = scan.next();// ?????????????????????(xyz)

				// ????????????
				sb.replace(a, b + 1, p);// sb.replace(1, 3, "xyz");
				break;
			}
			str = "";// str?????????
			str2 = "";// str2?????????
			list.clear();
		}

		// ????????????????????????
		sb.deleteCharAt(sb.length() - 1);
		System.out.print(new String(sb2));

	}
}

Measured memory_bytes: 46704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 300;

int h, w, k;

int grid[MX][MX], ans[MX][MX];

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> h >> w >> k;
    vector<pair<int, int>> a;
    
    for (int i = 0; i < h; i++) {
		string s; cin >> s;
		for (int j = 0; j < w; j++) {
			grid[i][j] = (s[j] == '#');
			if (s[j] == '#') {
				a.push_back({i, j});
			}
		}
	}
	
	int group = 0;
	for (auto& i : a) {
		group++;
		ans[i.first][i.second] = group;
		for (int j = i.second - 1; j >= 0; --j) {
			if (!ans[i.first][j] && !grid[i.first][j]) ans[i.first][j] = group;
			else break;
		}
		for (int j = i.second + 1; j < w; j++) {
			if (!ans[i.first][j] && !grid[i.first][j]) ans[i.first][j] = group;
			else break;			
		}
	}
	
	for (int i = 1; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (!ans[i][j]) ans[i][j] = ans[i - 1][j];
		}
	} 
	
	for (int i = h - 2; i >= 0; --i) {
		for (int j = 0; j < w; j++) {
			if (!ans[i][j]) ans[i][j] = ans[i + 1][j];
		}
	}
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << ans[i][j] << " ";
		}
		cout << "\n";
	}
    return 0;
}


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

int main()
{
    ll n,ans=0,mx=0,x;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        if(x < mx)
            ans += (mx - x);

        mx = max(mx, x);
    }
    cout << ans << '\n';

    return 0;
}

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

int main() {

	ll n; cin >> n;
	const ll p = 100001;
	vector<ll> num(p, 0);
	for (ll i = 0; i < n; i++) {
		ll a;  cin >> a;
		num[a]++;
	}
	ll evenCnt = 0;
	ll oddCnt = 0;
	for (ll i = 1; i < p; i++) {
		if (0 < num[i]) {
			if (num[i] % 2 == 0) evenCnt++;
			else oddCnt++;
		}
	}
	ll ans = 0;
	ll quo= evenCnt / 2;
	ll mod = evenCnt % 2;	
	ans += quo * 2;
	if (mod == 1) {
		ans += 1;
		oddCnt -= 1;
	}
	ans += oddCnt;
	cout << ans << endl;
	return 0;
}

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

vector<int> primes;
ll mod = 1e9 + 7;

ll inv(ll a, ll b) {
	return 1 < a ? b - inv(b % a, a) * b / a : 1;
}

ll power(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
int main(){
    int n;
    scanf("%d", &n);
    int arr[n];
    for (int i = 0 ; i < n ; ++i)
        scanf("%d", &arr[i]);
    map<int,int> mp;
    for (int i = 0 ; i < n ; ++i){
        int x = arr[i];
        for (int k = 2 ; k <= sqrt(arr[i])+1 ; ++k){
            int t = 0;
            if (x%k==0){
                while (x%k==0){
                    x /= k;
                    ++t;
                }
                mp[k] = max(mp[k], t);
            }
        }
        if (x != 1)
            mp[x] = max(mp[x],1);
    }
    ll l = 1;
    for (auto &itr : mp){
        l *= power(itr.first, itr.second)%mod;
        l %= mod;
    }
    ll ans = 0;
    for (int i = 0 ; i < n ; ++i){
        ans += l*inv(arr[i], mod);
        ans %= mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		mms(ar,a)       memset(ar,a,sizeof(ar))
#define		ss              ' '
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
#define		OO              10000000000

int main(){
//    freopen("input.txt","r",stdin);
    ll a,b,c=0,i,j,t,k,lie,m,n,o,x,y,z,ar[200010];
    SS(n,m);
    cout<<(n*(n-1))/2+(m*(m-1))/2<<nn;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <climits>
#include <iomanip>
#include <queue>

using namespace std;

const int N = 2e5 + 9;
const int INF = 2e9 + 2;
const int mod = 1e9 + 7;
const int K = 25;
const int P = 51;
const long long LONG_INF = LONG_MAX;
const int SZ = (1 << 18) - 1;

#define eb emplace_back
#define sz(s) (int)(s.size())
#define mkp make_pair
#define all(s) s.begin(), s.end()

#define ll long long

#define int ll

int cnt[N];

void solve() {
	int n, a, b;
	cin >> n >> a >> b;
	for (int i = 1; i <= n - 1; ++ i)
		for (int j = i + 1; j <= n; ++ j)
			cnt[min(j - i, 1 + abs(b - j) + abs(a - i))]++;
	for (int i = 1; i <= n - 1; ++ i)
		cout << cnt[i] << '\n';
}


signed main() {
	ios_base::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
N,K = map(int, input().split())
A = list(map(int, input().split()))

# if K ==0:
#     keta = 0
# else:
#     keta = (len(bin(K)[2:]))
keta = (len(bin(K)[2:]))

num1s = [0] * keta
for a in A:
    for j in range(keta):
        if (1 << j) & a :
            num1s[j] = num1s[j] + 1

half = N/2
X = 0
if K != 0:
    for j in range(keta):
            X = X + ((num1s[j] < half)<<j)
answer = 0

def f (X):
    r = 0
    for a in A:
        r = r + (a^X)
    return r

maxfx = f(K)
for j in range(keta):
    if (1<<j)&K:
        
        x = (((1<<j) -1)&X ) 
        x = x | ((~((1<<(j+1))-1))&K)
        if f(x) > maxfx:
            maxfx = f(x)
            #print(x,maxfx,f(x)) 
print(maxfx)





Measured memory_bytes: 69264
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, m, a[200010];
int cnt[200010];
int cum[200010];
int ans;

signed main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++)cin >> a[i], cnt[a[i]]++;
	for (int i = 1; i <= n; i++) {
		if (i <= cnt[i])cum[1] += cnt[i] - i + 1;
		cum[max((int)2, i - cnt[i] + 1)]++;
		cum[i + 1]--;
	}
	for (int i = 3; i <= n; i++)cum[i] += cum[i - 1];
	for (int i = 1; i <= n; i++)if (cum[i])ans += cum[i] - 1;
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		int p = a[x];
		a[x] = y;
		int k = 0;
		if (1 < cum[max((int)1, p - cnt[p] + 1)])k++;
		else k--;
		cum[max((int)1, p - cnt[p] + 1)]--;
		cnt[p]--;
		cnt[y]++;
		if (cnt[y] == 1) {
			if (1 <= cum[y])k--;
			else k++;
			cum[y]++;
		}
		else {
			if (1 <= cum[max((int)1, y - cnt[y] + 1)])k--;
			else k++;
			cum[max((int)1, y - cnt[y] + 1)]++;
		}
		ans -= k / 2;
		cout << ans << endl;
	}
}


Measured memory_bytes: 6144
while True:
    #n,xの入力
    n,x = map(int,input().split())
    if n == 0 and x == 0:
        break
    count = 0
    #三重ループですべての組み合わせを試行
    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if i+j+k == x:
                    count+=1

    print(count)



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

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


int main() {
  ll a, b;
  cin >> a >> b;
  
  ll ans = a*b/ gcd(a, b);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
AB = sorted([[int(_) for _ in input().split()] for _ in range(N)])
count = 0
cost = 0
for a, b in AB:
    hon = min([M - count, b])
    cost += hon * a
    count += hon
    if count == M:
        break
print(cost)


Measured memory_bytes: 22380
N, K = map(int, input().split())
X = list(map(int, input().split()))

ans = float('inf')

for left in range(N - K + 1) :
    if X[left] < 0 and X[left + K - 1] >= 0 :
        l = -X[left] * 2 + X[left + K - 1]
        r = -X[left] + X[left + K - 1] * 2
        ans = min(ans, l, r)
    elif X[left + K - 1] < 0 :
        ans = min(ans, -X[left])
    else :
        ans = min(ans, X[left + K - 1])

print(ans)

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

int main (){
    int N, M = 0;
    cin >> N >> M;
    vector<int> L(M);
    vector<int> R(M);
    int Lmax = 0;
    int Rmin = 500100;
    int count = 0;
    for (int i = 0; i < M;i++)
    {
        cin >> L[i] >> R[i];
        if(Lmax < L[i]){
            Lmax = L[i];
        }
        if(Rmin > R[i]){
            Rmin = R[i];
        }
    }
    for (int i = Lmax; i <= Rmin;i++)
    {
        count++;
    }
    cout << count << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s, t;
    cin >> s >> t;

    set<char> unique_char;
    for(auto c : s){
        unique_char.insert(c);
    }
    bool isBad = false;
    for(auto c : t){
        if(unique_char.count(c)==0) isBad = true;
    }
    if(isBad){
        cout<<"-1"<<endl;
        return 0;
    }

    vector<vector<ll>> s_map(26, vector<ll>());
    for(int i=0; i<s.size(); i++){
        s_map[s[i] - 'a'].push_back(i);
    }
    ll res = 0;
    ll i_tmp = -1;
    for(int i=0;i<t.size(); i++){
        auto c = t[i] - 'a';
        auto itr = lower_bound(s_map[c].begin(), s_map[c].end(), i_tmp+1);
        if(itr == s_map[c].end()){
            res += s.size() - i_tmp - 1;
            i_tmp = -1;
            i--;
        }else{
            res += *itr - i_tmp;
            i_tmp = *itr;
        }
    }
    cout<<res<<endl;

    return 0;
}


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

const int MAXN = 1e5+10;
int four,two,non,n,num;

int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        cin >> num;
        if(num%4 == 0) ++four;
        else if(num%2 == 0) ++two;
        else ++non;
    }
    if(four >= n/2)
        cout << "Yes" << endl;
    else
    {
        int remain = non - four;
        if(remain <= 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<queue>
#include<bitset>
const int N=52,N2=N*N,N3=N*N2,dx[]={0,1,0,-1,0};	
char L[N][N],R[N][N];
struct S{int lx,ly,rx,ry;}s,t;
int F()
{
	std::bitset<N3*N>b;
	std::queue<S>q;
	q.push(s);
	char l,r,i;
	while(q.size())
	{
		s=q.front(),q.pop();
		if(b[s.ly*N3+s.lx*N2+s.ry*N+s.rx])continue;
		b[s.ly*N3+s.lx*N2+s.ry*N+s.rx]=1;
		l=L[s.ly][s.lx];
		r=R[s.ry][s.rx];
		if(l=='%'&&r=='%')return 1;
		if(l=='%'||r=='%')continue;
		for(i=0;i<4;++i)
		{
			t=s;
			if(L[t.ly+=dx[i+1]][t.lx+=dx[i]]=='#')t=s;
			if(R[t.ry+=dx[i+1]][t.rx-=dx[i]]=='#')t.rx=s.rx, t.ry=s.ry;
			q.push(t);
		}
	}
	return 0;
}
int main()
{
	int h,w,i;
	char*p;
	while(scanf("%d%d",&w,&h),w)
	{
		for(i=1;i<=h;++i)
		{
			scanf("%s%s",L[i]+1,R[i]+1);
			if(p=strchr(L[i]+1,'L'))s.lx=p-L[i],s.ly=i;
			if(p=strchr(R[i]+1,'R'))s.rx=p-R[i],s.ry=i;
		}
		for(i=0;i<h+2;++i)L[i][0]=L[i][w+1]=R[i][0]=R[i][w+1]='#';
		for(i=0;i<w+2;++i)L[0][i]=L[h+1][i]=R[0][i]=R[h+1][i]='#';
		puts(F()?"Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 5280
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

set<ll> S;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


void divisor(ll n, ll l) {
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
        if(l % i == 0){
            S.insert(i);
        }
        if(i * i != n){
            if(l % (n/i) == 0){
                S.insert(n / i);
            }
        }
    }
  }
  return;
}

bool IsPrime(ll num)
{
    if (num == 1) return true;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main()
{
    ll A,B;
    cin >> A >> B;

    divisor(A,B);

    ll Scount = 0;
    for(auto value : S){
        if(IsPrime(value)) Scount++;
    }

    vector<ll> vec;
    ll C = 0;
    C = gcd(A,B);
    vec = divisor(C);

    ll SScount = 0;
    for(auto value : vec){
        if(IsPrime(value)) SScount++;
    }


    //cout << Scount << endl;
    cout << SScount << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

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

int main(){
    int N,K,S;
    cin >> N >> K >> S;
    rep(i,K){
        cout << S << ' ';
    }
    int SS =1;// = S/2;
    int TT;
    if(S != 1000000000){
        SS = 1000000000;
    }else{
        SS = 999999999;
    } 
    /*
    if(S != 1){
        SS = 1;
    }else{
        SS = 2;
    }*/
    for(int i=K;i<N;i++){
        cout << SS << ' ';
    }
    cout<< endl;
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>

int selectionSort(int*,int);

int main()
{
  int N;
  int i;
  int arr[100];
  int kai;
  
  scanf("%d",&N);
  if(N < 1 || N > 100) exit(1);
  for(i = 0; i < N; i++)
    {
      scanf("%d",&arr[i]);
      if(arr[i] < 0 || arr[i] > 100) exit(1);
    }
  kai = selectionSort(arr,N);
  for(i = 0; i < N; i++)
    {
      if(i) printf(" ");
      printf("%d",arr[i]);  
    }
  printf("\n");
  printf("%d\n",kai);
  
  
  return 0; 
} 

int selectionSort(int* A,int N)
{
  int i;
  int j;
  int count=0;
  int minj;
  int temp;
  
  for (i = 0; i < N; i++)
    {
      minj = i;
      for(j = i; j < N; j++)
	{
	  if(A[j] < A[minj])
	    minj = j;
	}
      temp = A[i];
      A[i] = A[minj];
      A[minj] = temp;
      if(i != minj) count++;
    }
  return count;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int ap=0, bp=0;
  for(int i=0; i<N; i++){
    if(i%2==0)
      ap+=a.at(i);
    else
      bp+=a.at(i);
  }
  cout << ap-bp << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a = ['']*h
for i in range(h):
    a[i] = input()
    
row = [False] * h
col = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end = '')
        print()

Measured memory_bytes: 4468
#include<bits/stdc++.h>
			#include <sstream> 
			#include<bitset>
			#include<string>
			#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
			using namespace std;
			#include <numeric> 
			using pi=pair<long long,long long>;
			#define pii 3.1415926536
			#define binary
			#define mod 1000000007 
			typedef long long ll;
			typedef long double ld;
			bool sortbysec(const ll &a, const ll &b) 
			{ 
			    return (a > b); 
			}
			bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b)
			{
				
				if(a.second<b.second)
				return a.first<b.first;
			}
			int lcm(int a, int b)  
			 {  
			    return (a*b)/__gcd(a, b);  
			 } 
			 int Kad(ll dp[],ll n)
	{
	  ll curr_max=0,maxx=INT_MIN;
	  for(int i=0;i<n;i++)
	  {
	    curr_max=curr_max+dp[i];
	    if(curr_max>maxx)
	      maxx=curr_max;

	    if(curr_max<0)
	      curr_max=0;
	   
	  }

	  return maxx;
	}
	ll nextAlive(ll l,ll next[])
	{
		if(next[l]==l)
			return l;
		else
			return next[l]=nextAlive(next[l],next);

	}

int main()
			 {
			 	
     IOS;
     ll N;
     cin>>N;
     ll ans=(N/1000);
     if(N%1000==0)
     {
     	cout<<0<<endl;
     }
     else
     {
     	ans+=1;
     	cout<<(1000*ans-N)<<endl;
     }
     

 	
}
		


			 		
			 		
			 		
			 


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%lld",a);
long long  int a[1000000];
int main()
{
        memset(a,0,sizeof(a));
      long long int  n,curr_min_diff=INT_MAX,final_min_diff=INT_MAX,sum1=0,sum=0;
      sc(n);
      
      for(long long int i=0;i<n;i++)
         {
         sc(a[i]);
         sum+=a[i];
         }
         
        long long int rem;
        
        for(long long int i=0;i<n-1;i++)
          {
                rem=0;
                sum1+=a[i];
                rem=sum-sum1;
                curr_min_diff=abs(rem-sum1);
                //pf(curr_min_diff);
               // printf("\n");
                if(curr_min_diff < final_min_diff)
                    final_min_diff=curr_min_diff;
          
          }

        pf(final_min_diff);





return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>

int main(){

  int i=0,n, fibo[100];

  scanf("%d",&n);

  fibo[0] = fibo[1] = 1;

  if(n>=2){
    for(i=2;i<=n;i++){

      fibo[i] = fibo[i-1]+fibo[i-2];
    }
  }

  printf("%d\n",fibo[n]);

  return 0;
}

Measured memory_bytes: 596
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 100000, MAXI = 3, D = 1000;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 10000, flag = 1;
//     cout << tc << "\n";
//     int n = 1;
//     while (tc--)
//     {
//     	n = rand()%N + 1;

//     	cout << n << "\n~\n";

//     }
 
//     return 0;
// }
 
 
 
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 

//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long
#define mod (int)(1e9+7)
#define MAXI (int)(3e17+10)
#define N 3005

int dp[N][N][2], n, a[N];

int MEM(int i, int j, int last)
{
	if(i==j){
		if(last==0)
			return 0;

		return a[i];
	}

	int ans = dp[i][j][last];
	
	if(ans!=-1)
		return ans;

	if(last==1)
	{
		ans = -1*MAXI;
		ans = max(ans, a[i] + MEM(i+1, j, 0));
		ans = max(ans, a[j] + MEM(i, j-1, 0));
		dp[i][j][last] = ans;
	}
	else
	{
		ans = MAXI;
		ans = min(ans, MEM(i+1, j, 1));
		ans = min(ans, MEM(i, j-1, 1));
		dp[i][j][last] = ans;
	}

	return dp[i][j][last];
}

// Driver code to test above functions
int32_t main()
{
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int sum = 0;
    cin >> n;
    for(int i=0;i<n;i++){
    	cin >> a[i];
    	sum += a[i];
    }

    memset(dp, -1, sizeof dp);

    cout << 2*MEM(0, n-1, 1) - sum; 
    

    return 0;
 
} 

Measured memory_bytes: 141568
using System;

namespace JagArrayTest
{
    class Program
    {
        static void Main(string[] args)
        {
            for(int x = 1; x < 10; x++)
            {
                for(int y = 1; y < 10; y++)
                {
                    Console.WriteLine("{0}x{1}={2}", x.ToString(), y.ToString(), (x * y).ToString());
                }
            }
        }
    }
}



Measured memory_bytes: 17928
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
男のi人目以降と女の部分集合Sがマッチングする場合の数。
*/

ll n,mod=1e9+7,dp[21][2097152];
vector<ll> m[30];

ll f(ll i,ll s){
	if(i==n)return 1;
	if(dp[i][s]!=-1)return dp[i][s];
	ll sum=0;
	for(int p : m[i]){
		if((s>>p & 1)==0){//使われてなければ
			sum=(sum+f(i+1,s|(1<<p)))%mod;
		}
	}
	return dp[i][s]=sum;
}


int main(void){
	cin>>n;
	rep(i,n)rep(j,n){
		ll a;
		cin>>a;
		if(a==1){//仲良しに辺を結ぶ
			m[i].push_back(j);
		}
	}
	//
	rep(i,n)rep(j,1<<n)dp[i][j]=-1;
	//
	cout<<f(0,0)<<endl;
	return 0;
}

Measured memory_bytes: 344320
from collections import deque
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
blacklist = []
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            blacklist.append((h,w))
ans = 0
alr = [[0 for i in range(W)] for j in range(H)]
h1 = [0,0,1,-1]
w1 = [1,-1,0,0]
for h,w in blacklist:
    if alr[h][w] == 0:
        bcount = 1
        wcount = 0
        que = deque()
        que.append((h,w,True))
        alr[h][w] = 1
        while que:
            hn,wn,black = que.popleft()
            black = not black
            for i in range(4):
                if 0 <= hn+h1[i] <= H-1 and 0 <= wn+w1[i] <= W-1 and not alr[hn+h1[i]][wn+w1[i]]:
                    if (not black) and S[hn+h1[i]][wn+w1[i]] == '.':
                        wcount += 1
                        que.append((hn+h1[i],wn+w1[i],black))
                        alr[hn+h1[i]][wn+w1[i]] = 1
                    elif black and S[hn+h1[i]][wn+w1[i]] == '#':
                        bcount += 1
                        que.append((hn+h1[i],wn+w1[i],black))
                        alr[hn+h1[i]][wn+w1[i]] = 1
        ans += wcount*bcount
print(ans)
                        

Measured memory_bytes: 17168