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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

class WarshallFloyd {
private:
    const int n;
    vector<vector<int>> d;
public:
    WarshallFloyd(int _n) : n(_n), d(_n, vector<int>(_n)) {
        rep(i, n) rep(j, n) {
            d[i][j] = (i == j ? 0 : inf);
        }
    }
    // undirected
    void setDist(int i, int j, int c) {
        d[i][j] = c;
        d[j][i] = c;
    }
    int getDist(int i, int j) {
        return d[i][j];
    }
    void calc() {
        rep(k, n) rep(i, n) rep(j, n) {
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }
    void disp() {
        printVV(d);
    }
};

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

    int n, m;
    while (cin >> n >> m, n) {
        vector<WarshallFloyd> wf(2, WarshallFloyd(n));
        rep(i, m) {
            int a, b, c;
            char t;
            cin >> a >> b >> c >> t;
            a--, b--;
            wf[t == 'S'].setDist(a, b, c);
        }

        rep(k, 2) wf[k].calc();

        int q;
        cin >> q;
        int s = -1;
        vi a(n, inf);
        rep(i, q) {
            int t;
            cin >> t;
            t--;
            if (i == 0) {
                a[t] = 0;
            }
            else {
                vi b(n, inf);
                rep(j, n) {
                    chmin(b[j], a[j] + wf[0].getDist(s, t));
                    rep(k, n) {
                        if (j == k) continue;
                        chmin(b[k], a[j] + wf[0].getDist(s, j) + wf[1].getDist(j, k) + wf[0].getDist(k, t));
                    }
                }
                a = b;
            }
            s = t;
        }

        cout << *min_element(all(a)) << endl;
    }
}

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

/**
 * 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;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			int count = 0;
			for(int i = 1; i <= N; i++) {
				String str = String.valueOf(i);
				if(str.length() % 2 != 0) {
//					System.out.println(i);
					count++;
				}
			}
			System.out.println(count);
		}
	}

	static boolean permutation_2(String s, String t) {
		if (s.length() != t.length()) {
			return false;
		}

		int[] letters = new int[256];

		char[] s_array = s.toCharArray();
		for (char c : s_array) {
			letters[c]++;
		}

		for (int i = 0; i < t.length(); i++) {
			int c = (int) t.charAt(i);
			if (--letters[c] < 0) {
				return false;
			}
		}
		return true;
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

		public char nextChar() {
			return next().charAt(0);
		}

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

		public double nextDouble() {
			return Double.parseDouble(next());
		}

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

	}
}


Measured memory_bytes: 27220
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long n,l[128],i;
    l[0]=2;l[1]=1;
    scanf("%lld",&n);
    for(i=2;i<=n;i++){l[i]=l[i-2]+l[i-1];}
    printf("%lld\n",l[n]);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int w, a, b;
    cin >> w >> a >> b;
    int x = a+w;
    int y = b+w;
    int ans;
    if (x < b) ans = b-x;
    else if (y < a) ans = a-y;
    else ans = 0;
    cout << ans << std::endl;
    return 0;
}

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

int main(){
	int H, W, i, j;
	scanf("%d%d", &H, &W);
	char **s = (char **)malloc(sizeof(char *) * (H + 2));
	for(i = 0; i <= H + 1; i++){
		s[i] = (char *)malloc(sizeof(char) * (W + 2));
		if(i == 0 || i == H + 1){
			for(j = 0; j <= W + 1; j++){
				s[i][j] = '.';
			}
		}
		else{
			scanf("%s", &s[i][1]);
			s[i][0] = '.';
			s[i][W + 1] = '.';
		}
	}
	for(i = 1; i <= H; i++){
		for(j = 1; j <= W; j++){
			if(s[i][j] == '#' && s[i - 1][j] == '.' && s[i + 1][j] == '.' && s[i][j - 1] == '.' && s[i][j + 1] == '.'){
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int mod = 1e9 + 7;
inline int mul( int x , int y ){ return 1LL * x * y % mod ;}
int power_mod( int x , int y ){int ret = 1;while( y ){if( y & 1 ) ret = mul( ret , x );y >>= 1;x = mul( x , x );}return ret;}
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
using namespace std;
const int maxn = 200 + 50;

char g[maxn][maxn],out[maxn][maxn];
int n , m;


int main(int argc,char *argv[]){
	//freopen( "in.txt" , "r" , stdin );
	n=read(),m=read();
	for(int i = 1 ; i <= n ; ++ i)
		scanf("%s",g[i]+1);
	for(int i = 1 ; i <= n * 2 ; ++ i)
		for(int j = 1 ; j <= m ; ++ j)
			out[i][j]=g[(i+1)/2][j];
	for(int i = 1 ; i <= n * 2 ; ++ i)
		cout<<out[i]+1<<endl;
	return 0;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 3e5 + 5;

typedef pair<int,int>   ii;

struct BIT  {
    int t[N];

    int upd(int p,int x)    {
        for(; p < N ; p += p & -p)
            t[p] += x;
        return  1;
    }
    int get(int p)  {
        int ans = 0;
        for(; p > 0 ; p -= p & -p)
            ans += t[p];
        return  ans;
    }
}   T[2];

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n;  cin >> n;
    ll  x = 0;
    ll  y = 0;

    for(int i = 1 ; i <= n ; ++i)   {
        int p;  cin >> p;
        int v = i % 2;

        if (p % 2 != v) {
            cout << "No";
            return  0;
        }
        x += T[v].get(n) - T[v].get(p); v ^= 1;
        y += T[v].get(n) - T[v].get(p); v ^= 1;

        T[v].upd(p,1);
    }
    if (y == x + x) cout << "Yes";
    else            cout << "No";
}

Measured memory_bytes: 2560
package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	var n, k int
	fmt.Fscanf(reader, "%d %d", &n, &k)
	if n%k == 0 {
		fmt.Fprintf(writer, "%d\n", 0)
	} else {
		fmt.Fprintf(writer, "%d\n", 1)

	}
}

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

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

    int d[n];
    int i,j;
    for(i=0;i<n;i++){
        cin >> d[i];

    }
    int sum = 0;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(i != j && i>j){
                sum += d[i]*d[j];
            }
        }
    }
    cout << sum;

    return 0;
}

Measured memory_bytes: 256
/*  HARD WORK FOREVER PAYS  */
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
vector<int> v[1000000+100];
int cont[1000000+100];
void divisor(){
	int i,j;
	for(i=1;i<=1000000;i++){
		for(j=i;j<=1000000;j+=i){
			v[j].pb(i);
		}
	}
}
int main() 
{ 
	turbo();
	divisor();
	int n,i,cnt=0,j,x,y=1;
	cin>>n;
	int ara[n];
	for(i=0;i<n;i++){
		cin>>x;
		ara[i]=x;
		cont[x]++;
	}
	for(i=0;i<n;i++){
		y=1;
		cont[ara[i]]--;
		for(j=0;j<v[ara[i]].size();j++){
			if(cont[v[ara[i]][j]]){
				y=0;
				break;
			}
		}
		cnt+=y;
		cont[ara[i]]++;
	}
	cout<<cnt<<"\n";
	return 0;
} 

