akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int fx[]={1,-1,0,0},fy[]={0,0,1,-1};
struct node{
	int x,y;
};
int n,m,ans=0;
int d[25][25];
char p[25][25];
bool vis[25][25];
queue<node> q;
int main(){
	memset(p,0x3f,sizeof(p));
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>p[i][j];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(p[i][j]=='#') continue;
			memset(d,0,sizeof(d));
			memset(vis,0,sizeof(vis));
			q.push((node){i,j});
			vis[i][j]=1;
			while(!q.empty()){
				node no=q.front();
				q.pop();
				for(int k=0;k<4;k++){
					int nx=no.x+fx[k],ny=no.y+fy[k];
					if(nx<n&&ny<m&&nx>=0&&ny>=0&&p[nx][ny]=='.'&&!vis[nx][ny]){
						vis[nx][ny]=1;
						d[nx][ny]=d[no.x][no.y]+1;
						ans=max(d[nx][ny],ans);
						q.push((node){nx,ny});
					}
				}
			}
		}
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, t string
	fmt.Scan(&n, &t)
	w := n
	for i := 0; i < len(n); i++ {
		w = w[(len(n)-1):] + w[0:(len(n)-1)]
		if w == t {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	k := io.NextInt()
	pow := 1
	num := 7
	history := map[int]struct{}{}
	for {
		if _, ok := history[num]; ok {
			io.Println(-1)
			return
		}
		history[num] = struct{}{}
		if num%k == 0 {
			break
		}
		pow = 10 * pow % k
		num += 7 * pow % k
		num %= k
	}
	io.Println(len(history))
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

using namespace std;

struct UnionFind {
	//d < 0 ならサイズの絶対値,d>= 0なら根の番号

	vector<int> d;
	UnionFind(int n) {
		d.resize(n, -1);
	}

	int find(int x) {
		if (d[x] < 0) return x;
		return d[x] = find(d[x]); //根を更新して戻す
	}

	bool unite(int x, int y) {
		x = find(x); y = find(y); //根とってくる
		if (x == y) return false;
		if (d[x] > d[y]) {
			int t;
			t = d[x];
			d[x] = d[y];
			d[y] = t;
		}
		//-d[x] > -d[y]となっている
		d[x] += d[y];
		d[y] = x;
		return true;
	}

	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d[find(x)]; }
};

int main() {
	int N, M, K;

	cin >> N >> M >> K;
	vector<int>deg(N + 1, 0);
	vector<vector<int>> blist(N + 1, vector<int>());

	UnionFind un(N + 1);

	//友達情報取得＆設定
	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;
		deg[a]++;
		deg[b]++;
		un.unite(a, b);
	}
	//ブロッキングペア取得&設定
	for (int i = 0; i < K; i++)
	{
		int c, d;
		cin >> c >> d;
		blist[c].push_back(d);
		blist[d].push_back(c);
	}

	//答え出力
	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		ans = un.size(i) - 1 - deg[i];
		//ブロッキングペアを除く
		for (int p : blist[i])
		{
			if (un.same(i, p)) ans--;
		}

		cout << ans << " ";
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  vector<int> dp(n + 1, INT_MAX);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= k; ++j) {
      if (i + j < n) {
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
      }
    }
  }
  cout << dp[n-1] << '\n';
  return 0;
}



Measured memory_bytes: 3980
N,M=map(int,input().split())

ng_dic={}
for i in range(M):
  a,b=map(int,input().split())
  if not a in ng_dic:
    ng_dic[a]=b
  else:
    ng_dic[a]=min(b,ng_dic[a])
    
ng_dic=sorted(ng_dic.items())
#print(ng_dic)

answer=0
right=N+1
for key,value in ng_dic:
  #print(key,value)
  right=min(right,value)
  #print(key,right)
  if key>=right:
    answer+=1
    right=value
  
print(answer+1)

Measured memory_bytes: 22624
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    set<ll> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size() << endl;
    return 0;
}


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

