akhauriyash/Code-Regression huggingface dataset:
/*
 *  Created on: 17 / 5 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

//#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)

ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

const ll mod = 1e15 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0)
    Eslam__Waheed
        ll k; cin >> k;
    ss s; cin >> s;
    if (sz(s) <= k)
    {
        cout << s;
        return 0;
    }
    for (int i = 0; i < k; i++)
    {
        cout << s[i];
    }cout << "...";
}

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

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

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string S; cin >> S;
  string result = S.size()>=4 && S.substr(0,4)=="YAKI" ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




int A, B;
bool solve() {
    if (A >= 9) return false;
    else return true;
}

int main() {
    while (cin >> A >> B) {
        if (A < B) swap(A, B);
        if (solve()) puts("Yay!");
        else puts(":(");
    }
}



























Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max({a*c, a*d, b*c, b*d}) << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Y;
    bool checker = false;
    cin >> N >> Y;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N - i; j++) {
            int sum = 10000 * i + 5000 * j;
            if ((Y - sum) / 1000 == N - i - j) {
                cout << i << " " << j << " " << N - i - j << endl;
                checker = true;
                break;
            }
        }
        if (checker) break;
    }
    if (!checker) {
        cout << -1 << " " << -1 << " " << -1 << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      double D = sc.nextDouble();
      double T = sc.nextDouble();
      double S = sc.nextDouble();
      if(D/S<=T){
      	System.out.print("Yes");
      }else{
        System.out.println("No");
      }
    }
}


Measured memory_bytes: 37196
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[s.length()-1]!='s')
        s.push_back('s');
    else
    {
        s.push_back('e');
        s.push_back('s');
    }
    cout<<s<<"\n";
    
}

Measured memory_bytes: 3600
package main

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

func main() {
	nextReader = newScanner()
	k, x := nextInt(), nextInt()
	if 500*k >= x {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 640
N, M = map(int, input().split())
graph = [[0 for i in range(N)] for j in range(N)]
edges = []
for m in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges.append([a,b])
    graph[a][b] = 1
    graph[b][a] = 1

ans = 0
for a,b in edges:
    graph[a][b] = 0
    graph[b][a] = 0

    visited = [False] * N
    visited[0] = True
    q = [i for i in range(N) if graph[0][i]]

    while q:
        r = q.pop(0)
        visited[r] = True
        for i in range(N):
            if graph[r][i] and not visited[i]:
                q.append(i)

    if False in visited:
        ans += 1

    graph[a][b] = 1
    graph[b][a] = 1

print(ans)

Measured memory_bytes: 40048
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

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

    int ret = 0;
    rep(i, n) {
        if (s[i] == 'g')
            ret++;
        else
            ret--;
    }
    ret -= n % 2;

    cout << ret / 2;
    /* ====================================== */
    cout << endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  
  int ans = 0, cur = 0;
  for (int i = 0; i < 3; i++){
    if (S.at(i) == 'R'){
      cur++;
    }
    else{
      ans = max(ans, cur);
      cur = 0;
    }
    
  }
  
  ans = max(ans, cur);
    
  cout << ans << endl;
}

Measured memory_bytes: 3624
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i < n;i++){
            a[i] = sc.nextInt();
        }

        int m = sc.nextInt();
        int[] b = new int[m];
        for(int i = 0;i < m;i++){
            b[i] = sc.nextInt();
        }

        int i = 0;
        while(true){
            if(i >= b.length){
                System.out.println("0");
                break;
            }
            if(i >= a.length){
                System.out.println("1");
                break;
            }
            if(a[i] > b[i]){
                System.out.println("0");
                break;
            }
            if(a[i] < b[i]){
                System.out.println("1");
                break;
            }
            i++;
        }
    }
}


