akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
     
    #define endl '\n'
    #define fi first
    #define se second
    #define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
    #define forn(i,n) for (int i = 0; i < n; i++)
    #define forr(i,a,b) for (int i = a; i <= b; i++)
    #define all(v) v.begin(), v.end()
    #define pb(x) push_back(x)
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<int, int> ii;
    typedef vector<ll> vi;
    typedef vector<vi> vvi;
    typedef vector<ii> vii;
     
    int s, w;
     
    int main () {
    	ios_base::sync_with_stdio(0); cin.tie(0);
    	
    	cin >> s >> w;
    	if (w >= s) cout << "unsafe" << endl;
    	else cout << "safe" << endl;
     
    	return 0;
    }

Measured memory_bytes: 3588
#include<stdio.h>

#define MAX 100005
#define NIL -1

typedef struct node{int p,l,r;}Node;
Node T[MAX];
int D[MAX];

void print(int u )
{
    int i,c;
    printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]);
    if(T[u].p==NIL)printf("root, ");
    else if(T[u].l==NIL)printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    for(i=0,c=T[u].l;c!=NIL;c=T[c].r,i++)
    {
        if(i)printf(", ");
        printf("%d",c);
    }
    printf("]\n");
}

void rec(int u,int p)
{
    D[u]=p;
    if(T[u].l != NIL)rec(T[u].l,p+1);
    if(T[u].r != NIL)rec(T[u].r,p);
}

int main()
{
    int n,l,root;
    scanf("%d",&n);
    for(int i=0;i<n;i++)T[i].p=T[i].l=T[i].r=NIL;

    for(int i=0;i<n;i++)
    {
        int v,d;
        scanf("%d%d",&v,&d);
        for(int j=0;j<d;j++)
        {
            int c;
            scanf("%d",&c);
            if(j==0)T[v].l=c;
            else T[l].r=c;
            l=c;
            T[c].p=v;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(T[i].p==NIL)root=i;
    }
    rec(root,0);
    for(int i=0;i<n;i++)print(i);
}



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

int main()
{
    int n;
    std::cin >> n;

    std::vector<std::uint64_t> as(n);
    std::vector<std::uint64_t> asum(n);

    for (std::uint64_t i = 0; i < n; i++)
    {
        std::cin >> as[i];
        if (i == 0)
        {
            asum[i] = as[i];
        }
        else
        {
            asum[i] = asum[i - 1] + as[i];
        }
    }

    constexpr std::uint64_t MOD = 1000000007;

    std::uint64_t ans = 0;
    for (std::uint64_t i = 0; i < as.size() - 1; ++i)
    {
        auto mul = (*asum.rbegin() - asum[i]) % MOD;
        ans += (as[i] * mul) % MOD;
        ans %= MOD;
    }

    std::cout << ans;
    return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

#define rep(i, N) for(int i = 0; i < N; ++i)

using namespace std;
struct card {char suit; int value;};
int N;
const int SENTINEL = 1LL << 29;
const int MAX = 100100;
card A[MAX];
card B[MAX];
struct card L[MAX/2 + 2], R[MAX/2 + 2];

int partition(int p, int r) {
    int x = A[r].value;
    int i = p-1;
    for(int j = p; j < r; ++j) {
        if (A[j].value <= x) {
            ++i;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[r]);
   return i+1;
}

void quickSort(int p, int r) {
    if (p < r) {
        int q = partition(p, r);
        quickSort(p, q-1);
        quickSort(q+1, r);
    }
}

void merge(int n, int left, int mid, int right) {
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;
    rep(i, n1) L[i] = B[left + i];
    rep(i, n2) R[i] = B[mid + i];
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for(k = left; k < right; ++k) {
        if (L[i].value <= R[j].value) B[k] = L[i++];
        else B[k] = R[j++];
    }
}

void mergeSort(int n, int left, int right) {
    int mid;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        mergeSort(n, left, mid);
        mergeSort(n, mid, right);
        merge(n, left, mid, right);
    }
}

int main() {
    cin >> N;
    rep(i, N) {
        char s; cin >> s;
        int v; cin >> v;
        A[i].suit = B[i].suit = s; 
        A[i].value = B[i].value = v;
    }
    mergeSort(N, 0, N);
    quickSort(0, N-1);
    string isStable = "Stable";
    rep(i, N) if(A[i].suit != B[i].suit) isStable = "Not stable";
    cout << isStable << endl;
    rep(i, N) cout << A[i].suit << " " << A[i].value << endl;


}



Measured memory_bytes: 5456
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=[0]*n
a[0]=p[0]
for i in range(n-1):
  a[i+1]=a[i]+p[i+1]
m=a[k-1]
for j in range(n-k):
  if a[j+k]-a[j]>m:
    m=a[j+k]-a[j]
print((m+k)/2)
    


Measured memory_bytes: 71792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			int m = sc.nextInt();
			
			int map[][] = new int[n][n];
			
			
			for(int i = 0; i < m ; i++){
				int x = sc.nextInt()-1;
				int y = sc.nextInt()-1;
				map[x][y] = 1;
				map[y][x] = -1;
			}
			
			System.out.println(dfs(map,0,1,0));
		}
	}
	
	int dfs(int map[][],int x,int y,int count){
		if(x >= map.length){
			return 1;
		}
		if(y >= map[x].length){
			int ss = 0;
			for(int s :map[x]){
				ss += s;
			}
			if(ss == 0){
				return dfs(map,x+1,x+2,count);
			}else{
				return 0;
			}
		}
		if(map[x][y] != 0){
			return dfs(map,x,y+1,count);
		}
		
		int res = 0;
		map[x][y] = 1;
		map[y][x] = -1;
		res += dfs(map,x,y+1,count);
		map[x][y] = -1;
		map[y][x] = 1;
		res += dfs(map,x,y+1,count);
		map[x][y] = 0;
		map[y][x] = 0;
		return res;
	}
}



