akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int main() {
    int m, d;
    int x;
    int y;
    cin >> m >> d;
    int count = 0;
    for (int i = 1; i <= m; i++) {
        for (int j = 22; j <= d; j++){
            x = j / 10;
            y = j % 10;
            if (x == 0 && i == j) {
                count++;
              
            }
            else if (x != 0 && i == x*y && y >= 2 ){
                count++;
                
            }else{

            }
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


//k!
ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = sum%MOD*i%MOD;
    }
    return sum%MOD;
}

const int MAX = 510000;
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() {
    int n,m;cin>>n>>m;
    vector<int> A(m);
    rep(i,m)cin>>A[i];
    sort(rall(A));
    int Need[9] = {2,5,5,4,5,6,3,7,6};
    int dp[10010];
    Fill(dp,-1);
    dp[0]=0;
    rep(i,n+1){
        rep(j,m){
            int need = Need[A[j]-1];
            if(i<need)continue;
            dp[i] = max(dp[i],dp[i-need]+1);
        }
    }
    int remain = dp[n];
    string ans = "";
    while(remain != 0){
        rep(i,m){
            int need = Need[A[i]-1];
            if(n<need)continue;
            if(dp[n-need] == remain-1){
                ans += to_string(A[i]);
                n -= need;
                remain--;
                break;
            }
        }
    }
    cout << ans << endl;
}



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

int main() {
        int n;
        scanf("%d", &n);
        vector<vector<vector<long long>>> cur(4, vector<vector<long long>> (4, vector<long long> (4)));
        const int mod = 1e9 + 7;

        rep(x, 4) rep(y, 4) rep(z, 4) {
                if (x == 2 && y == 1 && z == 0) continue;
                if (x == 2 && y == 0 && z == 1) continue;
                if (x == 1 && y == 2 && z == 0) continue;
                cur[x][y][z] = 1;
        }

        long long res = 0;
        rep(x, 4) rep(y, 4) rep(z, 4) (res += cur[x][y][z]) %= mod;
        rep(i, n - 3) {
                vector<vector<vector<long long>>> next(4, vector<vector<long long>> (4, vector<long long> (4)));
                rep(z, 4) rep(y, 4) rep(x, 4) rep(w, 4) {
                        if (w == 2 && x == 1 && y == 0) continue;
                        if (w == 2 && x == 0 && y == 1) continue;
                        if (w == 1 && x == 2 && y == 0) continue;
                        if (w == 2 && x == 1 && z == 0) continue;
                        if (w == 2 && y == 1 && z == 0) continue;
                        (next[w][x][y] += cur[x][y][z]) %= mod;
                }
                cur.swap(next);
        }
        long long ans = 0;
        rep(x, 4) rep(y, 4) rep(z, 4) (ans += cur[x][y][z]) %= mod;
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int H = scan.nextInt();
        int W = scan.nextInt();
        int N = scan.nextInt();
        int sr = scan.nextInt()-1;
        int sc = scan.nextInt()-1;
        String S = scan.next();
        String T = scan.next();

        int left = 0;
        int right = W;
        for (int i=N-1;i>=0;i--) {
            if (T.charAt(i)=='L') {
                if (right<W) right++;
            } else if (T.charAt(i)=='R') {
                if (left>0) left--;
            }

            if (S.charAt(i)=='L') {
                left++;
            } else if (S.charAt(i)=='R') {
                right--;
            }

            if (right<=left) {
                System.out.println("NO");
                return;
            }
        }

        int down = 0;
        int up = H;
        for (int i=N-1;i>=0;i--) {
            if (T.charAt(i)=='U') {
                if (up<H) up++;
            } else if (T.charAt(i)=='D') {
                if (down>0) down--;
            }

            if (S.charAt(i)=='U') {
                down++;
            } else if (S.charAt(i)=='D') {
                up--;
            }

            if (up<=down) {
                System.out.println("NO");
                return;
            }
        }

        if (left<=sc && sc<right && down<=sr && sr<up) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 30048
loop {
  a,l = gets.split.map{|s|s.to_i}
  if [a,l] == [0,0] then break end
  a = [a]
  loop {
    v = a.last.to_s.rjust(l,'0').chars.sort.join
    min = v.to_i
    max = v.reverse.to_i
    r = max - min
    i = a.index(r)
    if i != nil
      puts [i, r, a.length-i].join(' ')
      break
    end
    a << r
  }
}

Measured memory_bytes: 6116
from itertools import accumulate


def solve(string):
    from bisect import bisect_right
    n, m, k, *ab = map(int, string.split())
    a, b = [0] + ab[:n], [0] + ab[n:]
    a, b = list(accumulate(a)), list(accumulate(b))
    ans = 0
    for i in range(n + 1):
        c = bisect_right(b, k - a[i]) - 1
        if c != -1:
            ans = max(ans, c + i)
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 58712
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;

int main(){
    ll h,n,ans=0;cin>>h>>n;
    ll a[101010];
    rep(i,n){
        cin>>a[i];
        ans+=a[i];
    }
    if(ans>=h)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int ok(int x){
  bool nana=false,go=false,san=false;
  while(x>0){
    if(x%10==7){
      nana=true;
    }else if(x%10==5){
      go = true;
    }else if(x%10==3){
      san = true;
    }else{
      return 0;
    }
    x /= 10;
  }
  if(nana&&go&&san){
    return 1;
  }
  return 0;
}

int main(){
  int N;
  cin >> N;
  int sum=0;
  int start=1;
  if(N>=700000000){
    start=700000000;
    sum += 20434;
  }else if(N>=400000000){
    start=400000000;
    sum += 14384;
  }
  for(int i=start;i<=N;i++){
    sum += ok(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979323846264338327950288419716939937510
int main() {
  int r, degree;
  double theta, x, y;
  theta = PI / 2; x = 0; y = 0;
  while (1) {
    scanf("%d,%d", &r, &degree);
    if(!r&&!degree) break;
    x += r * cos(theta); y += r * sin(theta);
    theta -= (double) degree / 180 * PI;
  }
  printf("%d\n%d\n", (int) x, (int) y);
  return 0;
}

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

int		main(void)
{
	string s;

	cin >> s;
	int ans = 0;

	for (int i = 0; s[i]; i++)
	{
		s[i] == '+' ? ans++ : ans--;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N, K, C = map(int, input().split())
S = list(input())

mae = [-1] * N
i = 0
count = 0
while i < N and count < K:
    if S[i] == 'o':
        mae[i] = count
        count += 1
        i += C + 1
    else:
        i += 1

ushiro = [-1] * N
i = N - 1
count = 0
while i >= 0 and count < K:
    if S[i] == 'o':
        ushiro[i] = K - count - 1
        count += 1
        i -= (C + 1)
    else:
        i -= 1

for i in range(N):
    if mae[i] == ushiro[i] and mae[i] != -1:
        print (i + 1)

Measured memory_bytes: 26416
n,m=map(int,input().split())
a = list(map(int,input().split()))

for i in range(n):
    a[i]*=-1

import heapq,math

heapq.heapify(a)

for _ in range(m):
    b=heapq.heappop(a)*(-1)
    b //=2

    heapq.heappush(a,b*(-1))

print(sum(a)*(-1))

Measured memory_bytes: 19992
#include<bits/stdc++.h>
using namespace std;
struct Edge{
    int to; //辺の行先
    int weight; //辺の重み
    int color; //辺の色
    Edge(int w,int t,int c):weight(w),to(t),color(c){}
};
using Graph=vector<vector<Edge>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int N;cin>>N;
    Graph G(N);
    rep(i,N-1){
        int from,to;
        cin>>from>>to;
        from--;to--;
        G[from].push_back(Edge(i,to,-1));
        G[to].push_back(Edge(i,from,-1));
    }
    //幅優先探索
    //スタートから何ステップで到達できるか
    vector<int>dist(N,-1);
    vector<int>colorlist(N);
    vector<int>ans(N-1);
    //発見済み訪問前の頂点を入れておく
    queue<int>que;
    int maxi=0;
    //初期条件
    dist[0]=0;
    que.push(0);
    colorlist.at(0)=0;
    //頂点0が初期ノード
    //BFS
    while(!que.empty()){
        int v=que.front(); que.pop();
        int cl=colorlist.at(v);
        int count=1;
        for(auto nv:G[v]){
            if(dist[nv.to]!=-1){
                continue;
            }//訪問済みなら無視
            dist[nv.to]=dist[v]+1;
            if(count==cl){
                count++;
            }
            nv.color=count;
            colorlist.at(nv.to)=count;
            ans.at(nv.weight)=count;
            que.push(nv.to);
            maxi=max(maxi,count);
            count++;
        }
    }
    cout<<maxi<<endl;
    rep(i,N-1){
        cout<<ans[i]<<endl;
    }
}


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


int main() 
{
	int PIECE_NUM = 0;
	std::vector<int> piecePos;
	int opeNum = 0;

	auto haveSameNum = [&](int pos) -> bool
	{
		for (int pPos : piecePos) if (pPos == pos + 1) return true;
		return false;
	};
	

	std::cin >> PIECE_NUM;
	for (int i = 0; i < PIECE_NUM; ++i)
	{
		int pos = 0;
		std::cin >> pos;
		piecePos.emplace_back(pos);
	}
	std::cin >> opeNum;

	// 駒を動かす
	for (int i = 0; i < opeNum; ++i)
	{
		int no = 0;
		std::cin >> no;
		
		int pos = piecePos[no-1];

		if (pos == 2019) continue;
		else if(haveSameNum(pos)) continue;

		piecePos[no-1] ++;
	}	

	for (int pPos : piecePos) std::cout << pPos << std::endl;

	return 0;
}


Measured memory_bytes: 3144
import java.util.Map;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    boolean ret = true;
    Map<Character, Integer> map = new HashMap<Character, Integer>();
    for (char c: str.toCharArray())
      if (map.containsKey(c))
        map.put(c, map.get(c) + 1);
      else
        map.put(c, 1);
    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
      if (entry.getValue() != 2)
        ret = false;
    }
    if (ret)
      System.out.print("Yes");
    else
      System.out.print("No");
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 200005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi;
vector<lln> vl;
vector<pii> vii;
vector<pll> vll;


llu arr[maxii];
llu arr2[maxii];
//bool check[maxii];
bool check2[1000][1000];
//lln n,m;
llu gcd(llu a,llu b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}


int main()
{
   int n;
   sc(n)
   for(int i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   llu g=1;
   sort(arr,arr+n);
   for(int i=0;i<n;i++)
   {
       g=(g/gcd(arr[i],g))*arr[i];
   }
   cout<<g<<endl;

}






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

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

  int a[100];
  double rec;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    rec += 1.0 / a[i];
  }

  double ans = 1.0 / rec;
  printf("%f\n", ans);

  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;

int K;
void input()
{
    cin>>K;
}

int gcd(int a, int b)
{
    int c=a%b;
    while(c!=0){
        a=b; b=c; c=a%b;
    }
    return b;
}

void solve()
{
    int ans=0;
    for(int i=1;i<=K;++i) ans+=i;
    for(int i=1;i<K;++i){
        for(int j=i+1;j<=K;++j){
            ans+=gcd(i,j)*6;
        }
    }
    for(int i=1;i<=K-2;++i){
        for(int j=i+1;j<=K-1;++j){
            for(int k=j+1;k<=K;++k){
                ans+=gcd(gcd(i,j),k)*6;
            }
        }
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 3620
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		out=new PrintWriter (new BufferedOutputStream(System.out));
		FastReader s=new FastReader();
		int n=s.nextInt();
		int w=s.nextInt();
		long[][] dp=new long[w+1][n];
		int[] weight=new int[n];
		long[] values=new long[n];
		for(int i=0;i<n;i++) {
			weight[i]=s.nextInt();
			values[i]=s.nextLong();
		}
		for(int i=0;i<w+1;i++) {
			Arrays.fill(dp[i], -1);
		}
		dp[w][0]=0;
		if(w>=weight[0])dp[w-weight[0]][0]=values[0];
		for(int i=1;i<n;i++) {
			for(int j=0;j<w+1;j++) {
				if(dp[j][i-1]!=-1) {
					dp[j][i]=Long.max(dp[j][i],dp[j][i-1]);
					if(j-weight[i]>=0)dp[j-weight[i]][i]=Long.max(dp[j][i-1]+values[i],dp[j-weight[i]][i]);
				}
			}
		}
		long ans=0;
		for(int i=0;i<w+1;i++) {
			ans=Long.max(ans, dp[i][n-1]);
		}
		out.println(ans);
		out.close();
	}

	public static PrintWriter out;
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	
}


Measured memory_bytes: 126920
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Map<Integer, Integer> heightsOfMountain = new HashMap<>();
		Scanner scanner = new Scanner(System.in);
		for(int i=1;i<=10;i++){
			int height = scanner.nextInt();
			heightsOfMountain.put(i, height);
		}
		
		Set<Entry<Integer, Integer>> set = heightsOfMountain.entrySet();
        List<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer, Integer>>(set);
        Collections.sort( list, new Comparator<Map.Entry<Integer, Integer>>()
        {
        			@Override
			public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2) {
				// TODO Auto-generated method stub
				 return (o2.getValue()).compareTo( o1.getValue() );
			}
        } );
        for(int i=0;i<3;i++){
        		Map.Entry<Integer, Integer> entry = list.get(i);
            System.out.println(entry.getValue());
        }
	}
}

Measured memory_bytes: 26256
//Problem *
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n,a[N][3],d[N][3];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)for(int j=0;j<3;j++)scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)for(int j=0;j<3;j++){
		for(int k=0;k<3;k++)if(j!=k)d[i][j]=max(d[i][j],d[i-1][k]);
		d[i][j]+=a[i][j];
	}
	printf("%d",max(max(d[n][0],d[n][1]),d[n][2]));
	return 0;
}