Measured memory_bytes: 32128
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=1e2,M=6e6;
char map[N+10][N+10];
int pre[M+10],now[N*N*2+10],child[M+10],val[M+10];
int h[N*N*2+10],deep[N*N*2+10];
bool vis[N*N*2+10];
int n,m,S,T,tot=1;
int Get(int x,int y){return (x-1)*m+y;}
void join(int x,int y,int z){pre[++tot]=now[x],now[x]=tot,child[tot]=y,val[tot]=z;}
void insert(int x,int y,int z){join(x,y,z),join(y,x,0);}
bool bfs(int x){
	int head=1,tail=1;
	memset(deep,255,sizeof(deep));
	deep[h[1]=x]=0;
	for (;head<=tail;head++){
		int Now=h[head];
		for (int p=now[Now],son=child[p];p;p=pre[p],son=child[p]){
			if (!~deep[son]&&val[p]){
				deep[h[++tail]=son]=deep[Now]+1;
				if (son==T)	return 1;
			}
		}
	}
	return 0;
}
int dfs(int x,int v){
	if (x==T)	return v;
	int res=0;
	for (int p=now[x],son=child[p];p;p=pre[p],son=child[p]){
		if (deep[son]>deep[x]&&val[p]){
			int k=dfs(son,min(v,val[p]));
			val[p]-=k,v-=k;
			val[p^1]+=k,res+=k;
			if (!v)	break;
		}
	}
	if (!res)	deep[x]=-1;
	return res;
}
int main(){
	n=read(),m=read(),S=2*n*m+1,T=S+1;
	for (int i=1;i<=n;i++){
		scanf("%s",map[i]+1);
		for (int j=1;j<=m;j++){
			if (map[i][j]=='.')	continue;
			if (map[i][j]!='o'){
				insert(Get(i,j),Get(i,j)+n*m,inf);
				if (map[i][j]=='S')	insert(S,Get(i,j),inf);
				if (map[i][j]=='T')	insert(Get(i,j)+n*m,T,inf);
				map[i][j]='o';
			}else	insert(Get(i,j),Get(i,j)+n*m,1);
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			if (map[i][j]=='o'){
				for (int k=1;k<=n;k++)	if (map[k][j]=='o'&&k!=i)	insert(Get(i,j)+n*m,Get(k,j),inf);
				for (int k=1;k<=m;k++)	if (map[i][k]=='o'&&k!=j)	insert(Get(i,j)+n*m,Get(i,k),inf);
			}
		}
	}
	int Ans=0;
	while (bfs(S))	Ans+=dfs(S,inf);
	printf(Ans>=inf?"-1\n":"%d\n",Ans);
	return 0;
}

Measured memory_bytes: 53504
import java.util.*;

class Graph {
  public void addEdge(int a, int b) {
    if(! nodes.containsKey(a)) nodes.put(a, new Node());
    if(! nodes.containsKey(b)) nodes.put(b, new Node());

    nodes.get(a).addEdge(nodes.get(b));
    nodes.get(b).addEdge(nodes.get(a));
  }

  public int findLongestChain() {
    int max = 0;
    for(Node n : searchStartNodes()) {
      int d = n.dfs();
      if(d > max) max = d;
    }
    return max;
  }

  private Set<Node> searchStartNodes() {
    Collection<Node> ns = nodes.values();
    Set<Node> lst = new HashSet<Node>(ns);

    // 周囲のノードのうちエッジの数が極小のもののみを対象とする
    for(Node n : ns) {
      if(lst.contains(n)) {
        int rank = n.edges.size();
        for(Node s : n.edges) {
          if(lst.contains(s) && s.edges.size() <= rank) {
            lst.remove(n);
            break;
          }
        }
      }
    }

    Set<Node> snodes = new HashSet<Node>();

    // 対等なノードは1つのみで良い
    for(Node n1 : lst) {
      boolean contains = false;
      for(Node n2 : snodes) {
        if(n1.edges.equals(n2.edges)) {
          contains = true;
          break;
        }
      }
      if(! contains) snodes.add(n1);
    }

    return snodes;
  }

  private Map<Integer, Node> nodes = new HashMap<Integer, Node>();
}

class Node {
  public void addEdge(Node n) {
    edges.add(n);
  }

  public int dfs() {
    return dfs(new HashSet<Node>());
  }

  private int dfs(Set<Node> visited) {
    int max = 0;
    visited.add(this);

    for(Node e : getNeighbors(visited)) {
      if(! visited.contains(e)) {
        int n = e.dfs(visited);
        if(n > max) max = n;
      }
    }

    visited.remove(this);

    max++;
    return max;
  }

  private Set<Node> getNeighbors(Set<Node> visited) {
    Set<Node> nodes = new HashSet<Node>();

    // 対等なノードは1つのみで良い
    for(Node n1 : edges) {
      if(visited.contains(n1)) continue;

      boolean contains = false;
      for(Node n2 : nodes) {
        if(n1.edges.equals(n2.edges)) {
          contains = true;
          break;
        }
      }
      if(! contains) nodes.add(n1);
    }

    return nodes;
  }