Measured memory_bytes: 31636
S = input()

cs = {0: 1}

result = 0

n = 0
for i in range(len(S)):
    c = int(S[-i-1])
    n += c * pow(10, i, 2019)
    m = n % 2019
    if m in cs:
        result += cs[m]
        cs[m] += 1
    else:
        cs[m] = 1

print(result)

Measured memory_bytes: 9132
#include <stdio.h>

int main() {
  int A, B;
  scanf("%d %d", &A, &B);
  int ADD = A+B;
  int SUB = A-B;
  int MLT = A*B;
  
  if (MLT >= ADD) {
    if (ADD >= SUB)
    	printf("%d", MLT);
  	else if (MLT >= SUB)
        printf("%d", MLT);
    else
        printf("%d", SUB);
  } else if (ADD >= SUB) {
    if (SUB >= MLT)
    	printf("%d", ADD);
  	else if (ADD >= MLT)
        printf("%d", ADD);
    else
        printf("%d", MLT);
  } else if (SUB >= MLT) {
    if (MLT >= ADD)
    	printf("%d", SUB);
  	else if (SUB >= ADD)
        printf("%d", SUB);
    else
        printf("%d", ADD);
  }
  
  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader br = new BufferedReader(new FileReader("in1.txt"));
		// BufferedReader br = new BufferedReader(new FileReader("in2.txt"));
		int n = Integer.parseInt(br.readLine());
		List<Integer> S = new ArrayList<Integer>();
		String[] line_S = br.readLine().split(" ");
		for (String str : line_S)
			S.add(Integer.parseInt(str));
		int q = Integer.parseInt(br.readLine());
		List<Integer> T = new ArrayList<Integer>();
		String[] line_T = br.readLine().split(" ");
		for (String str : line_T)
			T.add(Integer.parseInt(str));
		
		int C = 0;
		Collections.sort(S);
		for (int t : T)
			if (Collections.binarySearch(S, t) >= 0)
				C++;
		
		System.out.println(C);
	}
}

Measured memory_bytes: 29056
//問題: https://atcoder.jp/contests/abc088/tasks/abc088_b

//Aliceは残ったカードの中で一番数字の大きいカードを取り続ける
#include<bits/stdc++.h>
using namespace std;

vector <int> card; //カード
int N; //カードの枚数