Measured memory_bytes: 2560
def joinWithSpace(list):
    return " ".join([str(s) for s in list])


x1, y1, x2, y2 = [int(s) for s in input().split(" ")]

x3 = x2 - (y2-y1)
y3 = y2 + (x2-x1)
x4 = x1 - (y2-y1)
y4 = y1 + (x2-x1)

print(joinWithSpace([x3, y3, x4, y4]))


Measured memory_bytes: 3188
import java.util.*;

public class Main{
    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int[] card_num = new int[101];
            int m = sc.nextInt();
            if(m==0){
                break;
            }
            int[] value = new int[m];
            int[] num = new int[m];
            for(int i = 0; i < m; i++){
                value[i] = sc.nextInt();
                num[i] = sc.nextInt();
            }
            int[] dp = new int[1001];
            dp[0] = 1;
            for(int i = 0; i < m; i++){
                for(int ii = 1000 - value[i] -1; ii >= 0; ii--){
                    for(int iii = 1; iii <= num[i]; iii++){
                        if(ii + value[i]*iii <= 1000){
                            dp[ii + value[i]*iii] += dp[ii];
                        }
                    }
                }
            }
            /*
              System.out.println(Arrays.toString(dp));
              for(int i = 0; i < 100; i++){
              System.out.println(i + " : " + dp[i]);
              }
            */
            int g = sc.nextInt();
            for(int i = 0; i < g; i++){
                System.out.println(dp[sc.nextInt()]);
            }
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}

