akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,j,n,rank;
    int card[4][13];
    char mark;
    scanf("%d",&n);
    
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            card[i][j] = 0;
        }
    }
    
    for(i=1;i<=n;i++){
        scanf("%c",&mark);  //改行読み込み
        scanf("%c %d",&mark,&rank);
        switch (mark){
            case 'S':
                card[0][rank-1] = 1;
                break;
            case 'H':
                card[1][rank-1] = 1;
                break;
            case 'C':
                card[2][rank-1] = 1;
                break;
            case 'D':
                card[3][rank-1] = 1;
                break;
            default:
                printf("error %c\n",mark);
                break;
        }
    }
    
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(card[i][j] == 0){
                switch (i){
                    case 0:
                        printf("S %d\n",j+1);
                        break;
                    case 1:
                        printf("H %d\n",j+1);
                        break;
                    case 2:
                        printf("C %d\n",j+1);
                        break;
                    case 3:
                        printf("D %d\n",j+1);
                        break;
                    default:
                        break;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2144
// D - Wizard in Maze

// コストもキューで管理するように変更

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

char field[1000][1000];
bool visited[1000][1000];

struct Search {
	int r;
	int c;
	int cost;
};

// 移動ベクトル
vector<int> dr;
vector<int> dc;
map<int, int> mv_to_cost;

// sr: スタート行, cs: スタート列, gr: ゴール行, gc: ゴール列
int bfs(int H, int W, int sr, int sc, int gr, int gc) {
	deque<Search> search_queue;
	search_queue.push_back(Search{sr, sc, 0});

	while(!search_queue.empty()) {
		// キューから探索対象の位置情報を取り出す
		Search search = search_queue.front();
		search_queue.pop_front();

		int r = search.r;
		int c = search.c;
		int cost = search.cost;

		if (visited[r][c]) continue;
		visited[r][c] = true;

		//cout << r << ' ' << c << " (" << cost << ")" << endl; // **** debug ****

		if (r == gr && c == gc) return cost; // ゴールに到達

		// 探索を予約
		for (int mv = 0; mv < dr.size(); mv++) {
			int next_r = r + dr[mv];
			int next_c = c + dc[mv];

			if (next_r < 0 || next_r >= H || next_c < 0 || next_c >= W) continue; // 範囲外
			if (field[next_r][next_c] == '#') continue; // 壁
			if (visited[next_r][next_c]) continue; // 探索済み

			if (mv_to_cost[mv] == 0) {
				search_queue.push_front(Search{next_r, next_c, cost});
			} else {
				search_queue.push_back(Search{next_r, next_c, cost + 1});
			}
		}
	}

	return -1; // ゴールできなかった場合
}

int main(){
  int H, W;
	int sr, sc, gr, gc;
	cin >> H >> W;
	cin >> sr >> sc;
	cin >> gr >> gc;

	for (int r=0; r<H; r++) {
		for (int c=0; c<W; c++) {
			cin >> field[r][c];
		}
	}

	// 移動ベクトルを作成
	int mv = 0;
	for (int i=-2; i<=2; i++) {
		for (int j=-2; j<=2; j++) {
			if (i == 0 && j == 0) continue;
			dr.push_back(i);
			dc.push_back(j);

			int cost = 1;
			if (i == 1 && j == 0) cost = 0;
			if (i == -1 && j == 0) cost = 0;
			if (i == 0 && j == 1) cost = 0;
			if (i == 0 && j == -1) cost = 0;
			mv_to_cost[mv] = cost;
			mv++;
		}
	}

	int ans = bfs(H, W, sr - 1, sc - 1, gr - 1, gc - 1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6064
def find(x, root)
  return unless @group[x]
  return true if @group[x].include?(root)
  @group[x].each do |m|
    if find(m, root)
      @group[x] << root
      return true
    end
  end
  false
end

while n = gets.to_i
  break if n == 0
  root = ''
  @group = {}
  n.times do |i|
    g, m = gets.split(':')
    root = g if i == 0
    ms = m[0..-3].split(',')
    ms.each{ |m| @group[m] ||= []; @group[m] << g }
  end
  cnt = 0
  leaf = @group.keys
  @group.values.each{ |vs| vs.each{ |v| leaf.delete(v) } }
  leaf.each do |name|
    if find(name, root)
      cnt += 1
    end
  end
  p cnt
end

Measured memory_bytes: 9280
/// c.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("Yes")
# define no puts("No")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < pll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
# define int ll
int s[1 << 10][1 << 10];
int v[1 << 10][1 << 10];
int g1(int n,int m,int x,int y)
{
    memset(s,0,sizeof(s));
    for (int i = x;i <= n;i += x)
        for (int j = y;j <= m;j += y)
                s[i][j] = - x * y - 3000 * (x * y - 1);
    for (int i = 1;i <= n;++i)
        for (int j = 1;j <= m;++j)
            if (!s[i][j])
                s[i][j] = 3001;
    memset(v,0,sizeof(v));
    for (int i = 1;i <= n;++i)
        for (int j = 1;j <= m;++j)
            v[i][j] = s[i][j] + v[i - 1][j] + v[i][j - 1] - v[i - 1][j - 1];
    if (v[n][m] <= 0)
        return 0;
    auto query = [&](int x1,int y1,int x2,int y2)
    {
        return v[x2][y2] + v[x1 - 1][y1 - 1] - v[x1 - 1][y2] - v[x2][y1 - 1];
    };
    for (int i = x;i <= n;++i)
        for (int j = y;j <= m;++j)
            if (query(i - x + 1,j - y + 1,i,j) >= 0)
                return 0;
    return 1;
}
int g2(int n,int m,int x,int y)
{
    int cnt = (n / x) * (m / y);
    if (cnt * (x * y + 1) >= n * m)
        return 0;
    return 1;
    for (int i = x;i <= n;i += x)
        for (int j = y;j <= m;j += y)
                s[i][j] = - x * y;
    for (int i = 1;i <= n;++i)
        for (int j = 1;j <= m;++j)
            if (!s[i][j])
                s[i][j] = 1;
    return 1;
}
int32_t main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m,x,y;
    fi>>n>>m>>x>>y;
    int cnt = g1(n,m,x,y);
    if (cnt)
        fo << "Yes\n";
    else
        fo << "No\n";
    if (cnt)
    {
        for (int i = 1;i <= n;++i)
            for (int j = 1;j <= m;++j)
                fo << s[i][j] << " \n"[j == m];
    }
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 17920
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;
#define INF (1LL << 60)
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,k,n) for(int i=(k);(i)<(n);(i)++)
#define REP(i,n) for(int i = 0;(i)<(n);(i)++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define F first
#define S second
#define MOD (1e9 + 7)

int main() {
	int n, q;
	string s;
	cin >> n >> q;
	cin >> s;
	vector<int> l(q);
	vector<int> r(q);
	REP(i, q) {
		cin >> l[i] >> r[i];
		l[i]--;
		r[i]--;
	}

	vector<int> sum(n, 0);
	
	REP(i, n) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			if (i == 0) {
				sum[0] = 0;
				sum[1] = 1;
			}
			else {
				sum[i] = sum[i - 1];
				sum[i + 1] = sum[i] + 1;
			}
			i++;
		}
		else {
			sum[i] = sum[i - 1];
		}
		
	}
	REP(i, q) {
		cout << sum[r[i]] - sum[l[i]] << endl;
	}
	return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    char a[105][105];
    ll h,w;
    scanf("%lld%lld",&h,&w);
    // ll [n];
    rep(i,0,h){
        scanf("%s",a[i]);
    }
    ll r=0,c=0,row[100],column[100];
    rep(i,0,h){
        rep(j,0,w){
            if(a[i][j]=='#') break;
            if(j==w-1){
                row[r] = i;
                r++;
            }
        }
    }
    rep(j,0,w){
        rep(i,0,h){
            if(a[i][j]=='#') break;
            if(i==h-1){
                column[c] = j;
                c++;
            }
        }
    }
    // printf("%lld %lld\n",r,c);
    // PN;
    ll j1,j2;
    rep(i,0,h){
        j1=1;
        rep(ii,0,r){
            if(i==row[ii]){
                j1=0;
                break;
            }
        }
        if(!j1) continue;
        rep(j,0,w){
            j2=1;
            rep(jj,0,c){
                if(j==column[jj]){
                    j2=0;
                    break;
                }
                
            }
            if(!j2) continue;
            printf("%c",a[i][j]);
        }
        PN;
    }
    
    // printf("%lld\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define re register
#define int long long
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9'){
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
int n,a[100002],m,p,v,l,r;
signed main(){
	n=read();
	m=read();
	v=read();
	p=read();
	for(re int i=1;i<=n;++i)a[i]=read();
	sort(a+1,a+n+1);
	l=1,r=n;
	while(l<r){
		int mid=(l+r)>>1;
		int tmp=a[mid]+m,num=m*(v-mid),cnt=mid;
		while(cnt<=n&&tmp>=a[cnt]){
			++cnt;
			if(tmp>=a[cnt]&&cnt<=n)
			num-=(tmp-a[cnt]);
		}
		num-=(n-cnt+1)*m;
		while(num>0&&cnt>=1)--cnt,num-=m-(tmp-a[cnt]);
		//cout<<cnt<<endl;
		//cout<<l<<" "<<r<<" "<<tmp<<" "<<mid<<" "<<a[mid]<<" "<<cnt<<endl;	
		if(cnt>n-p+1)r=mid;
		else l=mid+1;
	}
	printf("%lld",n-r+1);
}

Measured memory_bytes: 1024
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;

const LL INF=1<<30;
const LL MOD=1000000007;





int main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;++i){
        int a,b;
        cin>>a>>b;
    ans+=b-a+1;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
A = [list(map(int, input().split())) for _ in range(3)]
B = [[False] * 3 for _ in range(3)]
N = int(input())
ans = 'No'

for i in range(N):
  t = int(input())
  
  for y in range(3):
    for x in range(3):
      if A[y][x] == t:
        B[y][x] = True
      
for y in range(3):
  if B[y][0] == B[y][1] == B[y][2] == True:
    ans = 'Yes'
  
for x in range(3):
  if B[0][x] == B[1][x] == B[2][x] == True:
    ans = 'Yes'
    
if B[0][0] == B[1][1] == B[2][2] == True:
  ans = 'Yes'
  
if B[0][2] == B[1][1] == B[2][0] == True:
  ans = 'Yes' 

print(ans)

Measured memory_bytes: 3064
using System;
class p
{
  static void Main()
  {
    string[] ipt = Console.ReadLine().Split(' ');
    int[] arr = new int[9];
    for (int i = 0; i < 3; i++) {
      arr[i] = int.Parse(ipt[i]);
    }
    ipt = Console.ReadLine().Split(' ');
    for (int i = 0; i < 3; i++) {
      arr[i+3] = int.Parse(ipt[i]);
    }
    ipt = Console.ReadLine().Split(' ');
    for (int i = 0; i < 3; i++) {
      arr[i+6] = int.Parse(ipt[i]);
    }
    bool bingo = false;
    int N = int.Parse(Console.ReadLine());
    for (int i = 0; i < N; i++) {
      int b = int.Parse(Console.ReadLine());
      int index = Array.IndexOf(arr, b);
      if (0 <= index) {
        arr[index] = -1;
      } else {
        continue;
      }
      if ((arr[0] == -1 && arr[1] == -1 && arr[2] == -1) ||
          (arr[3] == -1 && arr[4] == -1 && arr[5] == -1) ||
          (arr[6] == -1 && arr[7] == -1 && arr[8] == -1) ||
          (arr[0] == -1 && arr[3] == -1 && arr[6] == -1) ||
          (arr[1] == -1 && arr[4] == -1 && arr[7] == -1) ||
          (arr[2] == -1 && arr[5] == -1 && arr[8] == -1) ||
          (arr[0] == -1 && arr[4] == -1 && arr[8] == -1) ||
          (arr[2] == -1 && arr[4] == -1 && arr[6] == -1)) {
        bingo = true;
        break;
      }
    }
    Console.WriteLine(bingo ? "Yes" : "No");
  }
}

Measured memory_bytes: 13140
import java.util.Arrays
import java.util.ArrayList
import java.util.ArrayDeque

const val MOD: Long = (1e9+7).toLong()
fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun <T : Comparable<T>> Iterable<T>.argmax(): Int? = withIndex().maxBy{it.value}?.index
fun <T : Comparable<T>> Iterable<T>.argmin(): Int? = withIndex().minBy{it.value}?.index

fun main(args: Array<String>) {
    val reader = System.`in`.bufferedReader()
    val s = reader.readLine()!!

    if (s[0] in listOf('a', 'i', 'u', 'e', 'o')) {
        println("vowel")
    } else {
        println("consonant")
    }
}


Measured memory_bytes: 33868
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                sum += array[i] * array[j];
            }
        }
        
        System.out.println(sum);
    }
}


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

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

    int cnt_r, cnt_l;
    cnt_r = 0; cnt_l = 0;

    deque <char> ans;

    bool cnt_start = false;

    int _cnt = 0;

    reverse(s.begin(), s.end());
    for(auto c: s){
        if(c == ')') cnt_start = true;
        if(cnt_start){
            if(c == ')') {
                _cnt += 1;
            }
            else{
                //cnt_l += 1;
                cnt_r += _cnt;
                cnt_r -= 1;
                if(cnt_r < 0) cnt_r = 0;
                _cnt = 0;
            }
        }
    }

    rep(i, _cnt + cnt_r) ans.push_front('(');

    cnt_r = 0; cnt_l = 0;
    cnt_start = false;
    if(ans.front() == '(') cnt_start = true;
    _cnt = 0;
    
    reverse(s.begin(), s.end());
    for(auto c: s){
        ans.push_back(c);
        if(c == '(') cnt_start = true;
        if(cnt_start){
            if(c == '(') {
                _cnt += 1;
            }
            else{
                //cnt_r += 1;
                cnt_l += _cnt;
                cnt_l -= 1;
                if(cnt_l < 0) cnt_l = 0;
                _cnt = 0;
            }
        }
    }

    rep(i, _cnt + cnt_l) ans.push_back(')');

    
    int size = ans.size();
    rep(i, size){
        cout << ans.front();
        ans.pop_front();
    }
    cout << endl;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;