int main(){
    int as=0,sum=0; //asはAliceのスコア、sumは合計スコア
    int cnt=0;
    cin >> N;
    card.resize(N);
    for(auto v : card){
        cin >> v;
        card[cnt]=v;
        cnt++;
        sum+=v;
    }
    sort(card.begin(),card.end()); //カードを昇順にソート
    for(int i=N-1; 0<=i; i-=2){
        as+=card[i];
    }
    cout << as*2-sum << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int c;
  c = 0;
  int OOTJNY;
  int KYR;
  OOTJNY = 1;
  KYR = 1;
  int YABAI;
  while(c < a){
    KYR *= 2;
    YABAI = KYR - OOTJNY;
    if(YABAI > b){
      KYR /= 2;
      KYR += b;
      OOTJNY += b;
    }
    else{
      OOTJNY *= 2;
    }
    c++;
  }
  cout << OOTJNY << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int mo = 1e9 + 7;

const int N = 1e4 + 5;

ll g[N];
int n, x, y;
int fi[N], nt[N], to[N], tot;

void link(int x, int y) {
	nt[++ tot] = fi[x], to[tot] = y, fi[x] = tot;
}

int fa[N], siz[N];

ll f[N][N];
void dg(int x) {
	siz[x] ++;
	f[x][1] = 1;
	for(int i = fi[x]; i; i = nt[i]) {
		int y = to[i]; if(fa[x] == y) continue;
		fa[y] = x; dg(y);
		fd(j, siz[x], 0) {
			fo(k, 1, siz[y]) {
				f[x][j + k] = (f[x][j + k] + f[x][j] * f[y][k]) % mo;
			}
			f[x][j] = f[x][j] * f[y][0] % mo;
		}
		siz[x] += siz[y];
	}
	fo(j, 1, siz[x]) if(j % 2 == 0)
		f[x][0] = (f[x][0] - f[x][j] * g[j]) % mo;
}

int main() {
	g[0] = g[2] = 1;
	for(int i = 4; i <= 5000; i += 2)
		g[i] = (g[i - 2] + ((ll) (i - 2) * (i - 3) % mo) * g[i - 4]) % mo;
	scanf("%d", &n);
	fo(i, 1, n - 1) {
		scanf("%d %d", &x, &y);
		link(x, y); link(y, x);
	}
	dg(1);
	pp("%lld\n", (-f[1][0] + mo) % mo);
}


Measured memory_bytes: 390400
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
    int l,r;
    cin >>l >>r;

    long long mini = 9999;
    int ct1 = 0;

    for(long long i = l; i <= r && ct1 < 2020; i++){
        ct1++;
        int ct2 = 0;
        for(long long j = i+1; j <= r && ct2 < 2020; j++){
            ct2++;
            mini = min(mini, (i*j) % 2019);
        }
    }

    printf("%lld\n", mini);
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
  while(1)
    {
  char buf[127][2];
  char str[128];
  buf['A']['0']='X';
  buf['A']['1']='Y';
  buf['X']['1']='Z';
  //buf['X']['0']='n';
  buf['Y']['0']='X';
  //buf['Y']['1']='n';
  buf['Z']['0']='W';
  buf['Z']['1']='B';
  buf['W']['0']='B';
  buf['W']['1']='Y';
  buf['B']['0']='Y';
  buf['B']['1']='X';
  scanf("%s",str);
  if(str[0]=='#')break;
  int ans=strlen(str);
  
  char now='A';
  for(int i=0;i<ans;i++)
    {
      
      now=buf[now][str[i]];
      //if(now=='n')break;

    }
  if(now=='B')printf("Yes\n");
  else printf("No\n");
    }
  return 0;
}

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

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

    static class A_Triangle {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            final long M = (long) 1e9;
            long s = in.nextLong();
            long x0 = 0;
            long y0 = 0;
            long x1 = s / M;
            long y1 = s % M;
            long x2 = -1;
            long y2 = M;
            if (x1 == M) {
                x1 = M;
                y1 = 0;
                x2 = 0;
                y2 = M;
            } else {
                ++x0;
                ++x1;
                ++x2;
            }
            out.printf("%d %d %d %d %d %d\n", x0, y0, x1, y1, x2, y2);
        }

    }

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

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

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

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

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
//
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> v;
    rep(i,n){
       int a;
       cin>>a;
       v.push_back(a);
    }
    sort(all(v));
    int ans=0;
    rep(i,k){
       ans += v[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>

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

using ll = long long;
using namespace std;

constexpr int INF = 2147483647; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i += 2) cout << s[i];
	cout << "\n";
	return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define INF 900000000

using namespace std;

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



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

// recursive approach
long long knapsack(vector<pair<int, long long>> &wv, int w, int i){
    if(w < 0)
        return LONG_LONG_MIN;
    if(w == 0 or i < 0){
        return 0;
    }

    return max(knapsack(wv, w - wv[i].first, i-1) + wv[i].second,
                knapsack(wv, w, i-1));
}

// dynamic programming approach
long long knapsack(vector<pair<int, long long>> &wv, int w){
    vector<vector<long long>> dp(wv.size() + 1, vector<long long>(w + 1, 0));

    for(int i = 0;i <= wv.size();i++){
        for(int wt = 0;wt <= w;wt++){
            if(i == 0 || wt == 0)
                dp[i][wt] = 0;
            else if(wv[i-1].first <= wt){
                dp[i][wt] = max(wv[i-1].second + dp[i-1][wt - wv[i-1].first], dp[i-1][wt]);
            }else{
                dp[i][wt] = dp[i-1][wt];
            }
        }
    }

    return dp[wv.size()][w];
}

int main(){
    int n, w;
    cin >> n >> w;
    vector<pair<int, long long>> wv(n);

    for(int i = 0;i < n;i++){
        cin >> wv[i].first >> wv[i].second;
    }

    cout << knapsack(wv, w) << endl;

    return 0;
}

Measured memory_bytes: 80256
import java.util.Scanner;
import java.util.HashMap;
import java.util.Arrays;
class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		double all[] = new double[24];
		HashMap<Double, Integer> allmap = new HashMap<Double, Integer>();
		for (int i = 0; i < 3; i++)
		{
			double group[] = new double[8];
			HashMap<Double, Integer> groupmap = new HashMap<Double, Integer>();
			for (int j = 0; j < 8; j++)
			{
				int num = sc.nextInt();
				double time = sc.nextDouble();
				group[j] = time;
				all[j + i * 8] = time;
				groupmap.put(time, num);
				allmap.put(time, num);
			}
			Arrays.sort(group);
			double time = group[0];
			System.out.printf("%d %.2f\n", groupmap.get(time), time);
			allmap.remove(time);
			time = group[1];
			System.out.printf("%d %.2f\n", groupmap.get(time), time);
			allmap.remove(time);
		}
		Arrays.sort(all);
		int index = 0;
		for (int i = 0; i < 2;index++)
		{
			Integer num = allmap.get(all[index]);
			if (num == null)
			{
				continue;
			}
			else
			{
				i++;
				System.out.printf("%d %.2f\n", num, all[index]);
			}
		}
	}
}