Measured memory_bytes: 20904
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
#define ll long long
#define mod 1000000007
int main(){
    ll n,x,m,i,j,amari,repeat=0,
    ans=0,a[100010]={},flag[100010]={},num[100010]={};
    scanf("%lld %lld %lld",&n,&x,&m);
    a[1]=x;
    flag[x]++;
    num[x]=1;
    ans+=a[1];
    for(i=1; i<100009; i++){
        a[i+1]=(a[i]*a[i])%m;
        flag[a[i+1]]++;
        if(flag[a[i+1]]==2)break;
        num[a[i+1]]=i+1;
        if(a[i+1]==0){
            printf("%lld",ans);
            return 0;
        }
        ans+=a[i+1];
    }
    ans=0;
    amari=(n+1-num[a[i+1]])%(i+1-num[a[i+1]]);
    for(j=i+1; j<=i+amari; j++){
        a[j]=(a[j-1]*a[j-1])%m;
        ans+=a[j];
    }
    for(j=1; j<num[a[i+1]]; j++){
        ans+=a[j];
    }
    for(j=num[a[i+1]]; j<i+1; j++){
        repeat+=a[j];
    }
    repeat*=(n+1-num[a[i+1]])/(i+1-num[a[i+1]]);
    ans+=repeat;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 4076
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		System.out.println(a*b/2);
	}
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}