Measured memory_bytes: 122376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please



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


	int N;
	cin >> N;
	double kotae = 0;

	rep(i, N) {
		double X;
		string u;
		cin >> X >> u;
		if (u == "JPY") kotae += X;
		else kotae += X * 380000;
	}

	cout << fixed << kotae << endl;

	Would you please return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	PRI(min(a, b) + min(c, d));
	return 0;
}

Measured memory_bytes: 3576
using System;

class Program{
    class Node{
        public int key;
        public Node parent;
        public Node left;
        public Node right;
    }

    static void Insert(Node root, Node z){
        Node y=null;
        var x=root.left;
        while (x!=null) {
            y=x;
            if (z.key<x.key) {
                x=x.left;
            } else {
                x=x.right;
            }
        }
        z.parent=y;
        if (y==null) {
            root.left=z;
        } else if (z.key<y.key) {
            y.left=z;
        } else {
            y.right=z;
        }
    }

    static void WalkPreorder(Node node){
        Console.Write(" "+node.key);
        if(node.left!=null){
            WalkPreorder(node.left);
        }
        if(node.right!=null){
            WalkPreorder(node.right);
        }
    }

    static void WalkInorder(Node node){
        if(node.left!=null){
            WalkInorder(node.left);
        }
        Console.Write(" "+node.key);
        if(node.right!=null){
            WalkInorder(node.right);
        }
    }