Measured memory_bytes: 12000
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N=cin.ReadInt;
            var F = new int[N][];
            for(int i=0;i<N;i++){
                F[i]= cin.ReadIntArray(10);
            }
            var P = new int[N][];
            for(int i = 0;i<N;i++){
                P[i] = cin.ReadIntArray(11);
            }

            var Result = new List<long>();
            for(int i =1;i<1024;i++){
                int[] TEN = new int[10].Select((value,index)=> i>>index & 1).ToArray();
                Result.Add(Rieki(N,TEN,F,P));
            }
            WriteLine(Result.Max());
        }

        public long Rieki(int N,int[] open, int[][] F,int[][] P){
            long R = 0;
            for(int j=0;j<N;j++){
                int jufuku = F[j].Select((v,index) => v*open[index]).Sum();
                R += P[j][jufuku];
            }
            return R;
        }


    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator =' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 17724
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	int w, h; cin >> w >> h;
	int hony = w + 1, honx = h + 1;
	vector<pair<ll, int> > c;
	REP(i, w){
		cin >> tmp;
		c.push_back(make_pair(tmp, 0));
	}
	REP(i, h){
		cin >> tmp;
		c.push_back(make_pair(tmp, 1));
	}
	sort(c.begin(), c.end());
	REP(i, w+h){
		if(c[i].second == 0){
			ans += c[i].first * honx;
			//cout << c[i].first << " " << honx << endl;
			hony--;
		}
		else{
			ans += c[i].first * hony;
			//cout << c[i].first << " " << hony << endl;
			honx--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 7472
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=200005;

int main()
{
    IO;
    int x;
    cin >> x;
    int Max=1;
    for(int i=2;i<=x;++i){
        int tmp=i;
        while(true){
            tmp*=i;
            if(tmp>x)break;
            Max=max(Max,tmp);
        }
    }
    cout<<Max<<endl;
    re 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int h,w;
    cin>>h>>w;
    char a[h][w];
    int cnt=0;
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
            if(a[i][j]=='#') cnt++;
        }
    }
    if(cnt==h+w-1) cout<<"Possible";
    else cout<<"Impossible";
}

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

void insert(int _value);
void delete(int _value);
void deleteFirst(void);
void deleteLast(void);

struct Node{

  struct Node* next;
  struct Node* prev;
  int value;

};

struct Node* head;
struct Node* tail;
main(){

  int i;
  int n;
  int tmpValue;
  char str[20];
  struct Node* node;

  head = (struct Node*)malloc(sizeof(struct Node));
  tail = (struct Node*)malloc(sizeof(struct Node));
  head->next = tail;
  head->prev = NULL;
  tail->next=NULL;
  tail->prev=head;
  head->value = 0;
  tail->value=0;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%s",str);
    if(!strcmp(str,"insert")){
      scanf("%d",&tmpValue);
      insert(tmpValue);
    }else if(!strcmp(str,"deleteFirst")){
      deleteFirst();
    }else if(!strcmp(str,"deleteLast")){
      deleteLast();
    }else if(!strcmp(str,"delete")){
      scanf("%d",&tmpValue);
      delete(tmpValue);
    }
  }

  for(node=head->next; node != tail; node=node->next){
    printf("%d",node->value);
    if(node->next!=tail){
      printf(" ");
    }
  }
  printf("\n");

  return 0;

}

void insert(int _value){

  struct Node* newNode;
  struct Node* tmpNode;

  newNode = (struct Node*)malloc(sizeof(struct Node));

  tmpNode = head->next;
  if(tmpNode != NULL){
    tmpNode->prev = newNode;
  }
  head->next = newNode;
  newNode->next = tmpNode;
  newNode->prev = head;

  newNode->value = _value;

}