Measured memory_bytes: 22996
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int n;
	cin>>n;
	char a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int W[n],E[n];
	memset(W,0,sizeof(W));
	if(a[0]=='W')W[1]=1;
	for(int i=1;i<n;i++){
		if(a[i]=='W')W[i+1]++;
		W[i]+=W[i-1];
	}
	memset(E,0,sizeof(E));
	if(a[n-1]=='E')E[n-2]=1;
	for(int i=n-2;i>=0;i--){
		if(a[i]=='E')E[i-1]++;
		E[i]+=E[i+1];
	}
	int ans=10000000;
	for(int i=0;i<n;i++)
		ans=min(ans,W[i]+E[i]);
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second

struct info
{
	ll b, l, u;
};

int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	ll n, x;
	cin >> n >> x;
	vector<info> a(n);
	for (auto &i : a)
		cin >> i.b >> i.l >> i.u;

	sort(a.begin(), a.end(), [&](const info &i, const info &y){ return i.b*i.l + i.u * (x - i.b) > y.b*y.l + y.u * (x - y.b); });

	vector<ll> temp(1);
	for (int i = 0; i < n; ++i)
		temp.push_back(temp.back() + a[i].u * (x - a[i].b));

	vector<ll> temp2(1);
	for (int i = 0; i < n; ++i)
		temp2.push_back(temp2.back() + a[i].l * (-a[i].b));

	temp.erase(temp.begin());
	temp2.erase(temp2.begin());

	auto get = [&](vector<ll> &q, int i, int j)
	{
		if (i > j) return 0LL;
		if (i == 0) return q[j];
		return q[j] - q[i-1];
	};

	ll l = 0, r = x*n;
	while (l < r)
	{
		ll m = (l+r) >> 1;

		ll k = m;
		ll take = min(n, k/x);
		k -= take * x;

		if (take == n) k = 0;

		ll best = numeric_limits<ll>::min();
		for (int i = 0; i < n; ++i)
		{
			ll cur = 0;
			if (k == 0)
			{
				cur = get(temp, 0, take-1) + get(temp2, take, n-1);
			}
			else if (i <= take)
			{
				cur = get(temp, 0, take) - get(temp, i, i) + max((k - a[i].b)*a[i].l, (k - a[i].b)*a[i].u) + get(temp2, take+1, n-1);
			}
			else
			{
				cur = get(temp, 0, take-1) + max((k - a[i].b)*a[i].l, (k - a[i].b)*a[i].u) + get(temp2, take, n-1) - get(temp2, i, i);
			}

			best = max(best, cur);
		}

		if (best >= 0)
			r = m;
		else
			l = m+1;
	}

	cout << l << "\n";

	return 0;
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