int main()
{
	int h1, h2;
	int k1, k2;
	int a, b, c, d;
	cin >> h1 >> h2 >> k1 >> k2;
	cin >> a >> b >> c >> d;

	int hirosi = h1*a + (h1 / 10)*c + h2*b + (h2/20)*d;
	int kenji = k1*a + (k1 / 10) * c + k2*b + (k2/20)*d;
	if (hirosi > kenji)cout << "hiroshi" << endl;
	else if (hirosi < kenji)cout << "kenjiro" << endl;
	else cout << "even" << endl;
	return 0;
}

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	int a[6],b[6];
	int tmp,tmp2;
	int sum=0;
	int count=0;
	for(int i=0;i<5;i++){
		scanf("%d",&a[i]);
		b[i] = (10-a[i]%10)*10;
		if(b[i]==100){
			tmp=b[count];
			tmp2=a[count];
			b[count]=b[i];
			a[count]=a[i];
			b[i]=tmp;
			a[i]=tmp2;
			count++;
		}
	}

	for(int i=count;i<5;i++){
		for(int j=i;j<5;j++){
			if(b[i]>b[j]){
				tmp2=b[i];
				tmp=a[i];
				b[i]=b[j];
				a[i]=a[j];
				b[j]=tmp2;
				a[j]=tmp;
			}
		}
	}

	for(int i=0;i<count;i++){
		sum+=a[i];
	}
	for(int i=count;i<=4;i++){
		if(i==4){
			sum+=a[i];
		}else{
			sum+=((a[i]/10)+1)*10;
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int N; cin >> N;
    vector<ll> L(N+1);
    L.at(0) = 2,L.at(1) = 1;
    for(int i = 2; i < N+1; i++)
    {
        L.at(i) = L.at(i-1) + L.at(i-2);
    }
    cout << L.at(N) << endl;
}

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

// typedef
typedef unsigned int uint;

using namespace std;

void Set753Number(uint inNum, uint inNumSize, vector<uint> &inAll753Numbers);

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

  vector<uint> all753Numbers;
  for (auto index = 0; index <= 9; index++)
    Set753Number(0, index, all753Numbers);  //753数をセット

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

  // 要素がNを超えるまでカウント
  int count = 0;
  for (auto &&val : all753Numbers)
  {
    if (val <= N)
      count++;
    else
      break;
  }
  cout << count << endl;
}