void delete(int _value){

  struct Node* node;
  struct Node* tmpNode;
  for(node=head->next; node != NULL; node=node->next){
    if(node->value == _value){
      tmpNode = node->prev;
      if(tmpNode != NULL){
	tmpNode->next = node->next;
      }
      if(node->next != NULL){
	node->next->prev = tmpNode;
      }
free(node);
      break;
    }
  }

}

void deleteFirst(){

  struct Node* node;
  node=head->next;

  if(head != NULL){
    head->next= node->next;
  }
  if(node->next != NULL){
    node->next->prev = head;
  }
  free(node);

}

void deleteLast(){

  struct Node* tmpNode;

  tmpNode=tail->prev;
  tail->prev=tmpNode->prev;
  tmpNode->prev->next=tail;

  free(tmpNode);

}

Measured memory_bytes: 15000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int first = sc.nextInt();
		int sum = 0;
		//ユークリッドの互除法
		for(int a =1; a<=first ; a++) { //(a,b,c)のAが増える
			for(int b = 1; b<=first; b++) { //(a,b,c)のBが増える
				for(int c = 1; c<=first; c++) { //(a,b,c)のCが増える
					sum += gcd(gcd(a,b),c);
				}
			}
		}
		System.out.println(sum);
	}

	private static int gcd(int a, int b) {
		if(b==0) {
			return a;
		}
		a = a%b;
		//割られた数に余りを入れる。a=390 ,b=273の場合
		//a=117(あまりの数),b=273   割られた側が上書きされるイメージ
		return gcd(b,a); //ここで反転して余りがなくなるまで繰り返す。

	}

}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}


inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}

int main()
{
    ///freopen("output.txt","w",stdout);
   //freopen("input.txt","r",stdin);
    FastIO;

    int n;
    while(cin>>n){

        int a[n+1];
        vector<int>dp(n+5,0);

        for(int i=1; i<=n; i++){
            cin>>a[i];
            dp[a[i]] = dp[a[i]-1] + 1;
        }
        int mx = 0;
        for(int i=1; i<=n; i++){
            mx = max(dp[i],mx);
        }
        cout<<(n-mx)<<endl;
    }

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
typedef long long ll;
#define lp(i,n) for(ll i = 0;i < ll(n);i++)
#define rlp(i,n) for(ll i = ll(n);i >= 0;i--)
#define rg(i,a,b) for(ll i = ll(a);i <= ll(b);i++)
#define wh(t) while(t)
#define re return
#define pb push_back
#define sz(s) (ll)(s.size())
#define NeverGiveUp ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
/*freopen("input.txt","r", stdin);
	freopen("output.txt","w", stdout);*/
using namespace std;
/*ll mx = INT_MIN;
ll mn = INT_MAX;*/
/*ll xd,dx[4]={1,0,-1,0};
ll yd,dy[4]={0,1,0,-1};
bool valid(ll xd,ll yd,ll n,ll m){return xd>-1&&xd<n&&yd>-1&&yd<m;}*/
const int sz = 2e5+5;
const ll md = 1e9+7;
ll n,a[sz],b[sz],ans;
int main()
{
    NeverGiveUp
    cin>>n;
    lp(i,n+1)cin>>a[i];
    lp(i,n)cin>>b[i];
    lp(i,n){
        if(a[i]>=b[i]){
            ans+=b[i];
        }if(a[i]<b[i]){
            ans+=a[i];
            b[i]-=a[i];
            ans+=min(b[i],a[i+1]);
            a[i+1]-=min(b[i],a[i+1]);
        }
    }
    cout<<ans<<'\n';
    re 0;
}


Measured memory_bytes: 5156
from itertools import product

H, W, K = map(int, input().split())
table = []
for i in range(H):
    table.append(input())
ans = 0
for is_red_h in product([False, True], repeat=H):
    for is_red_w in product([False, True], repeat=W):
        black = 0
        for i in range(H):
            if is_red_h[i]:
                continue
            for j in range(W):
                if is_red_w[j]:
                    continue
                if table[i][j] == "#":
                    black += 1
        if black == K:
            ans += 1
print(ans)


Measured memory_bytes: 74236
import math
a,b,x = list(map(int, input().split()))
volume = a*a*b
if 2 * x <= volume:
    print(90 - math.degrees(math.atan(2*(x/b/a)/b)))
else:
    print(math.degrees(math.atan(2*(volume-x)/a/a/a)))


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main() {
	int n;
	while (cin >> n, n) {
		cin.ignore();
		
		map<string, int> m;
		REP(i, n) {
			string str; getline(cin, str);
			stringstream ss(str);
			while (ss >> str) m[str]++;
		}
		
		vector<pair<int, string> > v[26];
		for (map<string, int>::iterator it = m.begin(); it != m.end(); ++it)
			v[it->fi[0] - 'a'].push_back(make_pair(-it->se, it->fi));
		
		string K; cin >> K;
		int k = K[0] - 'a';
		
		sort(ALL(v[k]));
		
		vector<string> ans;
		REP(i, min<int>(5, v[k].size())) ans.push_back(v[k][i].se);
		
		if (ans.empty()) puts("NA");
		else REP(i, ans.size()) cout << ans[i] << (i == ans.size() - 1 ? '\n' : ' ');
				
	}
	return 0;
}

Measured memory_bytes: 3236
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

N = getInput()[0];
a_i = getInput()
a_i.sort(reverse=True)
ret = 0

for i in range(1, N+1):
    if not i % 2 == 0:
        ret += a_i.pop(0)
    else:
        ret -= a_i.pop(0)
print(ret)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x)             cout <<#x<<": "<<x<<endl;
#define debug2(x, y)         cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define debug3(x, y, z)      cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define debug4(a, b, c, d)   cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
template <typename T>  using orderedSet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // order_of_key find_by_order
const int MAX=1e7+1;
int f[MAX];