int main() {
    long long x;
    cin >> x;

    for(long long a=-200; a<=200; a++){
        for(long long b=-200; b<=200; b++){
            if(((a*a*a*a*a) - (b*b*b*b*b))== x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

#define ll long long
#define D double
#define pb push_back
#define For(i,x,z) for(ll i=x;i<z;i++)
#define RFor(i,x,z) for(ll i=x;i>=z;i--)

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return (POW(B,P/2))*(POW(B,P/2));}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/__gcd(a,b));}

int main()
{
    string s;
    cin>>s;
    ll p=1,n=0,cnt=0;
    map<ll,ll>m;
    m[0]++;
    RFor(i,s.size()-1,0)
    {
       n+=(s[i]-'0')*p;
       n%=2019;
       p*=10;
       p%=2019;
       //cout<<n<<endl;2
       cnt+=m[n];
       m[n]++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
using Graph = vector<vector<int>>;
const int limit = 50;

bool visited[limit];

//辺のつながり管理
bool graph[limit][limit];

//頂点集合
int a[limit];
int b[limit];

int n,m;
//深さ優先探索
void dfs(int v){

    visited[v] = true;
    for(int v2=0;v2 < n;v2++){
        if(graph[v][v2] == false) continue;
        if(visited[v2] == true) continue;
        dfs(v2);
    }
}


int main() {

    cin >> n >> m;
    
    //データの作成
    for(int i=0;i < m;i++){

        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;

    }

    int ans =0;
    //取り除いて非連結になるか
    for(int i=0;i < m;i++){

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        //memset(visited,0,sizeof(visited));
        for (int j = 0; j < n; ++j) visited[j] = false;
        dfs(0);
        bool exist = false;
        for(int i=0;i < n;i++) if(visited[i] == false) exist = true;
        if(exist) ans++;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;

    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
/**
 *  author: Behradm
 *  Created: 2020.08.02 16:24:10
 *  In The Name Of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  int res = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    res += (sqrt((double) x * x + (double) y * y) <= (double) d);
  }

  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3692
#include<cstdio>
int main(){
  int n,i;
  scanf("%d",&n);
  int a[n];
  for(i = 0;i < n; i++){
    scanf("%d",&a[i]);
  }
  for(i = n-1;i >=0;i--){
    if(i != 0){
    printf("%d ", a[i]);
  }else{
    printf("%d\n",a[i]);
  }
  }
return 0;
}


Measured memory_bytes: 2704
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();
            int sum = 1;
            int mmm = 0;
            int a = cin.NextInt();
            int b = cin.NextInt();

            while (sum < b)
            {
                sum += a-1;
                mmm++;

            }
            Console.WriteLine(mmm);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

struct Point {
    Point(ll x, ll y, ll id) : x(x), y(y), id(id) {}
    Point() : Point(0, 0, 0) {}
    void read(ll i) { id = i; cin >> x >> y; }
    ll x, y, id;
    Point operator+=(const Point& other) { x += other.x; y += other.y; return *this; }
    Point operator+(const Point& other) { Point ans = *this; return ans += other; }
    Point operator-=(const Point& other) { x -= other.x; y -= other.y; return *this; }
    Point operator-(const Point& other) { Point ans = *this; return ans -= other; }
    ll norm2() const { return x * x + y * y; }

    int type() const {
        return x < 0 || (x <= 0 && y < 0);
    }
};

bool operator<(const Point &a, const Point &b) {
    if (a.type() != b.type()) {
        return a.type() < b.type();
    }
    ll cp = a.x * b.y - a.y * b.x;;
    if (abs(cp) > 0) {
        return cp > 0;
    }
    return a.id < b.id;
}

int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll n;
    cin >> n;
    vector<Point> ps(n);
    Point sum;
    for (ll i = 0; i < n; ++i) {
        ps[i].read(i);
        sum += ps[i];
    }
    sort(ps.begin(), ps.end());
    ll ans = 0;
    for (ll l = 0; l < n; ++l) {
        for (ll r = l; r <= n; ++r) {
            Point p;
            for (ll i = l; i < r; ++i) {
                p += ps[i];
            }
            ans = max(ans, p.norm2());
            ans = max(ans, (sum - p).norm2());
        }
    }
    cout << sqrt(ans) << endl;

    return 0;
}


Measured memory_bytes: 256
s = raw_input()
n = int(raw_input())
for i in range(n):
    tmp = raw_input().split()
    tmp[1] = int(tmp[1])
    tmp[2] = int(tmp[2])
    if tmp[0] == "replace":
        s = s[:tmp[1]] + tmp[3] + s[tmp[2]+1:]
    elif tmp[0] == "reverse":
        s = s[:tmp[1]] + s[tmp[2]:tmp[1]:-1] + s[tmp[1]] + s[tmp[2]+1:]
    else:
        print s[tmp[1]:tmp[2]+1]


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back

#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RepA(x) for(auto a : (x))
#define output_s(a) printf("%s\n",(a).c_str())

//library----------------------------------------------

#define NMAX 200000

int main(){
    int N;cin>>N;
    int A[NMAX];
    map<int,ll> mp;
    rep(i,N) {
        cin>>A[i];
        mp[A[i]]++;
    }
    ll sum=0;
    RepA(mp) sum+=(a.second*(a.second-1))/2;
    rep(i,N){
        ll ans = sum;
        ans -= (mp[A[i]]-1);
        printf("%lld\n",ans);
    }    
    return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, ans=0; cin>>N;
  vector<ll> A(N), B(N), C(N);
  
  rep(i, N) cin>>A[i];
  rep(i, N) cin>>B[i];
  rep(i, N )cin>>C[i];
  
  sort(ALL(A));
  sort(ALL(C));
  
  rep(i, N){
    ll cnt = upper_bound(ALL(A), B[i]-1) - A.begin(), cnt2 = C.end() - lower_bound(ALL(C), B[i]+1);
    ans += cnt * cnt2;
  }
  
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a){
        cout << k << endl;
    }else if(k<=a+b){
        cout << a << endl;
    }else{
        cout << a-(k-a-b) << endl;
    }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main () {
  long H, W;
  cin >> H >> W;
  if ((H * W) % 3 == 0) {
    cout << 0 << endl;
    return 0;
  }
  long a, ans = 10000000000;
  long one, two, three;
  if(H > 3) ans = min(ans, H);
  if(W > 3) ans = min(ans, W);
  for(int i = 1; i < H; i++) {
    one = W * i;
    two = (H - i) * (W / 2), three = (H - i) * (W - W / 2);
    a = max(one,max(two, three)) - min(one,min(two, three));
    ans = min(ans, a);
  }
  swap(H,W);
  for(int i = 1; i < H; i++) {
    one = W * i;
    two = (H - i) * (W / 2), three = (H - i) * (W - W / 2);
    a = max(one,max(two, three)) - min(one,min(two, three));
    ans = min(ans, a);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef complex<int> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()

int m, res = 0;
VP ps;

bool isParallel(Point a, Point b){
    return a.Y * b.X == a.X * b.Y;
}

void solve(vector<bool> &used, VP &vs){

    if((int)vs.size() == m/2){
        int cnt = 0;
        rep(i,m/2)rep(j,i){
            if(isParallel(vs[i],vs[j])) cnt++;
        }
        res = max(res,cnt);
        return;
    }

    rep(i,m)if(!used[i]){
        used[i] = true;
        rep(j,m)if(!used[j]){
            vs.push_back(ps[i]-ps[j]);
            used[j] = true;
            solve(used,vs);
            vs.pop_back();
            used[j] = false;
        }
        used[i] = false;
        return;
    }
}

int main(void){
    cin>>m;
    ps.resize(m);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        ps[i] = Point(x,y);
    }
    vector<bool> used(m);
    VP vs;
    solve(used,vs);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3096
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, M = map(int, readline().split())
    C = list(map(int, readline().split()))
    # dp[i] := i円払うのに必要な枚数
    dp = [INF] * (N+1)
    dp[0] = 0
    for c in C:
        if c<=N:
            for i in range(N-c+1):
                dp[i+c] = min(dp[i]+1, dp[i+c])
    print(dp[N])


if __name__ == '__main__':
    main()




Measured memory_bytes: 7512
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = Read();
        int[] h = Read(n);
        int p=0; int m=0;
        for(int i=0;i<n;i++){
            if(h[i]>=m){p++; m=h[i];}
        }
        Write(p);
    }

    static void Write(string s) { Console.WriteLine(s); return; }
    static void Write(int n) { Console.WriteLine(n.ToString()); return; }
    static int Read() { return int.Parse(Console.ReadLine()); }
    static int[] Read(int n)
    {
        int[] p = new int[n];
        string[] t = Console.ReadLine().Split(' ');
        for(int i = 0; i < n; i++) { p[i] = int.Parse(t[i]); }
        return p;
    }
    static int abs(int n) { return (n > 0) ? n : -n; }
    static int gcd(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = gcd(p, n[i]); } return p; }
    static int gcd(int a, int b) { return (a==0)?b:gcd(b % a, a); }
    static int lcm(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = lcm(p, n[i]); } return p; }
    static int lcm(int a, int b) { return a * b / gcd(a, b); }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define All(A) A.begin(),A.end()
#define RAll(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<double,double> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;


int main(){
    int a,b;
    cin >> a >> b;
    if(a<=8&&b<=8) puts("Yay!");
    else puts(":(");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[100010], b[100010];
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    int exceed = 0, lack = 0;
    vector<int> v;
    int ans1 = 0;
    rep(i, n) {
        if(a[i] > b[i]) {
            exceed += a[i] - b[i];
            v.push_back(a[i] - b[i]);
        }
        else if(a[i] < b[i]) {
            lack += b[i] - a[i];
            ans1++;
        }
    }
    if(lack > exceed) {cout << -1 << endl; return 0;}
    int ans2 = 0;
    sort(v.begin(), v.end(), greater<int>());
    while(lack > 0) {
        lack -= v[ans2++];
    }
    cout << ans1 + ans2 << endl;
    


    return 0;
}


Measured memory_bytes: 5380
#include <cstdio>

const int N=100005;

int fst[N],a[N],cnt[3],tot=0,num;
bool flag;

struct Edge{
	int to,v,nxt;
}e[N*2];

void addedge(int x,int y){
	e[++tot].to=y;e[tot].v=1;e[tot].nxt=fst[x];fst[x]=tot;
	e[++tot].to=x;e[tot].v=-1;e[tot].nxt=fst[y];fst[y]=tot;
}

void dfs(int x){
	cnt[a[x]]++;
	for (int i=fst[x];i;i=e[i].nxt){
		int y=e[i].to,z=(a[x]+e[i].v+3)%3;
		num++;
		if (a[y]==-1){
			a[y]=z;
			dfs(y);
		}
		else if (a[y]!=z) flag=1;
	}
}

int main(){
	int n,m;
	scanf("%d%d\n",&n,&m);
	for (int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d\n",&x,&y);
		addedge(x,y);
	}
	for (int i=1;i<=n;i++) a[i]=-1;
	long long ans=0;
	for (int i=1;i<=n;i++)
	if (a[i]==-1){
		for (int j=0;j<3;j++) cnt[j]=0;
		flag=0;a[i]=num=0;dfs(i);
		if (flag) ans+=1ll*(cnt[0]+cnt[1]+cnt[2])*(cnt[0]+cnt[1]+cnt[2]);
		else if (!cnt[0] || !cnt[1] || !cnt[2]) ans+=num/2;
		else for (int i=0;i<3;i++) ans+=1ll*cnt[i]*cnt[(i+1)%3];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 6400
#include<stdio.h>

int main(void){
	int i, time=0;
	int syou=1000000007;
	//sumを上5桁と下5桁で分割して管理する
	unsigned long long sum=1;

	
	scanf("%d", &time);
	for(i = 0 ; i < time ; i++){
		sum = sum * (i+1);
		sum = sum%syou;
	}
	printf("%d", sum);
	
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll dp[101][100100];

void solve(istream& cin, ostream& cout) {
  int n, W;
  cin >> n >> W;
  vector<ll> w(n), v(n);
  REP(i, n) cin >> w[i] >> v[i];
  dp[n][0] = 0;
  RREP(i, n) REP(j, W + 1) {
    if (j < w[i]) dp[i][j] = dp[i + 1][j];
    else
      dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
  }
  cout << dp[0][W] << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 78464
#include<cstdio>
int main(){
  int h=1,i;
  int a[4]={10,50,100,500};
  int n;
  while(scanf("%d",&n),n){
    int b[4],c[4]={};
    int sm=-n;
    for(i=0;i<4;++i){
      scanf("%d",b+i);
      sm+=a[i]*b[i];
    }
    for(i=3;i>=0;--i){
      c[i]+=sm/a[i];
      sm-=sm/a[i]*a[i];
    }
    if(h)
      h=0;
    else
      puts("");
    for(i=0;i<4;++i){
      if(b[i]>c[i])
    printf("%d %d\n",a[i],b[i]-c[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,o,p,q;
    while(cin>>m>>n>>o>>p)
    {
        if(m+n>o+p)
            cout<<"Left"<<endl;
        else if(m+n<o+p)
            cout<<"Right"<<endl;
        else
            cout<<"Balanced"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
const ll MAXN=1;
string s;
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
int main()
{
	cin>>s;
	for(register int i=0;i<s.length();i++)
	{
		putchar('x');
	}
	puts("");
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  vector<int> nums;
  int now = 1;//まず1を見る
  int cnt = 0;
  for (int i = 0; i < n; i++)
  {
    if (s.at(i) == (char)('0' + now))//今見てる数ならcnt++
      cnt++;
    else
    {
      nums.push_back(cnt);
      now = 1 - now;//次の数を数える
      cnt = 1;
    }
  }
  if (cnt != 0)
  {
    nums.push_back(cnt);
  }
  if (nums.size() % 2 == 0)
    nums.push_back(0);

  int add = 2 * k + 1;

  //累積和を作る
  vector<int> sum(nums.size() + 1);
  for (int i = 0; i < nums.size();i++){
    sum.at(i + 1) = sum.at(i) + nums.at(i);
  }

  int ans = 0;

  for (int i = 0; i < nums.size();i+=2){

    int left = i;
    int right = min(i + add, (int)nums.size());
    int temp = sum.at(right) - sum.at(left);

    ans = max(temp, ans);
  }

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

Measured memory_bytes: 1272
#include"bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())

int main() {
	int N, Y;
	cin >> N >> Y;
	for (int i = 0;i <= N;++i) {
		for (int j = 0;j <= N - i;++j) {
			int k = N - i - j;
			if (0 <= k && k <= N) {
				if (10000 * i + 5000 * j + 1000 * k == Y) {
					printf("%d %d %d\n", i, j, k);
					return 0;
				}
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 256
/* ex 3-3
    kas056*/
#include <stdio.h>
int main(void){
    int n , k ;
    // n,kの読み込み
    scanf("%d %d", &n, &k);

    //何乗したかのカウンターiとその時点の数値tを用意
    int i = 1;
    int t = k;

    //k進法の桁数はk^i>nとなるようなiに決まるので、そのiになるまでtにkを掛けていく
    while (t <= n){
        t *= k;
        i += 1;
    }
    //iを出力
    printf("%d",i);
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 18;

int n;
int best[1<<N][3];

void insert(int mask, int val){
    auto a = best[mask];
    a[2] = val;
    if (a[2] > a[1]) swap(a[2], a[1]);
    if (a[1] > a[0]) swap(a[1], a[0]);
}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    forn(i,1<<n) {
        int x; cin >> x;
        insert(i,x);
    }
    forn(i,n) {
        forn(mask, 1<<n) if ((mask>>i)&1) {
            int nmask = mask - (1<<i);
            forn(j,2) insert(mask, best[nmask][j]);
        }
    }


    for (int k = 2; k <= (1<<n); k++) {
        int ans = 0; 
        forn(i,n+1) if ((k>>i)&1) {
            int nk = (((k>>i) - 1) << i) + (1<<i) - 1;
            ans = max(ans, best[nk][0] + best[nk][1]);
        }
        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 6728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = a + b;
		if(c >= 10) {
			System.out.println("error");
		} else {
			System.out.println(c);
		}
	}
}

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

int main() {
  char S[100010];
  scanf("%s", S);
  int len = strlen(S);

  int ans1 = 0, ans2 = 0;
  for (int i = 0; i < len; i++) {
    if (i % 2 == S[i] - '0') {
      // 黒色スタート時の塗り替え数を検証
      ans1++;
    } else {
      // 白色スタート時の塗り替え数を検証
      ans2++;
    }
  }

  printf("%d", min(ans1, ans2));
  return 0;
}


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

int main(){
  set<int> S;
  
  int N,x;
  cin >> N;
  
  for(int i=0;i<N;i++){
    cin >> x;
    S.insert(x);
  }
  
  cout << S.size() << endl;
}

Measured memory_bytes: 256
#include <iostream>

#define ll long long
#define db(x) cout << "> " << #x << " : " << x << endl;

using namespace std;

int a[4];

void print(int i, int j, int k)
{
	cout << a[0];
	
	if(i == 0)
		cout << "+";
	
	else
		cout << "-";
	
	cout << a[1];
	if(j == 0)
		cout << "+";
	
	else
		cout << "-";
	
	cout << a[2];
	if(k == 0)
		cout << "+";
	
	else
		cout << "-";
	
	cout << a[3] << "=7\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin >> s;
	
	for(int i = 0; i < 4; i++)
		a[i] = s[i] -'0';
	
	for(int i = 0; i < 2; i++)
	{
		int aa = a[0], bb, cc, dd;
		
		if(i == 0)
			bb = a[1];
		
		else
			bb = -a[1];
			
		for(int j = 0; j < 2; j++)
		{
			if(j == 0)
				cc = a[2];
			
			else
				cc = -a[2];
			
			for(int k = 0; k < 2; k++)
			{
				if(k == 0)
					dd = a[3];
				
				else
					dd = -a[3];
				
				if(aa +bb +cc +dd == 7)
				{
					print(i, j, k);
					return 0;
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,a[100005],b[100005],ok;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",a+i),a[i]=-a[i];
    sort(a+1,a+n+1);
    for(int i=n;i;--i)a[i]=-a[i],b[i]=(a[i]==a[i+1])?b[i+1]+1:1;
    for(int i=1;i<=n;++i){
        if(i>a[i+1]&&i<=a[i]&&(i&1)==(a[i]&1))ok=1,i=n+1;
        if(i==a[i]&&(b[i]&1))ok=1,i=n+1;
        if(i==a[i+1]&&!(b[i+1]&1)&&(i&1)==(a[i]&1))ok=1,i=n+1;
    }
    if(ok)puts("Second");
    else puts("First");    
    //system("pause");
    return 0;
}


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

int main(){

    int n;
    int sum=0;
    cin>>n;
    vector<int> d(n);
    for(int i=0;i<n;i++) cin>>d.at(i);

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum+=d.at(i)*d.at(j);
        }
    }

    cout<<sum<<endl;








    return 0;
}

Measured memory_bytes: 256
n,k=map(int, input().split())  
P=list(map(int, input().split()))
import numpy as np
Px=np.array([(P[i]+1)/2 for i in range(n)])
Pcum=np.cumsum(Px)
Pcum=np.insert(Pcum,0,0)
ans=0
for i in range(k,n+1):
    ans=max(ans, Pcum[i]-Pcum[(i-k)])
print(ans)

Measured memory_bytes: 29176
#include <bits/stdc++.h>
#include <string.h>
#include <numeric>

using namespace std;

///////////////////////////////////////////
//const long long int INF = 1000000000000000000LL;
const long long int INF = 1000000;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<=former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(    v[0])>()) //降順でVをソート
///////////////////////////////////////////

vi v;
ll box[100001]={0};
ll box2[100001]={0};

int main(){
    ll n,a;cin>>n;
    ll a1=0,a2=0;
    ll b1=0,b2=0;
    rep(i,n){
        cin>>a;
        v.pb(a);
        if(i%2==0){
            box[a]++;
        }else{
            box2[a]++;
        }
    }
    ll max1=0,max2=0;
    rep(i,100001){
        if(chmax(max1,box[i])){a2=a1;a1=i;}
        if(chmax(max2,box2[i])){b2=b1;b1=i;}
    }
    ll ma1=0,ma2=0;
    if(a2==a1){
        ll ma1=0,ma2=0;
        if(b2==b1){
            rep(i,100001){
                if(box[a1]>box[i] && chmax(ma1,box[i]))a2=i;
                if(box2[b1]>box[i] && chmax(ma2,box2[i]))b2=i;
            }
        }else{
            rep(i,100001){
                if(box[a1]>box[i] && chmax(ma1,box[i]))a2=i;
            }
        }
    }else{
        if(b2==b1){
            rep(i,100001){
                if(box2[b1]>box[i] && chmax(ma2,box2[i]))b2=i;
            }
        }else{

        }
    }
    ll ans=0;
    if(a1 != b1){
        //cout<<a1<<" "<<b1<<endl;
        ans = n-max1-max2;
    }else{
       // cout<<a1<<" "<<b1<<endl;
       // cout<<max1<<" "<<max2<<endl;
        sort(box,box+100001);
        sort(box2,box2+100001);
        ans = min(n-max1-box2[100000-1],n-max2-box[100000-1]);

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


Measured memory_bytes: 2428
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

int main(){
	int a[5];
	for(int i=0;i<5;i++){
		cin >> a[i];
	}
	sort(a,a+5);
	for(int i=4;i>0;i--){
		cout << a[i] << " ";
	}
	cout << a[0] << endl;

	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const int mx=1e6+5;
ll c[mx];
ll n,d,a;
int main(){
	cin >> n >> d >> a;
	vector < pair < long long ,long long > > v;
	for(int i=0;i<n;++i){
		ll x,y;cin >> x >> y;
		v.pb(mp(x,y));
	}
	long long ans=0;
	sort(v.begin(),v.end());
	ll j=0;
	for(ll i=0;i<n;++i)
	{
		while(j<n and v[j].first<=v[i].first+2*d)
			++j;
		ll need=max((v[i].second-c[i]*a+a-1)/a,0ll);
		ans+=need;
		c[j]=c[j]-need;
		c[i]+=need;
		c[i+1]+=c[i];
	}
	cout << ans << endl;
}


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

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

#define N 500003
#define INFTY 1000000001

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int l;

int main()
{
  int i,j,left,mid,right,n;
  int S[N];

  scanf("%d",&n);
	     
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  left=0;
  right=n;
  
  mergeSort(S,left,right);

  for(i=0;i<n-1;i++) printf("%d ",S[i]);
  printf("%d\n",S[n-1]);
  printf("%d\n",l);

  return 0;
}

void merge(int *S,int left,int mid,int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1],R[n2+1],i,j,k;
  
  for(i=0;i<n1;i++) L[i] = S[left + i];
  for(j=0;j<n2;j++) R[j] = S[mid + j];
    
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
    for(k=left;k<right;k++){
      if(L[i] < R[j]){
	S[k] = L[i];
	i = i + 1;
      }
      else{ 
	S[k] = R[j];
	j = j + 1;
	}
      l++;
    }
}

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



Measured memory_bytes: 5616
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*
--------------------------------------------

	Optimizer

--------------------------------------------
*/
//#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
--------------------------------------------
 
	Utility Algorithm

-------------------------------------------- 
*/

template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}
 
template <typename T1>
T1 euclideanAlgorithm(T1 a, T1 b) {
    T1 a_tmp = a;
    T1 b_tmp = b;
 
    if (a_tmp > b_tmp) {
        swapAlgorithm<T1>(a_tmp, b_tmp);
    }
 
    T1 r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

template <typename T2>
T2 getLCM(T2 a, T2 b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    float a,b;
    cin >> a >> b;
    cout << ceil((a+b)/2) << endl;

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#define D 365

int main()
{
	int d=D;
	int i,j,k;
	int c[26]={0};
	int s[D][26]={0};
	int t[365]={0};

	int bestcon[365]={0};
	int bestnum=0;

	scanf("%d",&d);
	for(i=0;i<26;i++)
    {
	    scanf("%d",(&c[i]));
    }
    for(j=0;j<365;j++)
    {
        bestnum=0;
        for(k=0;k<26;k++)
        {
            scanf("%d",(&s[j][k]));
            if(bestnum<s[j][k])
            {
                bestnum=s[j][k];
                bestcon[j]=k;
            }
        }
    }
    // input 終了
    for(j=0;j<365;j++)
    {
        t[j]=(bestcon[j]+1);
    }


    // output 開始
	for(i=0;i<365;i++)
    {
	    if(t[i]==0)t[i]++;
	    printf("%d\n",t[i]);
    }
}

Measured memory_bytes: 1748
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	int ans = 0;
	string str;
	while(cin >> str)
	{
		bool flag = true;
		for(int i = 0; i < str.size() / 2; ++i)
		{
			if(str[i] != str[str.size() - 1 - i])
			{
				flag = false;
				break;
			}
		}
		if(flag)
		{
			++ans;
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
int n;
cin >> n;
string a,b,c;
cin >> a >> b >> c;
int ans = 0;
for(int i=0;i<n;i++){
    char aa = a.at(i),bb=b.at(i),cc=c.at(i);
    if(aa==bb&&bb!=cc)ans++;
    if(bb==cc&&bb!=aa)ans++;
    if(aa==cc&&bb!=aa)ans++;
    if(aa!=bb&&bb!=cc&&cc!=aa)ans+=2;
}
cout << ans << endl;
}
 


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

int main()
{
  int K, A, B;
  cin >> K >> A >> B;
  bool check = false;
  for (int i = A; i <= B; i++)
  {
    if (i % K == 0)
    {
      check = true;
      break;
    }
  }
  if (check) cout << "OK" << endl;
  else cout << "NG" << endl;
}


Measured memory_bytes: 3636
N,A,B = map(int, input().split())
def find_sum_of_digit(n):
    sum = 0
    while True:
        sum += n%10
        n = int(n/10)
        if n == 0:
            break
    return sum
ans = 0
for i in range(1,N+1):
    a = find_sum_of_digit(i)
    if a>=A and a<=B:
        ans += i
print(ans)

Measured memory_bytes: 3060
//
//  main.cpp
//  atcoderX
//
//  Created by 村井真奈美 on 2018/06/16.
//  Copyright © 2018年 村井真奈美. All rights reserved.
//

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

int main() {
    
    int N;
    int counter = 1;
    cin >> N;
    vector<int> figure(N);
    
    for(int i=0;i<N;i++){
        cin >> figure.at(i);
    }
    
    for(int i=0;i<N;i++){
        if(figure.at(0) == 2)break;
        swap(figure.at(0),figure.at(figure.at(0)-1));
        counter++;
        if(figure.at(0) == 2) break;
    }
    
    if(figure.at(0) == 2)cout << counter << endl;
    else cout << -1 << endl;
}




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

ll dp[1001][1001];
bool isBlocked[1001][1001];

int main() 
{
	ll n,m;
    cin>>n>>m;
    
    memset(isBlocked,false,sizeof(isBlocked));

    for(ll i=1; i<=n; i++)
    {
        string str;
        cin>>str;

        for(ll j=0; j<m; j++)
        {
            if(str[j]=='#')
                isBlocked[i][j+1] = true;
        }
    }

    memset(dp,0,sizeof(dp));
    
    if(!isBlocked[1][1])
        dp[1][1] = 1;     
    
    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=m; j++)
        {
            if(i==1 && j==1)
                continue;
                
            if(!isBlocked[i][j])
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        }
    }
    
    cout<<dp[n][m]<<endl;
	
	return 0;
}

Measured memory_bytes: 12424
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        sc.close();
        if (a * c <= b) {
            System.out.println(c);
            return;
        } else {
            System.out.println(b / a);
        }

    }
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (abs(b - a) > pow(10, 18)) {
        puts("Unfair");
        return 0;
    }
    if (k % 2 == 0) {
        cout << a - b << endl;
    } else {
        cout << b - a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//-------------------------↓↓↓↓↓↓------------------------
ll n, k, a, b, d[2002], lim, cnt = 0, ans = 1000000000, ma, parent;
vector<ll> graph[2002];
map<ll,ll> nex, dis;
bool visited[2002];

ll dfs_odd(ll now, ll depth){
    if(visited[now])return 0;
    visited[now] = true;
    if(depth > lim)d[now] = 1;
    for(int i = 0; i < graph[now].size(); i++){
        dfs_odd(graph[now][i], depth + 1);
    }
    return 0;
}

ll dfs_even(ll now, ll depth){
    if(visited[now])return 0;
    visited[now] = true;
    if(nex[now] == 1){
        parent = now;
    }
    if(depth > lim)d[now] = 1;
    if(depth == lim + 1){
        dis[parent]++;
    }
    for(int i = 0; i < graph[now].size(); i++){
        dfs_even(graph[now][i], depth + 1);
    }
    return 0;
}

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

    cin >> n >> k;
    for(int i = 0; i < n - 1; i++){
        cin >> a >> b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    if(k % 2 == 0){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n + 1; j++){
                d[j] = 0;
                visited[j] = false;
            }
            lim = k / 2;
            dfs_odd(i, 0);
            for(int j = 0; j < n; j++){
                cnt += d[j];
            }
            ans = min(ans, cnt);
            cnt = 0;
        }
        cout << ans << "\n";
    }
    else{
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n + 1; j++){
                d[j] = 0;
                visited[j] = false;
                nex[j] = 0;
                dis[j] = 0;
            }
            for(int j = 0; j < graph[i].size(); j++){
                nex[graph[i][j]] = 1;
            }
            lim = k / 2;
            dfs_even(i, 0);
            for(int j = 0; j < n; j++){
                cnt += d[j];
            }
            for(int j = 0; j < n; j++){
                ma = max(ma, dis[j]);
            }
            ans = min(ans, cnt - ma);
            cnt = 0;
            ma = 0;
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#pragma warning(disable:4996)
using namespace std;
int main() {
 int p[1001] = { 0 };
 int n = 0, k = 0;
 scanf("%d %d", &n, &k);
 for (int i = 0; i < n; i++) {
  scanf(" %d", &p[i]);
 }
 sort(p, p + n);

 int sum = 0;

 for (int i = 0; i < k; i++) {
  sum += p[i];

 }
 printf("%d\n", sum);


 //system("pause");
 return 0;
}

Measured memory_bytes: 1728
from collections import deque
n, m = map(int, input().split())

g = [[] for _ in range(n + 1)]
deg = [0] * (n + 1)
for i in range(m):
    x, y = map(int, input().split())
    g[x].append(y)
    deg[y] += 1

q = deque()

for i in range(1, n + 1):
    if deg[i] == 0:
        q.append(i)

dp = [0] * (n + 1)
while q:
    n = q.popleft()
    for zzz in g[n]:
        deg[zzz] -= 1
        if deg[zzz] == 0:
            q.append(zzz)
            dp[zzz] = dp[n] + 1

print(max(dp))


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

// Common file
#include <ext/pb_ds/assoc_container.hpp>
// Including tree_order_statistics_node_update
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>



#define pb push_back
#define F first
#define S second
#define rep(i,n) for(int i = 0; i < (n); i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
            y = y>>1;
            x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
    return(m == 0)?1:n*nCr(n-1,m-1)/m;
}

/*****************************************************/

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

    int len = s.length() , l = 0 , r = 0;

    for(int i = 0; i < len; ++i)
        if(s[i] != t[i])
            ++l;
    for(int i = len - 1; i >= 0; --i)
        if(s[i] != t[i])
            ++r;

    cout << min(l , r) << "\n";

    return 0;
}


Measured memory_bytes: 3828