ll n;
ll t[105];
ll m;
ll a[105];

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

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

cin>>m;
for(int i=0; i<m; i++){
  ll p,x;
  cin>>p>>x;
  for(int j=0; j<n; j++){
    if(j+1==p) a[i]+=x;
    else a[i]+=t[j];
  }
}

for(int i=0; i<m; i++){
  cout<<a[i]<<endl;
}

}





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

using namespace std;

typedef unsigned long long ull;

int main()
{
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    
   // freopen("AtCoder2/input.txt", "r", stdin);
    //freopen("AtCoder2/output.txt", "w", stdout);
    
    int q;
    ull t;
    cin >> q;
    ull a[q], b[q];
    for (int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < q; i++)
    {
        t = sqrt(a[i] * b[i]);
        if (a[i] == b[i])
        {
            cout << 2 * (a[i] - 1) << endl;
        }
        else if (t * t == a[i] * b[i])
        {
            cout << 2 * t - 3 << endl;
        }
        else if (t * (t + 1) >= a[i] * b[i])
        {
            cout << 2 * t - 2 << endl;
        }
        else
        {
            cout << 2 * t - 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.math.*;
import java.util.*;

class Main{
	int count(String s,String pat){
		int res=0;
		for(int i=-1;;){
			i=s.indexOf(pat,i+1);
			if(i==-1)
				break;
			res++;
		}
		return res;
	}
	void run()throws IOException{
		while(hasNext()){
			String s=next();
			int joi=count(s,"JOI");
			int ioi=count(s,"IOI");
			writer.println(joi);
			writer.println(ioi);
		}
	}
	
	// ---------- begin template ----------
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	boolean hasNext()throws IOException{
		while(tokenizer==null || !tokenizer.hasMoreTokens()){
			String s=reader.readLine();
			if(s==null)
				return false;
			tokenizer=new StringTokenizer(s);
		}
		return true;
	}
	String next()throws IOException{
		while(tokenizer==null || !tokenizer.hasMoreTokens())
			tokenizer=new StringTokenizer(reader.readLine());
		return tokenizer.nextToken();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(next());
	}
	long nextLong()throws IOException{
		return Long.parseLong(next());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(next());
	}
	BigInteger nextBigInteger()throws IOException{
		return new BigInteger(next());
	}
	void main(){
		try{
			reader=new BufferedReader(new InputStreamReader(System.in));
			tokenizer=null;
			writer=new PrintWriter(System.out);
			run();
			reader.close();
			writer.close();
		}
		catch(Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	public static void main(String[] args){
		new Main().main();
	}
	// ---------- end template ----------
}

Measured memory_bytes: 10000
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

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

	if (a == b) {
		std::cout << "Yay!" << std::endl;
	} else {
		if(a > 8 || b > 8) {
			std::cout << ":(" << std::endl;
		} else {
			std::cout << "Yay!" << std::endl;
		}
	}

	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Enum various numbers
//-------------------------------------------------
namespace Enum
{
    using fint = ::std::int_fast64_t;
    //素因数分解(素因数列挙)
    ::std::map<fint,int> factor(fint n)
    {
        ::std::map<fint,int> ret;
        for(fint i=2; i*i<=n; i++){
            while(n%i==0){
                ret[i]++;
                n/=i;
            }
        }
        if (n!=1) ret[n]++;
        return ret;
    }
    //約数列挙
    ::std::vector<fint> divisor(fint n)
    {
        ::std::vector<fint> ret;
        for(fint i=1; i*i<=n; i++){
            if (n%i==0){
                ret.push_back(i);
                if (i*i!=n) ret.push_back(n/i);
            }
        }
        return ret;
    }
    //商列挙(割る最小の数と商のペア)
    ::std::vector<::std::pair<fint,fint> > quotient(fint n)
    {
        ::std::vector<::std::pair<fint,fint> > ret;
        fint i=0;
        for(i=1; i*i<=n; i++){
            ret.emplace_back(i,n/i);
        }
        for(; i<=n; i++){
            fint d = n/i;
            ret.emplace_back(i,d);
            i+=(n-d*i)/d;
        }
        return ret;
    }
    //素数判定(おまけ)
    bool isprime(fint n)
    {
        for(fint i=2; i*i<=n; i++){
            if (n%i==0) return false;
        }
        return true;
    }
}

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    int ans=0;
    for(int i=1; i<=N; i+=2){
        auto div = Enum::divisor(i);
        if (div.size()==8) ans++;
    }
    cout<<ans<<"\n";
    return 0;
}


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

namespace Pair
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = Int32.Parse(Console.ReadLine());
            int count = 0;
            
            for(int i = 0; i < K; i=i+2)
            {
                for(int j = 1; j < K; j=j+2)
                {
                    count += 1;
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int main(){
    int N, M;
    cin >> N >> M;
    
    map<int, int> cm;

    //int* sm = new int(M);
    //int* cm = new int(M);
    int s, c;
    bool bRet = true;
    int ans = -1;
    map<int, int>::iterator it;
    pair<int, int> p;

    rep(i, M){
        cin >> s >> c;
        
        if(cm.insert(pair<int, int>(s, c)).second == false && cm[s] != c){
            bRet = false;
            break;
        }
    }
    int a = 1;
    rep(i, N -1)
        a *= 10;

/*
    if(M == 0){
        bRet = false;
    }
*/
    it = cm.find(1);
    if(it == cm.end()){
        ;
    }else{
        if(N != 1 && it->second == 0){
            bRet = false;
        }
    }
    
    if(bRet){
        ans = 0;
        it = cm.begin();
        for (; it != cm.end(); ++it)
        {
            int tmp = it->second;
            rep(i, N - it->first)
                tmp *= 10;
            ans += tmp;
        }
        if(ans == 0 && N != 1){
            ans = 1;
            rep(i,N - 1)
                ans *=10;
        }else if(ans < a && N != 1){
            ans += a;
        }

        int count = 0;
        int ans2 = ans;
        rep(i, N){
            if(ans2 != 0){
                count++;
                ans2 /= 10;
            }
        }
        if(ans == 0){
            count = 1;
        }
        if(count != N){
            ans = -1;
        }
    } 
    if(M == 0){
        if(N==1){
            ans = 0;
        }else{
            ans = 1;
            rep(i, N - 1){
                ans *= 10;
            }
        }       
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

ans = 0
passengers = 1
lasttime = T[0]
for i in range(1, N):
    if T[i] - lasttime > K:
        ans += 1
        passengers = 1
        lasttime = T[i]
    else:
        if passengers < C:
            passengers += 1
        else:
            ans += 1
            passengers = 1
            lasttime = T[i]
print(ans + 1)


Measured memory_bytes: 7420
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = ll(1e18) + 1;

int main(void)
{
    ll a, b, k;

    cin >> a >> b >> k;

    a -= k;

    if (a < 0)
    {
        b += a;

        if (b < 0)
        {
            b = 0;
        }

        a = 0;
    }

    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    ll x;
    cin >> x;
    ll ans = x / 11 * 2;
    if (x % 11 == 0) {
    } else if (x % 11 <= 6) {
        ans++;
    } else {
        ans += 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    int N, M;
    vector<pair<int, int>> v;
    cin >> N >> M;
    for (int i = 0; i < N; ++i){
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(), v.end());
    
    ll j = M, ans = 0;
    for (int i = 0; i < N; ++i){
        ll a = v[i].first;
        ll b = v[i].second;
        if (j >= b) {
            j -= b;
            ans += a * b;
        }else{
            ans += a * j;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <string>
#include <algorithm>
#define re register
#define maxn 100010
#define FOR(i, l, r) for(re int i = l; i <= r; ++i)
using namespace std;

int n, m , c, r, t, x, y, z;
char s[maxn];

int main() {
	scanf("%s", &s);
	n = strlen(s);
    FOR(i, 0, n-9)
      cout << s[i];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n;
  cin>>n;
  long long a[n][n];
  REP(i,n){
    REP(j,n){
      cin>>a[i][j];
    }
  }
  REP(i,n){
    REP(j,n){
      REP(k,n){
        if(a[i][k]+a[k][j]<a[i][j]){
          cout<<-1<<endl;
          return 0;
        }
      }
    }
  }
  long long ans=0;
  REP(i,n){
    REP(j,i){
      ans += a[i][j];
    }
  }
  vector<vector<bool>> used(n,vector<bool>(n,false));//辺が取り除かれている場合、trueにする。
  REP(k,n){
    REP(i,n){
      REP(j,n){
        if(k!=i && k!=j && a[i][k]+a[k][j]==a[i][j] && !used[i][k] && !used[k][j] && !used[i][j] && !used[k][i] && !used[j][k] && !used[j][i]){
          used[i][j] = used[j][i] = true;
          ans -= a[i][j];
        }
      }
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    int y=0,box;
    for(int i=1;i<=100;i++){
        box = y;
        for(int j=0;j<n;j++){
                if(j==0){
                    y=0;
                }
                y += (x[j]-i)*(x[j]-i);
        }
        if(i>1){
            y = min(y,box);
        }
    }
    cout << y << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>
#include <stdbool.h>

int main(void){
    int train, taxi, member, mul, min;
    scanf("%d" "%d" "%d", &member, &train, &taxi);
    mul = train * member; 
    if(mul < taxi){
        printf("%d\n", mul);
    }
    else if(mul >= taxi){
        printf("%d\n", taxi);
    }
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>
#define SIZE 6005

using namespace std;
typedef long long int ll;


int main()
{
	int n;
	scanf("%d",&n);

    int v[] = {1, 2, 3, 5, 6, 9, 10, 13, 14, 17};
    for (int i = 0; i < 10; i++){
        if (n == v[i]){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


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

int main(){
  ll n;
  cin>>n;
  double sum=0;
  cout<<fixed<<setprecision(10);
  rep(i,n){
    double a;
    cin>>a;
    sum+=1/a;
  }
  cout<<1/sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
int a[205];
void slove()
{
    int n, l;
    scanf("%d %d" ,&n ,&l);
    int f, e; 
    f=l;e=l+n-1;
	int ans=(f+e)*(e-f+1)/2;
	if(f<=0 and e>=0)
		printf("%d\n",ans);
	else if(f<=0 and e<=0)
		printf("%d\n",ans-e);
	else
		printf("%d\n",ans-f);
    return ;
}
signed main()
{
    slove();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 200005
#define inf 1e17
#define eps 1e-6
#define ll long long
#define ull unsigned long long
#define main() int main()
#define pii pair<int, ll>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define sa(x) scanf("%d",&x)
#define sab(x,y) scanf("%d%d",&x,&y)
#define pa(x) printf("%d",&x)
#define pab(x,y) printf("%d%d",x,y) 
#define ms(a,x) memset(a,x,sizeof(a))
#define IO ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define ff0(i,n) for(int i=0;i<n;++i)
#define ff1(i,n) for(int i=1;i<=n;++i)
main()
{
    int n;
    cin>>n;
    string s;
    map<string,int> mp;
    int minn=0;
    while(n--)
    {
    	cin>>s;
    	mp[s]++;
    	minn=max(minn,mp[s]);
	}
	for(auto w:mp)
	{
		if(w.sec==minn)
		{
			cout<<w.fir<<endl;
		}
	}
}

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

int main(){
  ll A,V,B,W,T;cin>>A>>V>>B>>W>>T;
  if(W>=V) cout<<"NO"<<endl;
  else{
    if(B>A){
      B = B + W*T;
      A = A + V*T;
      if(B>A)cout<<"NO"<<endl;
      else cout<<"YES"<<endl;
    }
    else{
      B = B - W*T;
      A = A - V*T;
      if(B<A)cout<<"NO"<<endl;
      else cout<<"YES"<<endl;
    }
  }
}

Measured memory_bytes: 3636
N, M = map(int, input().split())
H = list(map(int, input().split()))

E = [[] for _ in range(N)]
for m in range(M):
    A, B = map(int, input().split())
    E[A-1].append(B-1)
    E[B-1].append(A-1)

ans = 0
for i in range(N):
    good = True
    for j in E[i]:
        if H[i]<=H[j]:
            good=False
            break
    if good: ans+=1

print(ans)


Measured memory_bytes: 29492
N=int(input())
S=input()
count=0
res=0

for i in range(len(S)-1):
    #print(S[i+1:])
    #print(S[:i+1])
    Foward=set(S[i+1:])
    Rear=set(S[:i+1])
    count_prev=res
    count=0

    for j in Foward:
        #print(Foward[i+1:])
        #print(Rear)
        #print(j)
        if(j in Rear):
            #print("out")
            count+=1
            #print(count)
    res=max(count,count_prev)
    #print(count,count_prev)
print(res)

Measured memory_bytes: 3064
from heapq import*
I=float("inf")
def m():
 n=int(input())
 A=[]
 for _ in[0]*n:
  e=list(map(int,input().split()))
  A+=[zip(e[2::2],e[3::2])]
 d=[0]+[I]*n
 H=[(0,0)]
 while H:
  u=heappop(H)[1]
  for v,c in A[u]:
   t=d[u]+c
   if d[v]>t:
    d[v]=t
    heappush(H,(t,v))
 print('\n'.join(f'{i} {d[i]}'for i in range(n)))
m()


Measured memory_bytes: 40084
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string key,s;
    int n=0;
    cin>>key;
    for (int i = 0; i < key.size(); i++)key[i]=tolower(key[i]);
    while(cin>>s){
        if(s=="END_OF_TEXT")break;
        for (int i = 0; i < s.size(); i++)s[i]=tolower(s[i]);
        if(s==key)n++;
    }
    cout << n << endl;
}


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

namespace Contest
{
	class Program
	{
		static void Main()
		{
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (n % 2 == 0)
            {
                for (int i = n - 1; i > 0; i -= 2)
                {
                    Console.Write($"{a[i]} ");
                }
                for (int i = 0; i < n - 2; i += 2)
                {
                    Console.Write($"{a[i]} ");
                }
                Console.WriteLine(a[n - 2]);
            }
            else
            {
                for (int i = n - 1; i > 1; i -= 2)
                {
                    Console.Write($"{a[i]} ");
                }
                Console.Write(a[0]);
                if (n > 1)
                {
                    for (int i = 1; i < n; i += 2)
                    {
                        Console.Write($" {a[i]}");
                    }
                }
                Console.WriteLine();
            }
#if DEBUG
            Console.ReadKey();
#endif
		}
	}
}

Measured memory_bytes: 37420
// ABC 080 B- Harshed Number
/*
  各桁の和ってどうプログラムすればええんだ
  あ、10で割り続けて、商と余りを考えればいいんだ
*/
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, sum = 0 ;
  cin >> N;

  int N2 = N;
  while (N != 0) { // Nが0になるまで割り続ける。
    sum += N % 10; // 総和を更新して
    N /= 10; // Nを更新 N = N / 10 → N /= 10
  }
  if (N2 % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3596
#include <stdio.h>
int main(void){
  int n,a,i,max=-1000001,min=1000001;
  long long int sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(a>max)max=a;
    if(a<min)min=a;
    sum+=a;
  }
  printf("%d %d %lld\n",min,max,sum);
  return 0;
}

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

typedef vector<int> vi;
typedef pair<int, int> pii;
#define endl "\n"
#define sd(val) scanf("%d", &val)
#define ss(val) scanf("%s", &val)
#define sl(val) scanf("%lld", &val)
#define debug(val) printf("check%d\n", val)
#define all(v) v.begin(), v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val, 0, sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ                            \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

#define testcase(t) \
    while (t--)     \
        solve();

void solve()
{
}

int32_t main()
{
    FIO;
    //OJ;

    int n;
    cin >> n;
    vector<long long> ar(n, 0);
    for (auto &x : ar)
        cin >> x;

    long long res = 0;
    for (int i = 1; i < n; i++)
    {
        if (ar[i] < ar[i - 1])
        {
            long long t = abs(ar[i] - ar[i - 1]);
            ar[i] = ar[i] + t;
            res += t;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4776
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
        
  	int a = N/100;
    int b = (N -a*100)/10;
    int c = N-a*100-b*10;
    
    if(a==7 || b==7 || c==7){
    System.out.println("Yes");
    }else{
    System.out.println("No");
    }
  }
}


Measured memory_bytes: 35776
while True:
    i = list(map(int, input().split()))
    if i[0] == 0 and i[1] == 0:
        break
    else:
        for j in range(i[0]):
            for k in range(i[1]):
                print("#", end='')
            print("\n", end='')
        print("\n", end='')


Measured memory_bytes: 7016
#include <bits/stdc++.h>
using namespace std;
 
#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

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

    REP(i, 50000) {
        if ((int)(i * 1.08) == N) {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const* argv[])
{
	int buf[3];
  	int sum1,sum2;
  	int i;
  	for(i=0;i<3;i++)
    {
    	cin>>buf[i];
    }
  	sort(buf,buf+3);
  	sum1=buf[2]-buf[1]+buf[1]-buf[0];
    cout<<sum1<<endl;
  
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    k = ri()
    print("ACL"*k)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9088
#include <iostream>

using namespace std;

int main(){
  int n;
  int m	= 1;
  long a;
  long prev = -1;;
  int sign = 0;
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> a;
    long diff =	a - prev;
    if (prev > 0) {
      if (sign == 0) {
        if (diff > 0) {
          sign = 1;
        } else if (diff < 0) {
          sign = -1;
        }
      }	else {
	if (diff * sign < 0) {
          sign = 0;
          m++;
        }
      }
    }
    prev = a;
    //    cout << a << "\t" << sign << "\t" << m << endl;                                                              
  }
  cout << m << endl;
}


Measured memory_bytes: 256