    public static void Main(){
        var m=int.Parse(Console.ReadLine());
        var root=new Node();
        for (var i=0; i<m; i++) {
            var s=Console.ReadLine().Split(' ');
            if (s[0][0]=='i') {
                var node=new Node();
                node.left=null;
                node.right=null;
                node.key=int.Parse(s[1]);
                Insert(root, node);
            } else {
                WalkInorder(root.left);
                Console.WriteLine();
                WalkPreorder(root.left);
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 46468
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll mod=1000000007;
ll MOD=INF;


int main() {
  int n;
  cin >> n;
  int r=inf;
  vector<string> a(n);
  vector<pair<string,string>> mm(n);
  rep(i,n) cin >> a[i];
  rep(i,n) reverse(all(a[i]));
  vector<vector<int>> e(n,vector<int>(26,-1));
  rep(i,n){
      int w=a[i].size();
      r=min(r,w);
      string s;
      rep(j,a[i].size()){
          if (j==a[i].size()-1) mm[i]=mk(s,a[i]);
          s.push_back(a[i][j]);
      }
  }
  sort(all(mm));
  rep(i,n) a[i]=mm[i].second;
  rep(i,n){
      string s;
      rep(j,a[i].size()){
          e[i][a[i][j]-'a']=j;
      }
  }
  map<string,vector<char>> m;
  int ans=0;
  rep(i,n){
      string s="*";
      rep(j,a[i].size()+1){
          if (j>=r-1){
          auto it=m.find(s);
          if (it!=m.end()){
              rep(k,m[s].size()){
                if (e[i][m[s][k]-'a']>=j) {
                    ans++;
                }
              }
          }
          }
        //   rep(k,26){
        //       char y='a'+k;
        //       if (e[i][k]>=j) {
        //           auto it=m.find(mk(s,y));
        //           if (it!=m.end()) ans+=m[mk(s,y)];
        //           }
        //   }
          if (j==a[i].size()-1) m[s].push_back(a[i][a[i].size()-1]);
          if (j<a[i].size())s.push_back(a[i][j]);
      }
      
  }
  cout << ans << endl;
}


Measured memory_bytes: 65644
import collections
n = int(input())
arr = list(map(int,input().split()))
cnt = collections.defaultdict(int)
for val in arr:
    cnt[val] += 1
sums = sum(arr)
q = int(input())
for _ in range(q):
    b, c = map(int,input().split())
    diff = (c-b)*(cnt[b])
    sums += diff
    print(sums)
    cnt[c] += cnt[b]
    cnt[b] = 0


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

int main() {
    ll N, K;
    cin >> N >> K;
    ll A[N], F[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> F[i];
    sort(A, A + N);
    sort(F, F + N, greater<ll>());

    ll l = -1, r = 10e12;
    while (l + 1 < r) {
        ll mid = (l + r) / 2, sum = 0;
        rep(i, N) {
            sum += max(A[i] - mid / F[i], 0ll);
        }
        if (sum > K) l = mid;
        else r = mid;
    }
    cout << r << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
// cout<<"Case #"<<ts<<": “;
//priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;


using namespace std;

ll mod(ll x, ll m) {
	return (x % m + m) % m;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx, minn, temp, ans, flag, g, ts;
	ll mod = 1000000007;
	char ch, chh;
	double dans;
	string str, ttr;

	//cin >> t;


	for (ts = 1; ts <= t; ts++)
	{
		flag = 0; sum = 0; cnt = 0; ans = 0; k = 0; maxx = 0; minn = 0; a = 0; b = 0; temp = 0;

		cin >> x >> n;
		ll arr[n]; minn = 999999999999; ans = 9999999999;
		ll brr[102];

		memset(brr, 0, sizeof(brr));

		for (i = 0; i < n; i++)
		{
			cin >> arr[i];
			brr[arr[i]]++;

		}








		if (n == 0)
			cout << x;
		else if (x == 0)
			cout << -1;
		else
		{	minn = -1;
			for (i = x; i >= 0; i--)
			{
				if (brr[i] == 0)
				{
					minn = i;
					break;
				}
			}
			ans = abs(x - minn);


			for (i = x; i <= 101; i++)
			{
				if (brr[i] == 0)
				{
					maxx = i;
					break;
				}
			}

			sum = abs(x - maxx);


			if (sum < ans)
				cout << maxx;
			else
				cout << minn;
		}


		ln
	}
	return 0;
}


Measured memory_bytes: 3656
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n;
int ds[205][205];
int hs[205][205];

int getr(int t,int f){
	int c=0;
	if(t>=4){
		c=1-c; t=7-t;
	}
	if(f>=4){
		c=1-c; f=7-f;
	}
	int res;
	if((t+1)%3==f%3)res=6-t-f;
	else res=t+f+1;
	if(c==1)res=7-res;
	return res;
}

int main(void){
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		memset(hs,0,sizeof(hs));
		memset(ds,0,sizeof(ds));
		
		rep(qqq,n){
			int t,f;
			scanf("%d%d",&t,&f);
			int y=100,x=100;
			for(;;){
				bool rd=false;
				ireg(i,4,6){
					if(i==t || i==7-t)continue;
					int dy,dx,tt,tf;
					if(i==f || i==7-f){
						dx=0;
						if(i==f){
							dy=1; tt=7-f; tf=t;
						}
						else{
							dy=-1; tt=f; tf=7-t;
						}
					}
					else{
						dy=0;
						int r=getr(t,f);
						if(i==r){
							dx=1; tt=7-r; tf=f;
						}
						else{
							dx=-1; tt=r; tf=f;
						}
					}
					
					int ty=y+dy,tx=x+dx;
					if(hs[ty][tx]<hs[y][x]){
						y = ty; x = tx;
						t = tt; f = tf;
						rd=true;
						break;
					}
				}
				if(!rd){
					hs[y][x]++;
					ds[y][x]=t;
					break;
				}
			}
		}
		int anss[7];
		rep(i,7)anss[i]=0;
		rep(i,205)rep(j,205){
			anss[ds[i][j]]++;
		}
		reg(i,1,6)printf("%d%c",anss[i],i==6?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 1524
N,M = map(int,input().split())
ad = [[0]*N for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    a -= 1; b -= 1
    ad[a][b] = 1
    ad[b][a] = 1

ans = 0

def dfs(v=0,visited=[0]*N):
    visited[v] = 1
    if all(visited):
        global ans
        ans += 1
        return
    for nv, bit in enumerate(ad[v]):
        if bit == 0 or visited[nv] == 1: continue
        dfs(nv,visited[:])

dfs()
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
int main(){
	int n,a,t;int s;
	int ans;
	double minn=0x3f3f3f;
	scanf("%d %d %d",&n,&t,&a);
	for(int i=1;i<=n;i++){
		scanf("%d",&s);
		double tt=t-s*0.006;
		if(abs(tt-a)<minn){
			minn=abs(tt-a);
			ans=i;
		}
//		printf("%d\n",minn);
	}
	printf("%d\n",ans);
    return 0;
}

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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
#con = cmb(n,k,mod)
#print(con)
for i in range(min(k+1,n+1)):
    ans += cmb(n,i,mod)*cmb(n-1,i,mod)
    ans %= mod
    
print(ans)

Measured memory_bytes: 81008
open System
open System.Collections.Generic

module InputUtility =
    let InputTokens = new Queue<string>()

    let EnsureInput () =
        if InputTokens.Count = 0 then
            let input = Console.ReadLine ()
            let s = input.Split ([|' '|], StringSplitOptions.RemoveEmptyEntries)
            if s.Length > 0 then
                for x in s do InputTokens.Enqueue(x)
                true
            else false
        else true

    let rec ReadNext () =
        if EnsureInput () then InputTokens.Dequeue ()
        else ReadNext ()

    let ReadNextInt () = ReadNext () |> int

    let Read2Int () = ReadNextInt (), ReadNextInt ()

    let Read3Int () = ReadNextInt (), ReadNextInt (), ReadNextInt ()

    let ReadListOf f n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop ((ReadNext () |> f) :: acc) (c-1)
        loop [] n

    let MultipleCaseWithId f =
        let caseNum = ReadNextInt ()
        let rec loop index =
            if index = caseNum then ()
            else
                f index
                loop (index + 1)
        loop 0

    let MultipleCase f = MultipleCaseWithId (fun _ -> f ())

    let ReadList n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop (ReadNext () :: acc) (c-1)
        loop [] n

open InputUtility

module ARC083 =
    let private Mod = 1000000007L

    let private SugerWater () =
        let a, b, c = Read3Int ()
        let d, e, f = Read3Int ()
        let generate u x y =
            let arr = Array.create (u + 1) false
            let up d = if d <= u then arr.[d] <- true
            arr.[0] <- true
            for i in [0..u] do
                if arr.[i] then
                    up (i + x)
                    up (i + y)
            [0..u] |> Seq.where (fun i -> arr.[i]) |> Seq.toList
        let water = generate (f / 100) a b
        let suger = generate f c d |> Set.ofSeq
        let rec loop (n, d as r) = function
            | [] -> r
            | w :: h ->
                let cs = f - w * 100
                let ce = w * e
                let js =
                    [min cs ce .. -1 .. 0]
                    |> Seq.where suger.Contains
                    |> Seq.toArray
                let nr =
                    if js.Length = 0 then n, d
                    else
                        let s = js.[0]
                        let t = w * 100 + s
                        if s * n > d * t then t, s else n, d
                loop nr h
        let n, d = loop (a * 100, 0) water
        printfn "%d %d" n d

    let Entry = SugerWater

ARC083.Entry ()

Measured memory_bytes: 15068
#include <iostream>
#include <cmath>

int main()
{
  int a;
  std::cin >> a;
  int counter = 0;
  for (int i = 0; i < a; i++)
  {
    if ((int)std::floor(std::log10(i+1) + 1) % 2 != 0)
    {
      ++counter;
    }
    
  }
  std::cout << counter << "\n";
}

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

int main(void) {
    int count = 0;
    string W, T;
    cin >> W;

    for (int i = 0; i < W.size(); i++) W[i] = tolower(W[i]);

    while (true) {
        cin >> T;
        if (T == "END_OF_TEXT") break;
        for (int i = 0; i < T.size(); i++) T[i] = tolower(T[i]);
        if (W == T) count++;
    }
    cout << count << endl;

    return 0;
} 

Measured memory_bytes: 1192
//https://atcoder.jp/contests/abc166/tasks/abc166_d 
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<static_cast<ll>(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  ll X; cin>>X;
  unordered_map<ll,ll> vtbl;
  vector<ll> nums;
  {
    ll i=0;
    while(true){
      auto i5=i*i*i*i*i;
      if(i5<0) break;
      if(i5>LINF) break;
      vtbl[i5]=i;
      vtbl[-i5]=-i;
      nums.push_back(i5);
      nums.push_back(-i5);
      dump(i5);

      ++i;
    }
  }

  dump(nums.size())

  FOR(i,0,nums.size()){
    FOR(j,0,nums.size()){
      auto a5=nums[i];
      auto b5=nums[j];
      if(a5-b5==X){
        dump(a5,b5);
        cout<<vtbl[a5]<<" "<<vtbl[b5]<<endl;
        return 0;
      }
    }
  }
  assert(0);

  return 0;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[2][102];
	int s=0,t=-1,k;
	scanf("%s",a[1]);
	k=strlen(a[1]);
	for(int i=0;i<k;i++)
	{
		if(a[1][i]=='C')
		{
			s++;
			t=i;
			break;	
		}
	}
	for(int i=t;i<k;i++)
	{
		if(a[1][i]=='F')
		{
			s++;
			break;
		}
	}
	if(s==2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
class Shift_only:
  def __init__(self):
    self.counter = 0
    self.even = True
  
  def result_even(self):
    return self.even
  
  def result_counter(self):
    return self.counter

  def check_even_and_division(self, num_list):
    new_num_list=[]
    for i in num_list:
      new_num_list.append(i/2)
      if i%2 !=0:
        self.even = False
    return new_num_list
  
  def add_counter(self):
    self.counter +=1
    return self.counter

  
if __name__ == '__main__' :
  N = input()
  A=list(map(int, input().split()))
  shift_only=Shift_only()
  while shift_only.result_even():
    A = shift_only.check_even_and_division(A)
    if shift_only.result_even():
      shift_only.add_counter()
  print(shift_only.result_counter())

Measured memory_bytes: 38640
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

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

    cout << r * r << endl;
}

Measured memory_bytes: 256
let (a, b, n) = Scanf.sscanf (read_line ()) "%d %d %d" @@ fun a b n -> (float a, float b, float n)

let f x = int_of_float @@ floor (a *. x) /. b -. a *. floor (x /. b)

let () = Printf.printf "%d\n" @@ f @@ min (b -. 1.) n

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

int main() {
  int n,a,cnt,ans=0;
  cin >> n;
  for(int i=0 ;i<n ;i++){
    cin >> a;
    cnt = 0;
    while(a%2==0){
      a /= 2;
      cnt++;
    }
    ans += cnt;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n,k=map(int,input().split())
ans=[0 for _ in range(n)]

for i in range(k):
    d=int(input())
    tmp=list(map(int,input().split()))
    for j in tmp:
        ans[j-1]+=1

cnt=0
for i in ans:
    if i==0:
        cnt+=1

print(cnt)


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;

  int result = 0;
  for (int i = 1; i <= n; i++) {
    if (i <= k) {
      result += x;
    } else {
      result += y;
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scn = new Scanner(System.in);
    char[] str = scn.nextLine().toCharArray();
    if (str[0]<str[2])System.out.println("<");
    else if (str[0]>str[2])System.out.println(">");
    else System.out.println("=");
  }
}

Measured memory_bytes: 20948
use proconio::input;
use std::cmp::*;

fn dfs(depth: usize, m: usize, v: Vec<usize>) -> Vec<Vec<usize>> {
    if depth == v.len() {
        return vec![v];
    }

    let mut new_v: Vec<Vec<usize>> = Vec::new();
    let cur = v[v.len() - 1];

    for i in cur..=m {
        let mut next_v = v.clone();
        next_v.push(i);
        new_v.append(&mut dfs(depth, m, next_v));
    }

    new_v
}

fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        mut abcds: [[usize; 4]; q]
    };

    let mut ans = 0;
    let vecs = dfs(n, m, vec![1]);

    for v in vecs.iter() {
        let mut score = 0;
        for i in 0..q {
            let (a, b, c, d) = (abcds[i][0] - 1, abcds[i][1] - 1, abcds[i][2], abcds[i][3]);
            if v[b] >= v[a] && v[b] - v[a] == c {
                score += d;
            }
        }
        ans = max(ans, score);
    }
    println!("{}", ans);
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
#define inf (int)(1e8)
using namespace std;

int len = 200000;
long long n;
string sd = "RLUD";
vector<vector<vector<int>>> v, pl, mn;

int solve();

int main() {
  cin >> n;
  v.resize(4, vector(len + 1, vector<int>()));
  pl.resize(4, vector(2 * len + 1, vector<int>()));
  mn.resize(4, vector(2 * len + 1, vector<int>()));
  for (int i = 0; i < n; ++i) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    for (int j = 0; j < 4; ++j)
      if (c == sd[j]) {
        if (j < 2)
          v[j][y].push_back(x);
        else
          v[j][x].push_back(y);
        pl[j][x + y].push_back(x);
        mn[j][x - y + len].push_back(x);
      }
  }
  int res = solve();
  if (res == inf)
    cout << "SAFE" << endl;
  else
    cout << res << endl;
  return 0;
}

int solve() {
  int res = inf;
  for (int i = 0; i < 4; ++i)
    for (auto &vec : v[i]) sort(vec.begin(), vec.end());
  for (int i = 0; i <= len; ++i) {
    for (int ofst = 0; ofst < 2; ++ofst) {
      int ulen = v[ofst * 2][i].size(), dlen = v[ofst * 2 + 1][i].size();
      for (int uid = 0, did = 0; uid < ulen && did < dlen; ++uid) {
        while (did < dlen && v[ofst * 2][i][uid] > v[ofst * 2 + 1][i][did])
          ++did;
        if (did < dlen)
          res = min(res, (v[ofst * 2 + 1][i][did] - v[ofst * 2][i][uid]) * 5);
      }
    }
  }
  for (int i = 0; i <= 2 * len; ++i) {
    for (int j = 0; j < 4; ++j) {
      sort(pl[j][i].begin(), pl[j][i].end());
      sort(mn[j][i].begin(), mn[j][i].end());
    }
    int dlen = mn[3][i].size(), rlen = mn[0][i].size();
    for (int did = 0, rid = 0; did < dlen && rid < rlen; ++rid) {
      while (did < dlen && mn[0][i][rid] > mn[3][i][did]) ++did;
      if (did < dlen) res = min(res, (mn[3][i][did] - mn[0][i][rid]) * 10);
    }
    int ulen = mn[2][i].size(), llen = mn[1][i].size();
    for (int uid = 0, lid = 0; uid < ulen; ++uid) {
      while (lid < llen && mn[1][i][lid] < mn[2][i][uid]) ++lid;
      if (lid < llen) res = min(res, (mn[1][i][lid] - mn[2][i][uid]) * 10);
    }
    dlen = pl[3][i].size(), llen = pl[1][i].size();
    for (int did = 0, lid = 0; did < dlen && lid < llen; ++did) {
      while (lid < llen && pl[1][i][lid] < pl[3][i][did]) ++lid;
      if (lid < llen) res = min(res, (pl[1][i][lid] - pl[3][i][did]) * 10);
    }
    ulen = pl[2][i].size(), rlen = pl[0][i].size();
    for (int uid = 0, rid = 0; uid < ulen && rid < rlen; ++rid) {
      while (uid < ulen && pl[2][i][uid] < pl[0][i][rid]) ++uid;
      if (uid < ulen) res = min(res, (pl[2][i][uid] - pl[0][i][rid]) * 10);
    }
  }
  return res;
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int N;
using ll = long long;
vector<ll> A;

ll f(ll m) {
    ll ans = 0;
    rep(i, N) ans += m % A[i];
    return ans;
}

int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;
    rep(i, N) ans += A[i];
    cout << ans - N << endl;

    return 0;
}


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

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

	long long int l[2] = {2, 1};
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			l[0] = l[0] + l[1];
		} else {
			l[1] = l[1] + l[0];
		}
	}
	long long int ans;
	if (n % 2 == 0) {
		ans = l[0];
	} else {
		ans = l[1];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
// B.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	int N, T, A,kouho=0,mixed;
	double points[1000];
	cin >> N;
	cin >> T;
	cin >> A;
	A += 273;
	T += 273;
	for (int i = 0; i < N; i++) {
		cin >> points[i];
		points[i] *= 0.006;
		points[i] = T - (points[i]+273);
		points[i] += 273;
		//cout << points[i] << endl;
	}
	//cout << mixed<<endl;
	//cout << A - 273 << " " << abs(T - points[kouho]) << endl;
	for (int i = 1; i < N; i++)
	{
		if (abs(A- points[i]) < abs(A - points[kouho]))
			kouho = i;
	//	cout << A-273 << " " << abs(T - points[i]) << endl;
	}
	
	cout << kouho+1;
    return 0;
}



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

int main(){
  int N; cin >>N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    int x; cin >>x;
    L[i] = x;
  }
  
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());
  
  int ans = 0;
  
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=j+1;k<N;k++){
        if(L[i] < L[j]+L[k]) ans ++;
      }
    }
  }
  
  cout << ans << endl;
}

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

int main() {
	string s;
	cin >>s;
	int a=0;
	for(int i=0; i<s.length();i++){
		a+=s[i]-'0';
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,t,ans=0,sum=0;
    cin >>n;
    vector<vector<int>> f,p;
    for(int i=0;i<n;i++){
        vector<int> v;
        for(int j=0;j<10;j++){
            cin >> t;
            v.push_back(t);
        }
        f.push_back(v);
    }
    for(int i=0;i<n;i++){
        vector<int> v;
        for(int j=0;j<11;j++){
            cin >> t;
            v.push_back(t);
        }
        p.push_back(v);
    }
    for(int i=1;i<1024;i++){
        t=i;
        int k=0;
        sum=0;
        vector<int> tmp(n,0);
        //cout << i<<endl;
        while(t){
            if(t%2){
                for(int l=0;l<n;l++){
                    if(f[l][k]){
                        tmp[l]++;
                    }
                }
            }
            t/=2;
            k++;
            //cout << i<<" "<<k<<endl;
        }
        for(int l=0;l<n;l++){
            sum+=p[l][tmp[l]];
        }
        if(i==1){
            ans=sum;
        }
        ans=max(ans,sum);
    }
    cout << ans;
}


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

using namespace std;

const int mod = int(1e9) + 7;

void show(vector<int> v) {
	for (auto x: v) {
		cout << x << " ";
	}
	cout << endl;

}

int main() {
	int n, m;
	cin >> n >> m;

	vector<int> s(n), t(m);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}


	vector<vector<long long>> dp(n + 1, vector<long long>(m + 1, 0));
	auto sum = dp;

	for (int i = 0; i < n; i++) { sum[i][0] = 1;}
	for (int i = 0; i < m; i++) { sum[0][i] = 1;}
	dp[0][0] = 1;

	long long ans = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i] == t[j]) {
				dp[i+1][j+1] = sum[i][j];
				ans = (ans + dp[i+1][j+1]) % mod;
			}

			sum[i+1][j+1] = (sum[i+1][j] + sum[i][j+1] - sum[i][j] + mod + dp[i+1][j+1]) % mod;
			// printf("ij %d %d, sum %lld + %lld - %lld + %lld = %lld\n", i, j, sum[i+1][j], sum[i][j+1], sum[i][j], dp[i+1][j+1], sum[i+1][j+1]);
		}
	}

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