void Set753Number(uint inNum, uint inNumSize, vector<uint> &inAll753Numbers)
{
  uint num = inNum * 10;  //一桁ずらす

  if (inNumSize)
  {
    Set753Number(num + 3, inNumSize - 1, inAll753Numbers);
    Set753Number(num + 5, inNumSize - 1, inAll753Numbers);
    Set753Number(num + 7, inNumSize - 1, inAll753Numbers);
  }
  else
  {
    bool flag3 = false;
    bool flag5 = false;
    bool flag7 = false;

    uint cpInNum = inNum;
    while (cpInNum)
    {
      switch (cpInNum % 10)
      {
      case 3:
        flag3 = true;
        break;
      case 5:
        flag5 = true;
        break;
      case 7:
        flag7 = true;
        break;
      default:
        break;
      }
      cpInNum /= 10;
    }

    // 753数になっていれば追加
    if (flag3 * flag5 * flag7)
      inAll753Numbers.push_back(inNum);
  }
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var result int
	nums := make([]int, 5)
	for i:=0; i<5; i++{
		fmt.Scan(&nums[i])
		
		if nums[i] == 0{
			result = i+1
		}
	}

	fmt.Println(result)

}

Measured memory_bytes: 1752
from collections import deque
s = list(input())
d = deque(s)
q = int(input())
flag = True
for i in range(q):
  l = list(map(str,input().split()))
  if l[0] == '1':
    if flag:
      flag = False
    else:
      flag = True
  else:
    if l[1] == '1':
      if flag:
        d.appendleft(l[2])
      else:
        d.append(l[2])
    else:
      if flag:
        d.append(l[2])
      else:
        d.appendleft(l[2])