void pre(){
    for(int i=1;i<MAX;i++){
        for(int j=i;j<MAX;j+=i){
            f[j]++;
        }
    }
}
int main() {
    FAST
    ll n;
    cin>>n;
    ll ans=0;
    pre();
    for(ll i=1;i<=n;i++) ans+=(i*f[i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 42716
/*  
     author : masaow    
     g++ : 17.3.20  
*/        
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x) 			   cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set; 
const int N = 1e5+7;  
/*  
    time : 12 : 14    
    date : 19.01.2020
*/    
// int L,R,mid,target,idx ;
const int INF = 1e9 + 7 ;
int dp[N][3];   
int a[N][3] ;
int n; 
int solve(int state,int used ) {
	if( state == n )
		return 0 ; 
	if(dp[state][used] != INF )
		return dp[state][used] ;   
	int j ; 
	int result = -1 ; 	
	forn(j,0,3)
	if(j != used )	
		result = max(a[state][used]+solve(state+1,j),result) ; 
	return (dp[state][used] = result) ; 		
} 
int tests() 
{	
	int i,j ; 
	scanf("%d",&n) ;
	forn(i,0,n)
		forn(j,0,3)
			scanf("%d",&(a[i][j])) ; 
	forn(i,0,n)
		forn(j,0,3)
			dp[i][j] = INF ;  
	cout << max({solve(0,0),solve(0,1),solve(0,2)}) << '\n' ;
	return 0 ; 
}
int32_t main(){
    I__O ;   
    int cases = 1 ; 
 	// cin >> cases;  
    while(cases--)
	    tests(); 
	return 0 ; 
}

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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);

   int n, a, b, cnt = -LINF, ans = 0;
   cin >> n;
   vector<int> x, y;
   vector<pair<int, int>> xy(n);

   rep(i, n)
   {
      cin >> a >> b;
      x.push_back(a);
      y.push_back(b);
   }

   rep(i, n)
   {
      xy[i] = make_pair((x[i] + y[i]), (x[i] - y[i]));
   }

   sort(all(xy));

   rep(i, n)
   {
      if (cnt <= xy[i].second)
      {
         ++ans;
         cnt = xy[i].first;
      }
   }

   cout << ans << '\n';
}

Measured memory_bytes: 3572
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long int
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a==2||b==2)
    printf("No");
    else
    printf("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+100;
int n,a[N],mx,le;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+n+1); reverse(a+1,a+n+1);
	mx=-1;
	for(int i=1;i<=n;++i) 
		if(a[i]<i) { mx=i-2; break; }
	if(!(~mx)) mx=n-1;
	for(int i=n;i>=1;--i)
		if(a[i]>mx) { le=i; break; }
	bool ans=((a[mx+1]-mx)&1)&((le-mx)&1);
	if(ans) puts("Second");
	else puts("First");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
#include <algorithm>
#define ll  long long int
//#define mod 1000000007
using namespace std;
int main() 
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a!=c)
		printf("1");
	else printf("0");
	

	
}

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




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

bool ope(const pair<int,int>&left, const pair<int,int>&right){
	return left.second < right.second;
}

int main(){
	int n,c1,m1,s1,m2,s2,m3,s3,m4,s4;
	vector<pair<int,int> > v;
	while(cin >> n,n){
		v.clear();
		for(int i = 0;i < n;i++) {
			cin >> c1 >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
			v.push_back(make_pair(c1,m1 * 60 + s1 + m2 * 60 + s2 + m3 * 60 + s3 + m4 * 60 + s4));
		}
		sort(v.begin(),v.end(),ope);
		cout << v[0].first << endl << v[1].first << endl << v[v.size() - 2].first << endl;
	}
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1<<(n))
#define popcount(n) (__builtin_popcountll(n))


using namespace std;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int inf=1<<28;
int h,w;


int board[10];
int len[15][15];