  Set<Node> edges = new HashSet<Node>();
}

public class Main {
  private Scanner sc = new Scanner(System.in);

  public void run() {
    while(sc.hasNextInt()) {
      int n = sc.nextInt();
      if(n == 0) break;

      Graph g = new Graph();

      for(int i = 0; i < n; i++) {
        g.addEdge(sc.nextInt(), sc.nextInt());
      }

      System.out.println(g.findLongestChain());
    }
  }

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

Measured memory_bytes: 13000
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
string s;
vector<int> B;

int main() {
  INCANT;
  cin >> s;
  int N = s.size();
  rep(i, N) if (s[i]!='x') B.push_back(i);
  int b =B.size();
  rep(i, b/2) {
    if (s[B[i]] != s[B[b-1-i]]) {
      cout << -1 << "\n";
      return 0;
    } 
  }

  int left = 0;
  int right = N-1;
  int ans = 0;
  rep(i, b/2) {
    int tmp = abs((B[i]-left) - (right-B[b-1-i]));
    ans+=tmp;
    left = B[i];
    right = B[b-1-i];
  }
  if (b%2==1) ans+=abs((B[b/2]-left)- (right-B[b/2]));
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 972
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
int main(){
    string s;
    cin>>s;
    s.at(3)='8';
    cout<<s<<endl;
}


Measured memory_bytes: 3528
#include <stdio.h>

int main(void){
	int h, w, i, j;

	while(1){
		scanf("%d %d", &h, &w);
		if(h==0 && w ==0)
			break;
		for(i=0; i<h; i++){
			for(j=0; j<w; j++){
				if((i+j)%2==0)
					printf("#");
				else
					printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>

int main()
{
    int N, H, W;
    std::cin >> N >> H >> W;

    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        int a, b;
        std::cin >> a >> b;

        if (H <= a && W <= b) {
            ++cnt;
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();

		System.out.println("+".equals(op) ? a + b : a - b);


		sc.close();

	}

}

Measured memory_bytes: 35656
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int[] h=new int[n];
		for(int i=0; i<n; i++){
			h[i]=sc.nextInt();
		}
		Arrays.sort(h);
		long sum=0;
		for(int i=0; i<n-k; i++){
			sum+=h[i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 88724
#include <bits/stdc++.h>
using namespace std;
int main (){
    int h,w;
    bool ans=true;
    cin >> h >> w;
    vector<vector<char>> v(h+2,vector<char>(w+2,'.'));//ここ
    
    for(int i=1;i<h+1;i++){
        for(int j=1;j<w+1;j++){//ループ条件の文字、どれがどれか注意
            cin >> v.at(i).at(j);
        }
    }//入力
    
    for(int i=1;i<h+1;i++){//ループ誤り実装に注意
        for(int j=1;j<w+1;j++){
            if(
            v.at(i-1).at(j)=='.' &&
            v.at(i+1).at(j)=='.' && 
            v.at(i).at(j-1)=='.' && 
            v.at(i).at(j+1)=='.' &&
            v.at(i).at(j)=='#'){
            ans = false;
            break;
            }
        }// #の上下左右を調べる
    }
    if(ans == true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> pile(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &pile[i]);
    }
    sort(pile.rbegin(), pile.rend());
    pile.insert(pile.begin(), pile[0]);

    int cx = 0;
    for (int x = 0; x < n; ++x) {
        if (pile[x + 1] < x + 1) break;
        cx = x;
    }

    int up = pile[cx + 1] - cx;
    int left = 0;
    for (int x = cx + 1; x <= n; ++x) {
        if (pile[x] <= cx) break;
        ++left;
    }

    printf((up % 2) && (left % 2) ? "Second\n" : "First\n");
    return 0;
}

Measured memory_bytes: 1024
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "abc165_d.cpp"

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, n;
  cin >> a >> b >> n;
  cout << floor(a * ((double)min(n, b - 1) / b)) << endl;
}


Measured memory_bytes: 3804
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

int use(int money, int coin){
	return money / coin;
}

int main(){
	int time[3][3];
	int ans[3];
	int buf[3][3];
	int hours, minutes, seconds;

	for (int a = 0; a < 3; a++){
		scanf("%d%d%d", &time[a][0], &time[a][1], &time[a][2]);
		scanf("%d%d%d", &buf[a][0], &buf[a][1], &buf[a][2]);
		ans[a] = (buf[a][0] * 3600 + buf[a][1] * 60 + buf[a][2]) - (time[a][0] * 3600 + time[a][1] * 60 + time[a][2]);
		printf("%d", use(ans[a], 3600));
		ans[a] -= use(ans[a], 3600) * 3600;
		printf(" %d", use(ans[a], 60));
		ans[a] -= use(ans[a], 60) * 60;
		printf(" %d\n", ans[a] % 60);
	}
	return 0;
}

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

int main(){
	ll N;
	cin>>N;
	ll steps = 0;
	ll min_steps = LLONG_MAX;
	for(ll i=1; i*i <= N; i++){
		if(N%i==0){
			steps = (i-1) + (N/i -1);
			min_steps = std::min(min_steps, steps);
		}
	}
	cout<<min_steps;
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

string S;

ll s_to_int(ll start, ll end){
  if(start>=S.size()) return 0;
  ll ans = 0;
  for(ll i=start; i<=end; ++i){
    ans *= 10;
    ans += S[i]-'0';
  }
  return ans;
}

ll search(ll state){
  ll ans = 0;
  ll state_tmp = 1;
  ll start = 0;
  REP(i,(S.size()-1)){
    if(state&state_tmp){
      ans += s_to_int(start, i);
      start = i+1;
    }
    state_tmp<<=1;
  }
  ans += s_to_int(start, S.size()-1);
  return ans;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  IN(S);
  ll ans = 0;
  REP(i,1<<(S.size()-1)){
    ans += search(i);
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;
const int MAX_H = 100;
const int MAX_W = 100;

//?????\
int H, W;
char g[MAX_H][MAX_W + 1];

int d[4][2] = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};        //??????

//??±???????????????g[i][j]????±??±????
void dfs(int x, int y, int c){
    for(int i = 0; i < 4; i ++){
        int nx = x + d[i][0], ny = y + d[i][1];
        if(0 <= nx && nx < H && 0 <= ny && ny < W && g[nx][ny] == c){
            g[nx][ny] = '1';
            dfs(nx, ny, c);
        }
    }
}

void solve(){
    //????????????????????°????????°?????????????????\???????????°????????°???
    int ans = 0;
    for(int i = 0; i < H; i ++){
        for(int j = 0; j < W; j ++){
            if(g[i][j] != '1'){
                ans ++;
                char c = g[i][j];
                g[i][j] = '1';
                dfs(i, j, c);
            }
        }
    }
    printf("%d\n", ans);
}

int main(int argc, char const *argv[]){

    while(scanf("%d %d", &H, &W)){
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i ++){
            scanf("%s", g[i]);
        }
        solve();
    }

    return 0;
}

Measured memory_bytes: 1508
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val pp = readLine()!!.split(" ").map { it.toInt() }

    var min = pp[0]
    var cnt = 0

    pp.forEach {
        if (it <= min) {
            cnt++
            min = it
        }
    }

    println(cnt)
}

Measured memory_bytes: 82924
import Control.Applicative
import Control.Arrow ((&&&))
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char (isSpace)

main :: IO ()
main = solve <$> (flip div 2 <$> readLn) <*> f >>= print
  where
    f = readil B.readInt <$> B.getLine

solve :: Int -> [Int] -> Int
solve n vs = min (h ds us) (h us ds)
  where
    f (as, bs) [] = (as, bs)
    f (as, bs) (x:y:ys) = f (x:as, y:bs) ys
    (as, bs) = f ([], []) vs
    g = sortBy (flip compare) . map (length &&& head) . group . sort
    (ds, us) = (g as, g bs)
    h xs ys = n - (fst . head) xs + case filter (\(_,s) -> s /= ((snd . head) xs)) ys of
                                     [] -> n
                                     ((m,_):_) -> n - m

readil :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr g
  where
    g s = do
      (n, s') <- f s
      return (n, B.dropWhile isSpace s')


Measured memory_bytes: 21884
"""考え方
素数リストをあらかじめ作成し、その中から適当にN個値を選ぶ。
そして、その全ての5個の合計が合成数になることを確認？

"""
N = int(input())

prims = [1] * 55555
prims[0] = 0
prims[1] = 0

## 素数リストの作成
for i in range(250):
  if prims[i] == 1:
    for j in range(2*i,55555,i):
      prims[j] = 0
      

## 素数リストから5で割った際に1余る数をN個持ってくる
list_ans = []
for i in range(55555):
  if (prims[i] == 1) and (i%5 == 1):
    list_ans.append(str(i))
    if len(list_ans) >= N:
      break
    
print(" ".join(list_ans))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    map<string, int> mp;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;
    string s;
    cin >> s;
    cout << mp[s];
    return 0;
}

Measured memory_bytes: 3672
import java.util.Scanner;
public class Main{
	int x;
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		System.out.println(x*x*x);
		
	}
	
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x;cin>>x;
    cout<<1-x<<endl;
}


Measured memory_bytes: 3644
#A
#n = int(input())
#print(3*n**2)
#B
n, d = map(int, input().split())
canseerange = 2*d+1
if n % canseerange == 0:
    print(int(n/canseerange))
else:
    print(int(n/canseerange)+1)

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

int main(){
    double n;
    cin>>n;
    vector<int> x(n);
    rep(i,n) cin>>x[i];
    
    double ave=round(accumulate(x.begin(),x.end(),0)/n);
    
    int ans=0;
    rep(i,n) ans +=(x[i]-ave)*(x[i]-ave);
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <cmath>

int main(void){
    std::string s,t;
    std::cin >> s >> t;
    std::sort(s.begin(),s.end());
    std::sort(t.begin(),t.end(),std::greater<int>());

    if(s<t){
        std::cout << "Yes";
    }
    else{
        std::cout << "No";
    }
    return 0;

}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b = 0;
  scanf("%d",&a);
  scanf("%d",&b);
  
  a *= b;
  switch(a%2){
    case 0:
      printf("Even");
      break;
    default:
      printf("Odd");
      break;
  }
  return 0;
}

Measured memory_bytes: 128
fun main(args:Array<String>) {
	val s= readLine()!!
	val k= readLine()!!.toLong()
	if(s.all{it=='1'}){
		println('1')
	}else if(k<=s.takeWhile {it=='1'}.length){
		println('1')
	}else{
		println(s.first{ it!='1'})
	}
	
}

Measured memory_bytes: 33708
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace  std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(n) for (int i = 0; i < n; ++i)
#define ps(x) cout << x << endl;
#define ps_end(x) ps(x); return;

const int md = 1e9 + 7; //998244353 ;
void addto(int &x, int y) { x = x + y; if (x >= md) x -= md; }
int add(int x, int y) { int z = x + y; return z >= md? z -= md : z;}
void updmin(auto&x, auto y ) { if (y < x) x = y;}
void updmax(auto&x, auto y ) { if (y > x) x = y;}
long long pw(auto x, auto y) {	
	long long s = 1;
	while(y) {
		if (y & 1) s = s * x % md;
		x= 1LL * x * x % md; y /= 2;
	}
	return s;
}


const int maxn = 1e6 + 10;

int T, n, m;

void task() {
	cin >> n;
	cout << ((n >= 30)?"Yes":"No") << endl;
	
	// you should actually read the stuff at the bottom
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout<<fixed<<setprecision(20);
  T  = 1;
  for (int ti = 1; ti <= T; ++ti) {
    task();
  }
  return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* write down
*/


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

double prob(ll n, ll d){
    if(d==0)return (double)1/n;
    else return (double)2*(n-d)/n/n;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,d;cin>>n>>m>>d;
    cout<<setprecision(12)<<(m-1)*prob(n,d);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <cmath>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	
	int gc=0, pc=0, ans=0;
	
	rep(i,sz(s)){
		if(s[i] =='g'){
			if(pc<gc){ pc++; ans++;}
			else{gc++;}
		}else{
			if(pc<gc){ pc++; }
			else{gc++; ans--;}
			
		}
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int even = 0;
    rep(_, n){
        int a;
        cin >> a;
        if(a%2==0) ++even;
    }

    int all_odd = pow(2, even);
    cout << pow(3, n) - all_odd << endl;

    return 0;
}

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

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

  int five = 0;
  int seven = 0;

  int len[3] = {a, b, c};

  for(int i = 0; i < 3; i++){
    if(len[i] == 5){
      five++;
    }else if(len[i] == 7){
      seven++;
    }
  }
  if(five == 2 && seven == 1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N, K;
    cin >> N >> K;
    vll A(K);
    vl snuke(N, 0);
    rep(i, K){
        ll d;
        cin >> d;
        rep(j, d){
            ll a;
            cin >> a;
            a--;
            snuke[a]++;
        }
    }
    ll ans = 0;
    rep(i, N){
        if(snuke[i] == 0){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3636
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define mp make_pair

using namespace std;

typedef long long int64;
typedef vector<int> vi;
typedef pair<int, int> ii;

class TaskB {
 public:
  int n;
  vector<vector<int>> dist;
  vector<vector<int>> have;

  void upd( int r, int c, int d) {
    if (r < 0 || c < 0 || r >= n || c >= n || d >= dist[r][c]) return;
    dist[r][c] = d;
    d += have[r][c];
    for (int dr = -1; dr <= 1; ++dr) {
      for (int dc = -1; dc <= 1; ++dc) if (abs(dr) + abs(dc) == 1)  {
        upd(r + dr, c + dc, d);
      }
    }
  }

  void solveOne(istream &in, ostream &out) {
    in >> n;
    vector<int> p(n * n);
    for (int i = 0; i < p.size(); ++i) {
      in >> p[i];
      --p[i];
    }
    dist = vector<vector<int>>(n, vector<int>(n));
    have = vector<vector<int>>(n, vector<int>(n, 1));
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        dist[i][j] = min(i, min(j, min(n - 1 - i, n - 1 - j)));
      }
    }
    int res = 0;
    for (int at : p) {
      int r = at / n;
      int c = at % n;
      have[r][c] = 0;
      res += dist[r][c];
      for (int dr = -1; dr <= 1; ++dr) {
        for (int dc = -1; dc <= 1; ++dc) if (abs(dr) + abs(dc) == 1) {
          upd(r + dr, c + dc, dist[r][c]);
        }
      }
    }
    out << res << "\n";
  }

  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int it = 0; it < nt; ++it) {
      solveOne(in, out);
    }
  }
};


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  TaskB solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 24964
#include <map>
#include <cstdio>
#include <algorithm>

using namespace std;
#define rep(i,a,n) for (int i=(a);i<(n);++i)

const int N=200000+5;

inline int read() {
  int x;scanf("%d",&x);return x;
}
int n,k;

map <int,int> cnt;

int c[N];

int main() {
  n=read(),k=read();
  rep (i,0,n) ++cnt[read()];
  map<int,int>::iterator it=cnt.begin();
  int p=0;
  while (it!=cnt.end()) {
    c[p++]=it->second,++it;
  }
  sort(c,c+p);
  int ans=0;
  rep (i,0,p-k) ans+=c[i];
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 10368
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		int m=1<<s[0],inf=int.MaxValue;
		int[][] h=new int[s[0]][];
		var dp=new long[m][];
		for(int i = 0;i<s[0];i++) {h[i]=Enumerable.Repeat(inf,s[0]).ToArray();}
		for(int i = 0;i<s[1];i++) {
			var e=sc.Ia;
			h[e[0]][e[1]]=e[2];
		}
		for(int i = 1;i<m;i++) {
			dp[i]=new long[s[0]];
			for(int j = 0;j<s[0];j++) {
				if((1<<j)!=i){
					dp[i][j]=inf;
					if(((1<<j)&i)!=0){
						for(int k = 0;k<s[0];k++) {
							if(dp[i][j]>dp[i^(1<<j)][k]+h[k][j]){
								dp[i][j]=dp[i^(1<<j)][k]+h[k][j];
							}
						}
					}
				}
				else if(i!=1){dp[i][j]=inf;}
			}
		}
		long ans=inf;
		for(int i = 0;i<s[0];i++) {ans=Min(ans,dp[m-1][i]+h[i][0]);}
		Console.WriteLine("{0}",ans>=inf?-1:ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}



Measured memory_bytes: 28736
#include <bits/stdc++.h>
using namespace std;
int N;
string a[200001];
map<string, int> mp;
int ans = 0;

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> a[i];
        mp[a[i]] = 1;
    }
    for(auto i = mp.begin(); i != mp.end(); ++i){
        ans += i->second;
    }
    cout << ans << endl;
    return 0;  
}

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

n=int(input())
a= [list(map(int, input().split())) for i in range(n-1)]

b = [[] for i in range(n)]
a1=[]
a2=[]
ans=[0]*n
for i in range(n-1):
    b[a[i][0]-1].append(a[i][1]-1)
    b[a[i][1]-1].append(a[i][0]-1)

import collections
from collections import deque
def tree(s):

    INF=-10**9
    dis = [INF for i in range(n)]
    dis[s]=0
    def bfs():
        d = deque()
        d.append(s)
        a1.append(s)

        while len(d):
            x = d.popleft()

            for i in range(len(b[x])):
                y=b[x][i]
                if dis[y] == INF:
                    d.append(y)
                    dis[y]=dis[x]+1
                    if dis[y]%2==0:
                        a1.append(y)
                    else:
                        a2.append(y)
        return a1,a2
    return bfs()

tree(0)

j = 0
k = 0
if min(len(a1),len(a2))<=n//3:
    if len(a1)<=n//3:
        for i in range(1,n+1):
            if i<=len(a1)*3 and i%3==0 and j<=len(a1)-1:
                ans[a1[j]]=i
                j+=1
            else:
                ans[a2[k]]=i
                k+=1
    else:
        for i in range(1,n+1):
            if i<=len(a2)*3 and i%3==0 and j<=len(a2)-1:
                ans[a2[j]]=i
                j+=1
            else:
                ans[a1[k]]=i
                k+=1

else:
    for i in range(1,n+1):
        if i%3==1:
            ans[a1[j]]=i
            j+=1
        elif i%3==2:
            ans[a2[k]] = i
            k += 1
        else:
            continue

    for i in range(3,n+1,3):
        if j<=len(a1)-1:
            ans[a1[j]]=i
            j+=1
        else:
            ans[a2[k]] = i
            k += 1


print(*ans)

Measured memory_bytes: 119308
def main():
    INF = int(1e9+7)
    N = int(input())
    ans_total = 1
    ans1 = 1
    ans2 = 1
    if N <= 1:
        print(0)
        return 
    
    for i in range(N):
        ans_total = ans_total * 10
        ans1 = ans1 * 9
        ans2 = ans2 * 8

        ans_total = ans_total % INF
        ans1 = ans1 % INF
        ans2 = ans2 % INF

    print((ans_total - ((2*ans1 - ans2)))%INF)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63016
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] a = new Integer[N];
		for (int i=0; i<N; i++) {
			a[i] = sc.nextInt();
		}
		int bob = 0; int alice = 0;
		Arrays.sort(a, Collections.reverseOrder());
		for (int i=0; i<a.length; i++) {
			if (i%2 ==0) alice += a[i];
			else bob += a[i];
		}
		System.out.println(alice - bob);
	}
}


Measured memory_bytes: 23124
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            List<Integer> numList = Arrays.stream(args.get(1).split(" ")).map(Integer::valueOf).collect(Collectors.toList());
            int min = Integer.MAX_VALUE;
            int right = numList.stream().mapToInt(x -> x).sum();
            int left = 0;
            for (int i = 0; i < numList.size(); i++) {
                left += numList.get(i);
                right -= numList.get(i);
                min = Math.min(min, Math.abs(right - left));
            }
            System.out.println(min);
        };
    }

}


Measured memory_bytes: 29012
#include <bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
using ll = long long;
/*
    g++ -std=c++11 test.cpp -o test.out && ./test.out
*/
int n, m;
void solve(){
    int n, k; cin >> n >> k;

    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    sort(a.begin(), a.end());

    // debug(a);
    int count = 0;
    for(int i = 0; i < k; i++) count += a[i];

    cout << count;
}   
 
int main()
{    
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    solve();
    
    return 0;
}

Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class44
    {
        static void Main()
        {
            var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = abc[0], b = abc[1], c = abc[2];
            if (!check(a, b, c)) { Console.WriteLine(0);return; }
            if (a == b && b == c) { Console.WriteLine(-1);return; }

            int count = 0;
            while (check(a,b,c))
            {
                int d = a, e = b, f = c;
                a = (e + f) / 2;
                b = (d + f) / 2;
                c = (d + e) / 2;
                count++;
            }
            Console.WriteLine(count);
        }
        static bool check(int a,int b,int c)
        {
            bool ans = false;
            if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) ans = true;
            return ans;
        }
    }
}


Measured memory_bytes: 13396