if flag:
  print(''.join(d))
else:
  d.reverse()
  print(''.join(d))
  

Measured memory_bytes: 9460
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string a,b; cin>>a>>b;
    int ans = 0;
    for(int i=0;i<a.size();++i){
        if(a[i] != b[i])ans++;
    }
    cout << ans;
    
    
    return 0;
}

// Химаншу    

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;

    vector<long long>x(n),y(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    long double ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ans+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    cout<<fixed<<setprecision(10)<<ans/n<<endl;
  
    
}


Measured memory_bytes: 384
#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>;

vector<int>to[10010];
int c[10010],a[10010],cnt,ans;

void dfs(int v, int p=-1){
    a[v]=c[cnt];
    for(int u:to[v]){
        if(u==p)continue;
        cnt++;
        dfs(u,v);
    }
}

void dfs2(int v, int p=-1){
    for(int u:to[v]){
        if(u==p)continue;
        ans+=min(a[v],a[u]);
        dfs2(u,v);
    }
}

int main(){
    int n;
    cin>>n;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i,n)cin>>c[i];
    sort(c,c+n);
    reverse(c,c+n);
    dfs(0);
    dfs2(0);
    cout<<ans<<endl;
    rep(i,n)cout<<a[i]<<" ";
}

Measured memory_bytes: 4660
num_degit n =truncate $ log n / log 10 +1