int min_res=0;
int dfs(int y,int x,int d,int remain){
	if(d+(remain?1:0)>min_res) return inf;

	if(y==h){		
		if(min_res>d) min_res=d;
		return d;
	}

	if(x>=w) return dfs(y+1,0,d,remain);
	
	if(len[y][x]==0) return dfs(y,x+1,d,remain);

	int ret=inf;
	if((board[y]&bit(x))==0){
		int cur=dfs(y,x+1,d,remain);
		if(ret>cur) ret=cur;
	}

	int tboard[10],l=len[y][x];
	rep(i,y,y+l) tboard[i]=board[i];

	int nremain=remain;
	int mask=((1<<l)-1)<<x;
	rep(a,y,y+l){
		nremain-=popcount(board[a]&mask);
		board[a]&=(1023^mask);
	}

	if(remain!=nremain){
		int cur=dfs(y,x+1,d+1,nremain);
		if(ret>cur) ret=cur;
	}
	
	rep(i,y,y+l) board[i]=tboard[i];
	return ret;
}

int main(void){
	while(1){
		scanf("%d %d",&w,&h);
		if(w==0) break;

		rep(i,h){
			board[i]=0;
			rep(j,w){
				int tmp;
				scanf("%d ",&tmp);
				board[i]|=(tmp<<j);
			}
		}

		rep(i,h)rep(j,w){
			len[i][j]=0;
			if((board[i]&bit(j))==0) continue;
			len[i][j]=min(h-i,w-j);
			const int l=len[i][j];
			rep(a,i,i+l)rep(b,j,j+l) if((board[a]&bit(b))==0) len[i][j]=min(len[i][j],max(a-i,b-j));
		}

		int num[10][10],sy[10][10],sx[10][10];
		rep(i,h)rep(j,w) num[i][j]=0;
		rep(i,h)rep(j,w){
			const int l=len[i][j];
			rep(a,i,i+l)rep(b,j,j+l) num[a][b]++,sy[a][b]=i,sx[a][b]=j;
		}

		int add=0;
		rep(i,h)rep(j,w){
			if(num[i][j]!=1) continue;
			const int cy=sy[i][j],cx=sx[i][j],l=len[cy][cx],mask=((1<<l)-1)<<cx;
			rep(a,cy,cy+l) board[a]&=(1023^mask);
			len[cy][cx]=0,add++;
		}

		int remain=0;
		rep(i,h) remain+=popcount(board[i]);
		min_res=min(20,remain);
		int ans=dfs(0,0,0,remain);
		if(ans==inf) ans=21;		
		printf("%d\n",ans+add);
	}
	return 0;
}

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

char b[3][3];

bool check(char c) {
	for (int i = 0; i < 3; i++) {
		if (b[i][0] == c && b[i][1] == c && b[i][2] == c) return true;
		if (b[0][i] == c && b[1][i] == c && b[2][i] == c) return true;
	}
	if (b[0][0] == c && b[1][1] == c && b[2][2] == c) return true;
	if (b[0][2] == c && b[1][1] == c && b[2][0] == c) return true;
	return false;
}