Measured memory_bytes: 62976
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<int> a(n);

    int ans = 0;
    vector<int> b(n+1);
    for(int i = 0;i < n;i ++){
        cin >> a[i];
        b[a[i]] ++;
    }


    for(int i = 1;i < n+1;i ++){
        ans += b[i] * (b[i] - 1) / 2;
    }

    for(int i = 0;i < n;i ++){
        int t = b[a[i]];
        cout << ans - t * (t-1) / 2 + (t-1) * (t-2) /2 << endl;
    }
}



Measured memory_bytes: 5760
#include <iostream>
#include <cstring>
#include <queue>
using namespace std; 
#define maxn 100010
int n = 0;
int cnt = 0;
int dis[maxn][2];
int vis[maxn];
int head[maxn];
struct Edge
{
     int next;
     int to;
}edge[maxn * 2];

void add(int u,int v)
{
    edge[cnt].to = v;
    edge[cnt].next = head[u];
    head[u] = cnt++;
}
void bfs(int start,int id){
	queue<int > q;
	q.push(start);
	vis[start] = 1;
	dis[start][id] = 0;
	while(!q.empty()){
		int now = q.front();
		q.pop();
		for(int i = head[now];i!=-1;i = edge[i].next){
			if(!vis[edge[i].to]){
				vis[edge[i].to] = 1;
				dis[edge[i].to][id] = dis[now][id] + 1;
				q.push(edge[i].to);
			}
		}
	}
} 
int main(){
	cin>>n;
	memset(head,-1,sizeof(head));
	memset(vis,0,sizeof(vis));
	memset(dis,0,sizeof(dis));
	for(int i = 0;i < n-1;i++){
		int f,t;
		cin>>f>>t;
		add(f,t);
		add(t,f);
	}
	bfs(1,0);
	memset(vis,0,sizeof(vis));
	bfs(n,1);
	int x=0, y=0;
    for(int i=1;i<=n;i++){
        if(dis[i][0]<=dis[i][1])x++;
        else y++;
    }
    if(x>y)cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << "\n";
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<ll> x(n), y(m);
    for (int i=0; i<n; ++i) cin >> x.at(i);
    for (int i=0; i<m; ++i) cin >> y.at(i);

    ll sumX = 0, sumY = 0;
    for (ll i=1; i<n; ++i) {
        sumX += (x.at(i) - x.at(i-1)) * i * (n-i);
        sumX %= MOD;
    }
    for (ll i=1; i<m; ++i) {
        sumY += (y.at(i) - y.at(i-1)) * i * (m-i);
        sumY %= MOD;
    }
    cout << sumX * sumY % MOD << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
	char x;
	int i,j,k,a[27]={0},count2=97;
	while(x!=EOF){
		x=getchar();
		if((x>='A'&&x<='Z')||(x>='a'&&x<='z')){
			for(j='A';j<='Z';j++){
				if(j==x)a[j-65]++;
			}
			for(k='a';k<='z';k++){
				if(k==x)a[k-97]++;
			}
		}
	}
	for(i=0;i<26;i++){
		printf("%c : %d\n",count2,a[i]);
		count2++;
	}
	return 0;
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define SP << " " <<
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, A, B;
  cin >> N >> A >> B;
  int ans = min(A * N, B);
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
  int N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  int res = 0;
  for (int i = 0; i < N; ++i) {
    if (T[i] == 'r') {
      res += P;
      if (i + K < N && T[i + K] == 'r') {
        T[i + K] = 'x';
      }
    }
    if (T[i] == 's') {
      res += R;
      if (i + K < N && T[i + K] == 's') {
        T[i + K] = 'x';
      }
    }
    if (T[i] == 'p') {
      res += S;
      if (i + K < N && T[i + K] == 'p') {
        T[i + K] = 'x';
      }
    }
  }
  printf("%d\n", res);
}