main = do
  n <- getLine >>= return . read :: IO Int
  let a = minimum [num_degit $ fromIntegral (maximum [a,div n a]) |a<-[1..(truncate ( sqrt $ fromIntegral n))],(n `mod` a)==0]
  print a

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string n;
  cin>>n;
  int ans=0;
  for(int i=0;i<n.size();i++){
    ans+=(int)n[i]-'0';
  }
  if(ans%9==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int n,d,x; cin >> n >> d >> x;
  int sum=x;
  rep(i,n){
    int a; cin >> a;
    sum += (d-1)/a+1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
n = int(input())

robots = []

for i in range(n):
    x,l = map(int, input().split())
    robots.append((x+l, x-l))

INF = 1e10
last = -INF
    
robots.sort()

ans = 0
for (r, l) in robots:
    if l < last:continue
    ans += 1
    last = r

print(ans)

Measured memory_bytes: 54488
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		long x[] = new long[n];
		long y[] = new long[m];
		for(int i=0; i<n; i++) x[i]=sc.nextLong();
		for(int i=0; i<m; i++) y[i]=sc.nextLong();
		long mod = 1000000007;
		long sumx = 0;
		for(int i=0; i<n; i++) {
			sumx += ((2*i-n+1) * x[i]) % mod;
			sumx %= mod;
		}
		long sumy = 0;
		for(int i=0; i<m; i++) {
			sumy += ((2*i-m+1) * y[i]) % mod;
			sumy %= mod;
		}
		long ans = (sumx * sumy) % mod;
		ans %= mod;
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 61260
import sys
N = int(input())

s1 = ""
s2 = ""

sgn1 = "..##"
sgn2 = ".#.#"

flag = False
while True:
    if flag == False:
        flag = True
        for i in range(4):
            s1 += sgn1[i]
            s2 += sgn2[i]
            print(s1 + "\n" + s2)
            r = input()
            if r == "end":
                sys.exit(0)
            elif r == "T":
                flag = False
                break
            else:
                s1 = s1[:-1]
                s2 = s2[:-1]

    if flag == True:
        for i in range(4):
            s1 = sgn1[i] + s1
            s2 = sgn2[i] + s2
            print(s1 + "\n" + s2)
            r = input()
            if r == "end":
                sys.exit(0)
            elif r == "T":
                break
            else:
                s1 = s1[1:]
                s2 = s2[1:]

Measured memory_bytes: 3532
using System;

namespace abc148_c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[]ss = Console.ReadLine().Split(' ');
            int A = int.Parse(ss[0]);
            int B = int.Parse(ss[1]);

            int L = lcd(A, B);
            long S = (long) A / L * B;

            Console.WriteLine(S.ToString());
     }

        static int lcd(int a, int b) {

            int maxN = Math.Max(a,b);
            int minN = Math.Min(a,b);

            int divN = minN;
            int m = maxN % minN;
            while(m > 0) {
                minN = divN;
                divN = m;

                m = minN % divN; 
            }

            return divN;
        }
    }
}