int main() {
	while (true) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				cin >> b[i][j];
				if (b[i][j] == '0') return 0;
			}
		}

		if (check('b')) {
			cout << 'b' << endl;
		}
		else if (check('w')) {
			cout << 'w' << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 1136
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string S, T, a;

    cin >> S >> T;

    a = T.substr(0, T.size()-1);

    if(S==a) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
a = list(input())
b = list(input())
c = list(input())
p = a.pop()
while 1:
    if p=='a':
        if len(a)==0:
            print('A')
            exit()
        p = a.pop(0)
    elif p=='b':
        if len(b)==0:
            print('B')
            exit()
        p = b.pop(0)
    else:
        if len(c)==0:
            print('C')
            exit()
        p = c.pop(0)

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  cout << N - (i - 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

class BIT   // 1-indexed (0 is not used)
{
private:
    long num;
    vector<long> bit;
public:
    BIT(long n):bit(vector<long>(n+1, 0)), num(n) {}

    long sum(long i) {   // sum of 1..i
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(long i, int x) {
        if (i > num) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

ll InvNum( long n, long double* a )
{
    map<long double,long> mp;
    long i;
    for(i=0; i<n; i++) {
        mp[a[i]]=0;
    }
    long num=0;
    auto it=mp.begin();
    for(; it!=mp.end(); ++it) {
        num++;
        it->second=num;
    }

    ll ans=0;
    BIT bit(num);
    for(i=0; i<n; i++) {
        ans += i - bit.sum(mp[a[i]]);
        bit.add(mp[a[i]], 1);
    }
    return ans;
}

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> a(n), b(n), c(n);
    vector<pair<double, long> > z(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld%ld%ld", &a[i], &b[i], &c[i]);
    }

    // solve for x
    for(i=0; i<n; i++) {
        z[i] = make_pair((double)(-a[i])/b[i], i);
    }
    sort(z.begin(), z.end());

    {
        long double l = -INF;
        long double r = INF;
        vector<long double> y(n);
        const double eps = 1.0e-10;
        while(r-l>eps) {
            long double m = (l+r)/2;
            for(i=0; i<n; i++) {
                y[i] = (((long double)c[z[i].second] - a[z[i].second]*m) / b[z[i].second]);
            }
            ll ans = InvNum( n, &(y[0]) );
            //printf("%lf, %lld\n", m, ans);
            if( ans <= (double)n*(n-1)/4 ) {
                r = m;
            }
            else {
                l = m;
            }
        }
        printf("%.12Lf ", r);
    }
    
    // solve for y
    for(i=0; i<n; i++) {
        z[i] = make_pair((double)(-b[i])/a[i], i);
    }
    sort(z.begin(), z.end());

    {
        long double l = -INF;
        long double r = INF;
        vector<long double> x(n);
        const double eps = 1.0e-10;
        while(r-l>eps) {
            long double m = (l+r)/2;
            for(i=0; i<n; i++) {
                x[i] = (((long double)c[z[i].second] - b[z[i].second]*m) / a[z[i].second]);
            }
            ll ans = InvNum( n, &(x[0]) );
            //printf("%lf, %lld\n", m, ans);
            if( ans <= (double)n*(n-1)/4 ) {
                r = m;
            }
            else {
                l = m;
            }
        }
        printf("%.12Lf\n", r);
    }

    return 0;
}


Measured memory_bytes: 7888
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

int N;
#define MAXN 200001
int P[MAXN];

int main(){
    cin >> N;
    rep(i,N)cin >> P[i];
    int sta_min  =P[0];
    int ans = 1;
    for(int i=1;i<N;i++){
        if(P[i] < sta_min){
            sta_min = P[i];
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  k=min(41LL,k);
  for(int i=0;i<k;i++){
    vector<int> b(n,0);
    for(int j=0;j<n;j++){
      int l=max(0LL,j-a[j]);
      int r=min(n-1,j+a[j]);
      b[l]++;
      if(r+1<n){
        b[r+1]--;
      }
    }
    a[0]=b[0];
    for(int j=1;j<n;j++){
      b[j]+=b[j-1];
      a[j]=b[j];
    }
    /*
    for (ll x : a) {
      cout << x << " ";
    }
    cout << endl;
    */
  }
  for(ll x:a){
    cout<<x<<" ";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ppb pop_back()
#define fi first
#define se second
#define pi pair<int, int>
#define rep(i, a, n) for(int i = a; i <= n; i++)
#define REP(i, a, n) for(int i = a; i < n; i++)
#define Y "Yes"
#define N "No"
using namespace std;

string s;
int n, c, d;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	//freopen("in.txt", "r", stdin);

	cin >> n >> s;
	REP(i, 0, n)
		if (s[i] == 'R') c++;
	REP(i, 0, c) {
		if (s[i] == 'R') d++;
	}
	cout << c-d;
}

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

int main()
{
    set<int> st;
    rep(i, 3)
    {
        int a;
        cin >> a;
        st.insert(a);
    }
    cout << st.size();
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<climits>
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define MOD 1000000007
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<unsigned long long> ans(n,0);
    unsigned long long sum = 0;
    for(int i = 0;i<n;i++)
    {
        cin>>ans[i];
    }
    unsigned long long check = 0;
    for(int i = 0;i<n;i++)
    {
       sum = (sum + (ans[i]*check)%MOD)%MOD;
       check  = (check + ans[i])%MOD;
    }

    cout<<sum;
return 0;
}

Measured memory_bytes: 4336
//
// Created by yamunaku on 2019/08/24.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    ll n,k;
    cin >> n >> k;
    vl a(n);
    vl c(5000,0);
    rep(i,n){
        cin >> a[i];
        c[a[i]]++;
    }
    ll ans=0;
    rep(i,n){
        repl(j,i+1,n){
            if(a[i]>a[j]){
                ans++;
            }
        }
    }
    ans=k*ans%MOD1;
    ll total=0;
    rep(i,5000){
        ans=(ans+(k-1)*k/2%MOD1*c[i]%MOD1*total%MOD1)%MOD1;
        total+=c[i];
    }
    cout << ans%MOD1 << endl;
    return 0;
}


Measured memory_bytes: 256
S=int(input())
l=[0]*1000000
l[0]=0
l[1]=S
for i in range(2,1000000):
    if l[i-1]%2==0:
       l[i]=l[i-1]//2
    else:
        l[i]=3*l[i-1]+1
    for j in range(1,i-1):
        if l[i]==l[j]:
            print(i)
            exit()

Measured memory_bytes: 10868