Measured memory_bytes: 3376
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>

/*
 *変数
 */
int a[3];

/*
 *解 
 */
void solve(){
    std::sort(a,a+3,std::greater<>());
    printf("%d",a[0]*10+a[1]+a[2]);
}

/*
 *入力 
 */
int main(){
       std::cin.tie(0);
       std::ios::sync_with_stdio(false);
       std::cin>>a[0]>>a[1]>>a[2];
       solve();
       return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 101001;//ここを問題の制約を見ながらいじる．配列の確保に使う．
//int A[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．

// Main program
void solve() {
    string C;
    cin >> C;

    char c = C[0]+1;


    cout << c;

    return;

}

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







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;


int main(){
	string s;
	cin >> s;
	for(int i = 0; i<3; i++) if (s[i] == s[i+1]) {puts("Bad"); return 0;}
	puts("Good");
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
from functools import lru_cache
from itertools import chain

@lru_cache(None) # 再帰にしつつ、下から計算することで再帰処理をしない
def subsets(U): # O(2^k)
    # base case
    if U == 0:
        return (0,)
    # recursion
    d = U.bit_length() - 1
    U ^= 1 << d
    prev = subsets(U)
    return tuple(chain(prev, [U | 1 << d for U in prev]))


def resolve():
    n = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(n))

    # O(n^2 * 2^n)
    state_to_score = [0] * (1 << n)
    for U in range(1 << n):
        for i in range(n):
            if (U >> i) & 1 == 0:
                continue
            for j in range(i):
                if (U >> j) & 1:
                    state_to_score[U] += A[i][j]

    # dp[i][U] : i まで見て U <= {1, ..., n} を grouping したときの max
    # msb(U) = i ならば dp[i][U] = dp[i + 1][U] = ... = dp[n - 1][U] なので dp は使いまわせる
    # dp[i + 1][U | 1 << (i + 1)] = max((V + {i + 1} の score) + dp[i][W]) for all V + W = U
    dp = [-INF] * (1 << n)
    dp[0] = 0
    for i in range(n): # 既に U = 0, ..., 2^i - 1 までは確定している
        for U in range(1 << i): # O(2^i) これから 2^i, ..., 2^(i + 1) - 1 を確定させる
            for V in subsets(U): # O(2^k) where k = popcount(U)
                W = U ^ V
                dp[U | 1 << i] = max(dp[U | 1 << i], state_to_score[V | 1 << i] + dp[W])

    print(dp[-1])
resolve()

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

int main(){
  int k,s;
  cin>>k>>s;
  int ans;
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
      if(s-x-y>=0 && s-x-y<=k){
        ans++;}
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 1e5+10;
int n,a[MAXN];
int main (){
	scanf("%d",&n);
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1,greater<int>());
	for(int i = 1;i <= n;i++){
		if(i+1 > a[i+1]){
			int j = 0;
			for(;a[i+1+j] == i;j++);
			if((j&1)||(a[i]-i)&1) printf("First");
			else printf("Second");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3596