Measured memory_bytes: 11092
//#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

    double ans = 0;

    irep(i, n) {
        int a;
        cin >> a;

        ans += 1.0/a;
    } 
    ans = 1.0/ans;
    printf("%.12f\n", ans);
    return 0;
} /*atcoder*/



Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n,k,c=0;cin>>n>>k;bool f=false;
  for(int i=k;i<k+n;i++){
    c+=i;
    if(i==0)f=true;
  }
  cout<<(f?c:(k>0?c-k:c-(k+n-1)));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集

ll modPow(ll x, ll n, ll mod = MOD){
    ll res = 1;
    while(n){
        if(n&1) res = (res * x)%mod;
 
        res %= mod;
        x = x * x %mod;
        n >>= 1;
    }
    return res;
}
 
const int MAX = 2000010;
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  int N, M; cin >> N >> M;
  COMinit();

  ll ans = 0;

  for(int i=0; i<=N; i++){
    //位置が被っているものがi個

    //被っている所の位置
    ll tmp = COM(N, i);

    tmp *= COM(M, i) * fac[i] % MOD;
    tmp %= MOD;
    tmp *= COM(M-i, N-i) * fac[N-i] % MOD;
    tmp %= MOD;
    tmp *= COM(M-i, N-i) * fac[N-i] % MOD;
    tmp %= MOD;

    if(i % 2 == 1) tmp *= -1;
    ans += tmp;
    ans = (ans + MOD) % MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 50520
import sys
import math

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
x = math.ceil(N / 1.08)
bool = True
if math.floor(x * 1.08) != N:
    bool = False
print(int(x) if bool else ':(')


Measured memory_bytes: 3060
#include <stdio.h>
#define MAX 101

int main(void) {
    int i, j, r, c, fld[MAX][MAX] = {};
    scanf("%d %d", &r, &c);
    for(i = 0; i < r; i++) {
        for(j = 0; j < c; j++) {
            scanf("%d", &fld[i][j]);
            fld[r][j] += fld[i][j];
            fld[i][c] += fld[i][j];
            fld[r][c] += fld[i][j];
        }
    }
    for(i = 0; i <= r; i++) {
        for(j = 0; j <= c; j++) {
            printf("%d%s", fld[i][j], j - c ? " " : "\n");
        }
    }
    return 0;
}

Measured memory_bytes: 648
import java.util.*;

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

        int X = sc.nextInt();
        boolean flag = false;

        while (flag == false){
            flag = isPrime(X);
            X++;
        }
        System.out.println(X-1);
    }

    public static boolean isPrime(int X) {
        if(X == 2) return true;
        if(X % 2 == 0) return false;

        double sqrtNum = Math.sqrt(X);

        for(int i=3; i<= sqrtNum; i += 2) {
            if(X % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 23508
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  outl("ABC" + to_string(n));
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	ll n;
	cin >> n;
	cout << (n-2)*180 << endl;
	cin >> n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

class iunionfind {
   public:
    // 連続するuintにのみ使える。vectorであるため定数時間がとれる。
    // 基本的にこれだけあればよい。任意の構造体を扱うときは、IDと構造体のマッピングをとるvectorを別途用意する。
    // libs-test.cppの iuf_map あたりを検索。
    vector<ull> partition;
    vector<ull> rank;

    iunionfind(ull n) {
        partition.resize(n);
        rank.resize(n);
        for (ull x = 0; x < n; x++) {
            partition[x] = x;
            rank[x] = 0;
        }
    }
    ull find(ull x) {
        if (partition[x] == x) {
            return x;
        } else {
            partition[x] = find(partition[x]);
            return partition[x];
        }
    }
    void unite(ull x, ull y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return;
        }
        if (rank[x] < rank[y]) {
            partition[x] = y;
        } else {
            partition[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }
    bool same(ull x, ull y) {
        return find(x) == find(y);
    }
};
using pll = pair<ll, ll>;
int main() {
    ll N, M;
    cin >> N >> M;
    vector<pll> AB(M);

    iunionfind uf(N);
    for (ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
    }

    vector<ll> unionsize(N, 0);
    for (ll i = 0; i < N; i++) {
        unionsize[uf.find(i)]++;
        //print(i, uf.find(i));
    }
    ll maxsize = 0;
    for (ll i = 0; i < N; i++) {
        maxsize = max(maxsize, unionsize[i]);
    }
    print(maxsize);
}


Measured memory_bytes: 11176
K, N = map(int, input().split())
an = list(map(int, input().split()))

dis =[]

dis.append(an[0] + K - an[len(an)-1])

for i in range(N-1):
    dis.append(an[i+1]-an[i])

work = sorted(dis)
total = 0

for i in range(N-1):
    total += work[i]

print(total)

Measured memory_bytes: 26420
#include <cstdio>
#include <memory.h>
#include <vector>
using namespace std;
const int maxn = 200005;
struct Query{
    int v, d, c;
}q[maxn];
int n, m, Q;
vector<int> G[maxn];
bool vis[maxn][15];
int color[maxn];

void solve(int v, int d, int c){
    if(vis[v][d]) return;
    if(color[v] == 0)    color[v] = c;
    if(d <= 0) return;

    for(int i = 0; i < G[v].size(); i++)
    {
        solve(G[v][i], d-1, c);
    }
    vis[v][d] = 1;

}
int main(){
//freopen("input.txt", "r", stdin);
    scanf("%d %d", &n, &m);
    memset(color, 0, sizeof(color));
    memset(vis, false, sizeof(vis));
    int a, b;
    for(int i = 0; i < m; i++)
    {
        scanf("%d %d", &a, &b);
        G[a].push_back(b);
        G[b].push_back(a);
    }
    scanf("%d", &Q);
    for(int i = 0; i < Q; i++)
    {
        scanf("%d %d %d", &q[i].v, &q[i].d, &q[i].c);
    }
    for(int i = Q-1; i >= 0; i--)
       solve(q[i].v, q[i].d, q[i].c);
    for(int i = 1; i <= n; i++)
        printf("%d\n", color[i]);
    return 0;
}

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

using namespace std;

int main() {
    string N;
    vector<string> vec;
    cin >> N;

    for (int i = 0; i < N.size(); ++i) {
        if (N[i] == '0'){
            vec.push_back("0");
        } else if (N[i] == '1') {
            vec.push_back("1");
        } else if (vec.size() > 0){
            vec.pop_back();
        } else {
            // スルー
        }

    }

    for (int j = 0; j < vec.size(); ++j) {
        cout << vec[j];
    }

    return 0;
}

Measured memory_bytes: 256
/*input
6

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=55555;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
bool isp[maxn];
vector<int> p;
vector<int> v;
int main()
{
	IOS;	
	for(int i=2;i<maxn;i++){
		if(!isp[i]) p.pb(i);
		for(int j=0;i*p[j]<maxn;j++){
			isp[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}
	for(int i:p) if(i%5==1) v.pb(i);
	int n;
	cin>>n;
	REP(i,n) cout<<v[i]<<" \n"[i==n-1];

	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int c[3][3], a[3], b[3];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    rep(i,3)rep(j,3) cin >> c[i][j];
    for(int a0 = -100; a0 <= 100; ++ a0){
        a[0] = a0;
        rep(j,3) b[j] = c[0][j] - a[0];
        rep(i,3) a[i] = c[i][0] - b[0];
        bool ok = true;
        rep(i,3)rep(j,3){
            if(c[i][j] != a[i] + b[j]) ok = false;
        }
        if(ok){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 384
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=200023};
ll a[N];
ll n;

il ll* lower(ll*l,ll*r,ll x,ll k){
	while( l<r ){
		ll*w = l+(r-l)/2;
		if( x*(*w)<=k ) r=w;
		else l=w+1;
	}
	return l;
}
il ll* upper(ll*l,ll*r,ll x,ll k){
	while( l<r ){
		ll*w = l+(r-l+1)/2;
		if( x*(*w)<=k ) l=w;
		else r=w-1;
	}
	return l;
}

il ll calc(ll w){
	ll ans = 0;
	rep(i,1,n){
		if( a[i]==0 ) ans+= w>=0 ? n-i:0 ;
		else if( a[i]>0 ){
			ans += max(0ll,(ll)(upper(a+i,a+n,a[i],w)-a-i));
		}else{
			ans += max(0ll,(ll)(n-(lower(a+i+1,a+n+1,a[i],w)-a)+1));
		}
//		printf("[%d] : %lld\n",i,ans);
	}
	return ans;
}

int main(){
	n=ci();
	ll k; scanf("%lld",&k);
	rep(i,1,n) a[i] = ci();
	sort(a+1,a+n+1);
	ll l=-1e18, r=1e18;
//	rep(i,-12,9) printf("%d : %lld\n",i,calc(i));
//	return 0;
	while( l<r ){
		ll w= l+(r-l)/2;
		if( calc(w)<k ) l=w+1;
		else r=w;
	}
	printf("%lld\n",l);
	return 0;
}


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

using namespace std;

int main(){
	string s;
	cin >> s;
	bool res = true;
	if(s.length()%2!=0)res = false;
	else{
		for(int i=0;i<s.length();i+=2){
			if(s[i] != 'h' || s[i+1] != 'i'){
				res = false;
				break;
			}
		}
	}
	if(res)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<ll,int> P;

int main(){
  int A,B,C,ans;
  cin>>A>>B>>C;
  ans=C-(A-B);
  if(ans<0) ans=0;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * ???(Nails)
 * --------------------
 * JOI 11th, Fin.4
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		int N, M;
		N = parseInt(line.substring(0, line.indexOf(' ')));
		M = parseInt(line.substring(line.indexOf(' ') + 1));

		int[][] grid = new int[N + 3][N + 3];

		for (int i = 0; i < M; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			int a, b, x;
			a = parseInt(st.nextToken());
			b = parseInt(st.nextToken());
			x = parseInt(st.nextToken());

			grid[a][b] += 1;
			grid[a][b + 1] -= 1;

			grid[a + x + 1][b] -= 1;
			grid[a + x + 1][b + x + 2] += 1;

			grid[a + x + 2][b + 1] += 1;
			grid[a + x + 2][b + x + 2] -= 1;
		}

//		Arrays.stream(grid).forEach(x -> System.out.println(Arrays.toString(x)));
//		System.out.println();

		for (int i = 1; i < N + 3; i++) {
			for (int j = 1; j < N + 3; j++) {
				grid[i][j] += grid[i][j - 1];
			}
		}

		for (int i = 1; i < N + 3; i++) {
			for (int j = 1; j < N + 3; j++) {
				grid[i][j] += grid[i - 1][j];
			}
		}

		for (int i = 1; i < N + 3; i++) {
			for (int j = 1; j < N + 3; j++) {
				grid[i][j] += grid[i - 1][j - 1];
			}
		}

//		Arrays.stream(grid).forEach(x -> System.out.println(Arrays.toString(x)));
//		System.out.println();

		int count = 0;

		for (int i = 0; i < N + 3; i++) {
			for (int j = 0; j < N + 3; j++) {
				if (grid[i][j] > 0) count++;
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 204500
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
    int n,i=0;
    cin>>n;
    while(n!=0)
    {
        if(n%10==7)
        {
            i=1;
            break;
        }
        n/=10;
    }
    if(i==1)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;

}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(void)
{
	char x, y;
	cin >> x >> y;
	if ((int)x == (int)y) { cout << "=" << endl; }
	else if ((int)x < (int)y) { cout << "<" << endl; }
	else { cout << ">" << endl; }
	return 0;
}

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

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

int main() {
    map<string, bool> memo;
    int n; cin >> n;
    rep(i,n) {
        string s; cin>>s;
        memo[s] = true;;
    }

    int m; cin >> m;
    int cur = 1;
    rep(i,m) {
        string s; cin>>s;
        if(memo[s] == 0)
            cout << "Unknown " << s << "\n";
        else if(memo[s] == 1 and cur == 1)
            cout << "Opened by " << s << "\n", cur*=-1;
        else
            cout << "Closed by " << s << "\n", cur*=-1;
    }

    return 0;
}

Measured memory_bytes: 3240
# The Secret Number from Aizu Online Judge

# 漸化式:
#    S(i, j) = max( S(i-1,j), S(i,j-1) ) D_ij if D_ij ∈ { 0,1,2,3,4,5,6,7,8,9 }
#            = φ otherwise

def secret_number(w, h, matrix)
  subsol = Array.new(h+1) { |i| Array.new(w+1) { |j| i*j==0 ? '' : nil } }
  1.upto h do |i|
    1.upto w do |j|
      c = matrix[i-1][j-1]
      subsol[i][j] = if c =~ /\d/
                       [subsol[i-1][j], subsol[i][j-1]].max_by(&:to_i) + c
                     else
                       ''
                     end
    end
  end
  subsol.map { |row| row.max_by(&:to_i) }.max_by(&:to_i).to_i
end

# ----------------------------------------
loop do
  w, h = gets.split.map(&:to_i)
  break if [w,h] == [0,0]

  matrix = h.times.map { gets.chomp.chars }
  ans = secret_number(w, h, matrix)
  puts ans
end

Measured memory_bytes: 6132