akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static class Train implements Comparable<Train>{
		int station;
		int time;
		boolean getted;
		
		public Train(int station, int time, boolean getted) {
			super();
			this.station = station;
			this.time = time;
			this.getted = getted;
		}

		@Override
		public int compareTo(Train arg0) {
			return this.time - arg0.time;
		}
	}
	
	public static final int MAX_EDGE = 5000;
	public static final int MAX_NODE = 500;
	
	public static final int INF = Integer.MAX_VALUE / 2 - 1;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String[][] data = new String[MAX_EDGE][2];
		int[] dist = new int[MAX_EDGE];
		int[] delay  = new int[MAX_EDGE];
		int[][] adj = new int[MAX_NODE][MAX_NODE];
		boolean[][] is_visited = new boolean[MAX_NODE][2];
		
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		
		while(true){
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			
			if(n == 0 && m == 0){
				break;
			}
			
			map.clear();
			
			String start = sc.next();
			String inter = sc.next();
			String goal  = sc.next();
			
			map.put(start, 0);
			map.put(inter, 1);
			map.put(goal , 2);
			
			for(int i = 0; i < m; i++){
				data[i][0] = sc.next();
				data[i][1] = sc.next();
				dist[i] = sc.nextInt();
				delay[i] = sc.nextInt();
			}
			
			int count = 3;
			for(int i = 0; i < m; i++){
				for(int j = 0; j < 2; j++){
					if(!map.containsKey(data[i][j])){
						map.put(data[i][j], count);
						count++;
					}
				}
			}
			
			for(int i = 0; i < n; i++){
				for(int j = i + 1; j < n; j++){
					adj[i][j] = adj[j][i] = INF;
				}
				
				
				is_visited[i][0] = false;
				is_visited[i][1] = false;
			}
			
			for(int i = 0; i < m; i++){
				int from = map.get(data[i][0]);
				int to   = map.get(data[i][1]);
				
				adj[from][to] = adj[to][from] = dist[i] / 40 + delay[i];
			}
			
			PriorityQueue<Train> queue = new PriorityQueue<Main.Train>();
			queue.add(new Train(0, 0, false));
			
			boolean getted = false;
			while(!queue.isEmpty()){
				Train train = queue.poll();
				
				if(getted && !train.getted){
					continue;
				}
				
				if(is_visited[train.station][train.getted ? 1 : 0]){
					continue;
				}else{
					is_visited[train.station][train.getted ? 1 : 0] = true;
				}
				
				if(train.station == 2 && train.getted){
					System.out.println(train.time);
					break;
				}
				
				if(train.station == 1 && !train.getted){
					train.getted = true;
					getted = true;
				}
				
				for(int to = 0; to < n; to++){
					if(adj[train.station][to] < INF && !is_visited[to][train.getted ? 1 : 0]){
						queue.add(new Train(to, train.time + adj[train.station][to], train.getted));
					}
				}
				
			}
			
			
		}
		
	}

}

Measured memory_bytes: 81064
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

using namespace std;

int main() 
{   
    int ans = 0;
    int n, k;
    cin >> n >> k;
    map<int, int> a;

    irep(i,n) {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }
    
    vector<int> b;
    for(auto ball : a) {
        b.push_back(ball.second);
    }
    sort(b.begin(), b.end());

    if(a.size() > k) {
        irep(i,a.size() - k) {
            ans += b[i];
        }
        cout << ans << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}
    



Measured memory_bytes: 10748
#include <stdio.h>
int min(int a,int b)
{
    int m=a;
    if(a>b){m=b;}
    return m;
}

int main() {
    int a,b,c,d;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    
    printf("%d\n",min(a,b)+min(c,d));
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	int n;
	cin>>n;

	int t=0;
	rep(i,n){
		ll a;
		cin>>a;
		int f=0;
		for(int i=2; i<=sqrt(a); i++){
			if(a%i==0){
				f=1;
				break;
			}
		}
		if(f==0)t++;
	}
	cout<<t<<endl;

	return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

ll euclidean_gcd(ll a, ll b)
{
    if(a<b) swap(a, b);
    ll r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }

    return b;
}

int main()
{
    ll A,B;
    cin >> A >> B;
    ll M=euclidean_gcd(A,B);
    ll ans=1;
    for(ll i=2; i<=1000010; i++){
        if(M%i==0){
            ans++;
            while(M%i==0){
                M/=i;
            }
        }
    }
    if(M>1000000) ans++;
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl;
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n; cin >> n;
    cout << pow(n, 3) << endl;
}

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


Measured memory_bytes: 4176
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "math"
)
 
func main() {
  stdin := bufio.NewScanner(os.Stdin)
  stdin.Scan()
  n_number, err := strconv.Atoi(stdin.Text())
  if err != nil {
        panic(err)
  }
  p_count := math.Pow(float64(n_number), 3)
  fmt.Println(p_count)
}

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

int main()
{
 

    long Q,H,S,D;
    cin>>Q>>H>>S>>D;

    long N;
    cin>>N;

    // unit price, litter
    vector<tuple<long, double> > tuples(4);

    tuples.at(0)=make_tuple(Q*4,0.25);
    tuples.at(1)=make_tuple(H*2,0.5);
    tuples.at(2)=make_tuple(S,1);
    tuples.at(3)=make_tuple(D/2,2);

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

    if(get<1>(tuples.at(0)) ==2){
        cout<<N/2*D+N%2*get<0>(tuples.at(1))<<endl;
    }
    else {
        cout<<N*get<0>(tuples.at(0))<<endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    n -= k;
    if (k == 1)
    {
        cout << 0;
    }
    else
    {
        cout << max(n,0);
    }
    return 0;
}


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

int main() {
	long long n;
	cin >> n;
	vector<int> arr;
	vector<int>::iterator ip;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		arr.push_back(a);
	}sort(arr.begin(), arr.end());
	ip = unique(arr.begin(), arr.begin() + n);
	int ans=distance(arr.begin(), ip);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x0123456789) cerr<<#x0123456789<<':'<<x0123456789<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x0123456789:v)cerr<<x0123456789<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

bool check(vector<int> v){
  if(v.size() < 2)return 1;
  FOR(i,0,v.size()-1){
    if(v[i+1]-v[i] < 2)return 0;
  }
  return 1;
}

signed main(){
  ll H,W,K;
  cin >> H >> W >> K;
  vector<vector<int>> v;
  FOR(i,0,(1<<(W-1))){
    vector<int> yay;
    FOR(j,0,W-1){
      if(i&(1<<j))yay.pb(j+1);
    }
    if(check(yay))v.pb(yay);
  }
  ll DP[H+1][W+1];
  FOR(i,0,H+1)FOR(j,0,W+1)DP[i][j] = 0;
  DP[0][1] = 1;
  FOR(i,1,H+1){
    FOR(j,0,v.size()){
      bool yay[W+1] = {0};
      FOR(k,0,v[j].size()){
        DP[i][v[j][k]] += DP[i-1][v[j][k]+1];
        DP[i][v[j][k]+1] += DP[i-1][v[j][k]];
        DP[i][v[j][k]] %= INF;
        DP[i][v[j][k]+1] %= INF;
        yay[v[j][k]] = 1;
        yay[v[j][k]+1] = 1;
      }
      FOR(k,1,W+1){
        if(!yay[k]){
          DP[i][k] += DP[i-1][k];
          DP[i][k] %= INF;
        }
      }
    }
  }
  cout << DP[H][K] << endl;
}


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

int main() {
	int n, max = 0, current = 0;
	string s;

	cin >> n >> s;

	vector<int> left(26, 0), right(26, 0);

	for (int i = 0; i < s.length(); i++) {
		right[s[i] - 'a'] += 1;
	}
	for (int i = 0; i < s.length(); i++) {
		right[s[i] - 'a'] -= 1;
		left[s[i] - 'a'] += 1;
		if (right[s[i] - 'a'] == 0 && left[s[i] - 'a'] != 1) {
			current--;
		}
		else if (right[s[i] - 'a'] != 0 && left[s[i] - 'a'] == 1) {
			current++;
		}
		if (current > max) {
			max = current;
		}
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAX = 1e5+5;
vector<LL> GRAPH[MAX];
bool vis[MAX];
stack<LL> s;
LL dist[MAX];

void DFS(LL x)
{
        vis[x] = true;
        for(int i = 0 ; i < GRAPH[x].size() ; i++)
        {
                if(!vis[GRAPH[x][i]])
                {
                        DFS(GRAPH[x][i]);
                }
        }
        s.push(x);
}


int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        LL n;
        cin >> n;
        double a[n+2] , dp[n+2][n+2];
        for(int i = 1 ; i <= n ; i++)
        {
                cin >> a[i];
        }
        for(int i = 0 ; i <= n ; i++)
        {
                dp[i][0] = 1;
        }
        double temp = 1;
        for(int i = 1 ; i <= n ; i++)
        {
                temp = temp* (1-a[i]);
                //cout << temp << " ";
                dp[0][i] = temp;
        }
        for(int i = 1 ; i <= n ; i++)
        {
                for(int j = 0 ; j <= n ; j++)
                {
                        if(j < i)
                        {
                                dp[i][j] = 0;
                                continue;
                        }
                        dp[i][j] = dp[i-1][j-1]*(a[j]) + dp[i][j-1]*(1-a[j]);
                }
        }
        double ans = 0;
        for(int i = n ; i >= 0 ; i--)
        {
                if(n-i > i) break;
                ans += dp[i][n];
        }
        printf("%.10f" , ans);
        return 0;
}

Measured memory_bytes: 72960
#pragma once

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

using namespace std;
long long int N, A, B;
long long int myMax,myMin;
long long int result;




int main() {
	cin >>N>> A >> B;
	
	if (N == 1) {
		if (A != B) {
			result = 0;
		}
		else {
			result = 1;
		}
	}
	else if (A > B) {
		result = 0;
	}
	else if (N==2) {
		result = 1;
	}
	else {
		myMax = B*(N - 1) + A;
		myMin = A*(N - 1) + B;
		result = myMax - myMin + 1;
	}
	cout <<result<< endl;

	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n, m, food[31] = {0}, k, count = 0;
  scanf("%d %d", &n, &m);getchar();
  for(int i = 0; i < n; i++){
    scanf("%d", &k);getchar();
    for(int j = 0; j < k; j++){
      int like;
      scanf("%d", &like);getchar();
      food[like]++;
    }
  }
  for(int i = 0; i <= m; i++){
    if(food[i] == n){
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 128
from math import atan2, pi

n = int(input())
e = []

for _ in range(n):
    x, y = map(int, input().split())
    r = atan2(y, x)
    if r < 0:
        r += pi * 2
    e.append([r, x, y])

e.sort()

ans = 0
for i in range(n):
    e.append([e[i][0] + pi * 2, e[i][1], e[i][2]])
    ans = max(ans, (e[i][1] ** 2 + e[i][2] ** 2) ** 0.5)

if n == 1:
    print(ans)
    exit()

for L in range(n):
    x = e[L][1]
    y = e[L][2]
    for R in range(L+1, L+n):
        x += e[R][1]
        y += e[R][2]
        ans = max(ans, (x ** 2 + y ** 2) ** 0.5)

print(ans)


Measured memory_bytes: 3444
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	long long N,min=100000000;
	cin>>N;
	long long a[100000],max=a[1];
	for(int i=1;i<=N;i++){
		cin>>a[i];
		if(a[i]>max) max=a[i];
	}
	for(int i=1;i<=max;i++){
		long long sum=0;
		for(int j=1;j<=N;j++){
			sum+=(a[j]-i)*(a[j]-i);
//			cout<<sum<<endl;
		}
		if(sum<min) min=sum;
	}
	printf("%lld\n",min);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    printf("%.10f\n",(double)n*n*n/27);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
int a[20];
vector<int> b,c;
int m;
int minsa;
 
int co(){
  int sum=0;
  for(int i=0;i<b.size();i++) sum+=b[i];
  for(int i=0;i<c.size();i++) sum-=c[i];
  if(sum<0) sum*=-1;
  return sum;
}
 
void dps(int u){
 
  if(u==m){
    int sa=co();
    if(sa<minsa) minsa=sa;
    else if(minsa==-1) minsa =sa;
  }
  else {
    b.push_back(a[u]);
    dps(u+1);
    b.pop_back();
    c.push_back(a[u]);
    dps(u+1);
    c.pop_back();
  }
}
 
 
int main(){
   
  while(1){
    cin >> m;
    if(m==0) break;
    
    for(int j=0;j<m;j++) cin >>a[j];
      minsa =-1;
      dps(0);
      cout << minsa << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<bitset>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n) cin >> vec[i];
    int sum = 0;
    rep(i,n)
        for(int j = i + 1; j < n; j++)
            sum += vec[i] * vec[j];
    
    cout << sum << endl;
}

Measured memory_bytes: 3600
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] h = new int[N];
    for (int i = 0; i < N; i++) h[i] = scanner.nextInt();

    for (int i = N - 1; i >= 1; i--) {
      if (h[i] < h[i - 1]) h[i - 1]--;
      if (h[i] < h[i - 1]) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
}


Measured memory_bytes: 50596
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.split("\n");
var nq=arr[0].split(" ").map(Number);
var str = arr[1];
var a=[0,0];
var cnt=0;
for(var i=1;i<str.length;i++){
   if(str[i]=="C" && str[i-1]=="A")cnt++;
      a.push(cnt);
   }
var ans=[];
for(var i=2;i<nq[1]+2;i++){
   var lr=arr[i].split(" ");
   ans.push(a[lr[1]-0]-a[lr[0]-0]);
}
console.log(ans.join("\n"));

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



int main(){
  ll h,w,k,s=0;
  cin >> h >> w >> k;
  vector<vector<char>>c(h,vector<char>(w));
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> c[i][j];
      if(c[i][j]=='#') s++;
    }
  }
  ll ans = 0;
  vector<ll>r(w),g(h);
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(c[i][j]=='#') g[i]++;
    }
    //if(s-g[i]==k) ans++;
  }
  
  for(int j=0; j<w; j++){
    for(int i=0; i<h; i++){
      if(c[i][j]=='#') r[j]++;
    }
    //if(s-r[j]==k) ans++;
  }
  
  //cout << ans << endl;
  
  for(int i=0; i<pow(2,h); i++){
    for(int j=0; j<pow(2,w); j++){
      ll count = 0;
      //cout << i << " " << j << endl;
      for(int x=0; x<h; x++){
        if(i >> x & 1 ) count+=g[x];
      }
      for(int y=0; y<w; y++){
        if(j >> y & 1) count+=r[y];
      }
      for(int x=0; x<h; x++){
        for(int y=0; y<w; y++){
           if(i >> x & 1 && j >> y & 1){
             if(c[x][y]=='#') count--;
           }
        }
      }
      
      if(s-count == k) ans++;
    }
  }
  cout << ans << endl;
}
       
        
      
  
    

Measured memory_bytes: 4108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace COJ1_7
{
    struct Node
    {
        public int value;
        public int parent;
        public int depth;
        public string type;
        public int[] children;
    }
    class Program
    {
        public static void GetDepth(Node[] nodes, int i, int depth)
        {
            nodes[i].depth = depth;
            for(int j = 0; j < nodes[i].children.Length; j++)
            {
                GetDepth(nodes, nodes[i].children[j], depth + 1);
            }
        }
        static void Main(string[] args)
        {
            int cnt;
            Node[] nodes;

            cnt = int.Parse(Console.ReadLine());
            nodes = new Node[cnt];

            for(int i = 0; i < cnt; i++)
            {
                nodes[i].parent = -1;
            }

            for(int i=0;i<cnt;i++)
            {
                int[] param = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                nodes[param[0]].value = param[0];
                if (param[1] == 0) nodes[param[0]].type = "leaf";
                else
                {
                    nodes[param[0]].type = "internal node";
                }
                nodes[param[0]].children = new int[param[1]];

                for (int j = 0; j < param[1]; j++)
                {
                    nodes[param[2+j]].parent = param[0];
                    nodes[param[0]].children[j] = param[2 + j];
                }
            }

            for(int i = 0; i < cnt; i++)
            {
                if (nodes[i].parent == -1)
                {
                    nodes[i].type = "root";
                    GetDepth(nodes, i, 0);
                }
            }

            StringBuilder builder = new StringBuilder();
            for(int i = 0; i < nodes.Length; i++)
            {
                builder.Append("node ").Append(i).Append(": ").Append("parent = ").Append(nodes[i].parent).Append(", depth = ").Append(nodes[i].depth).Append(", ").Append(nodes[i].type).Append(", [").Append(string.Join(", ", Array.ConvertAll(nodes[i].children,n=>n.ToString()))).Append("]\n");
            }
            Console.Write(builder.ToString());
        }
    }
}

Measured memory_bytes: 54032
#include <iostream>

#include <fstream>

#include <cstdio>

#include <cmath>

#include <vector>

#include <cstring>

#include <string>

#include <set>

#include <map>

#include <stack>

#include <queue>

#include <algorithm>

using namespace std;



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

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

#define FORR(i,a,b) for (int i=a; i>=b; --i)

#define ALL(c) (c).begin(), (c).end()

typedef long long ll;

typedef vector<int> VI;

typedef vector<ll> VL;






int main(){
  int x = 1;
  int i,K,N;
  cin >> N >> K;

  for(i=0;i<N;i++){
    int a = 2*x;
    int b = x + K;
    if(a<=b){
      x = a;
    }
    else {
      x = b;
    }

  }

  cout << x << endl;

  return 0;




}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int h, w; cin >> h >> w;
    VS s(h); cin >> s;
    int dy[] = { -1,0,0,1 }, dx[] = { 0,-1,1,0 };
    FOR(y, 0, h)FOR(x, 0, w) {
        if (s[y][x] == '.')continue;
        bool ok = false;
        FOR(i, 0, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (out(ny, nx))continue;
            ok |= s[ny][nx] == '#';
        }
        if (!ok) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc046/tasks/arc062_a
# 条件を考えよう
# iのときの割合の人数n[i],m[i]を考えると
# n[i]=p*A[i], m[i]=p*B[i] かつ n[i]>=n[i-1], m[i]>=m[i-1] を満たす最小のn[i], m[i]
# このような条件を満たすpを探すのは容易だ
# n[i-1]//A[i] がn[i]をギリギリ超えないpなのだから、ギリギリ超えるpはn[i-1]//A[i] + 1 (ぴったり割り切れるときは注意)
# nについてもmについてもギリギリ越したいのだから大きい方を採用する。(小さい方では片方が超えなくなる)


N = int(input())
ans = 1


def ret_nm(t, a, n, m):
    times_t = (n - 1) // t + 1
    times_a = (m - 1) // a + 1
    times = max(times_t, times_a)
    return times * t, times * a


n = m = 1
for _ in range(N):
    t, a = map(int, input().split())
    n, m = ret_nm(t, a, n, m)


print(n + m)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll inf=1e18;
ll p= 1e9+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
typedef pair<ll, ll> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll i,j,x,y,k,t,n,z,c,d,r,m;
           cin>>n>>m;
           ll ans[n+1]={0};
           vector<vector<ll>>adj(n+1);
           while(m--)
           {
               cin>>x>>y;
               adj[x].pb(y);
               adj[y].pb(x);
           }
           queue<ll>q;
           q.push(1);
           ll used[n+1]={0};
           used[1]=1;
           while(!q.empty())
           {
               ll s=q.front();
               q.pop();
               for(auto u:adj[s])
               {
                   if(used[u]==0)
                   {
                       used[u]=1;
                       ans[u]=s;
                       q.push(u);
                   }
               }
               
           }
           ll f=1;
           for(i=2;i<=n;i++)
           {
               if(ans[i]==0)
               f=0;
           }
           if(f)
           {
               cout<<"Yes\n";
               for(i=2;i<=n;i++)
               cout<<ans[i]<<"\n";
           }
           else
           {
               cout<<"No";
           }
           
    return 0;
 
    
}

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

using namespace std;


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

    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        ans += L + i - 1;
    }

    if (L < 0) {
        if (N < abs(L - 1)) {
            ans -= L + (N - 1);
        }
    } else if (0 < L) {
        ans -= L;
    }

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


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

int main () {
    int n, k;
    std::cin >> n >> k;

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

    int ans = 0;

    int num = 0;
    do {

        if(!ans) {
            num += k;
        } else {
            num += k - 1;
        }

        ans++;
    } while (num < n);

    std::cout << ans << std::endl;
}

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

int main(){
	int n,k;
	cin>>n>>k;
	vector<int> arr(n,0);
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	long long int sum=0;
	sort(arr.begin(),arr.end());
	for(int i=0;i<k;i++){
		sum+=arr[i];
	}
	cout<<sum<<endl;
	return 0;
}

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

int main() {
  int N;cin>>N;
  vector<int> a(100010);
  for(int i=0;i<N;i++)cin>>a.at(i);
  int now=1;
  int cnt=0;
  bool ok=false;
  for(int i=0;i<N;i++){
    cnt++;
    now=a.at(now-1);
    if(now==2){
      ok = true;
      break;
    }
  }
  if(ok)cout<<cnt<<endl;
  else cout<<-1<<endl;
}


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

int main() {
  ll N,M,sum=0,result=0;


  cin >> N >> M;

  vector<ll> A(M);
  for(ll i=0;i<A.size();i++){
    cin >> A[i];
    sum += A[i];
  }

  result=N-sum;
  if(result>=0){
    cout << result << endl;
  }else{
    cout << -1 << endl;
  }
}


Measured memory_bytes: 3628
n, m = map(int, input().split())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
cd = []
for i in range(m):
    cd.append(list(map(int, input().split())))
for i in range(n):
    dis = []
    for j in range(m):
        dis.append(abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]))
    print(dis.index(min(dis)) + 1)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int N=S.length();
		int count=0;
		
		char[] s=S.toCharArray();
		char[] t=T.toCharArray();
		
		for(int i=0;i<N;i++) {
			if(s[i]!=t[i]) {
				count++;
			}
		}
		
		if(count==0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35684
n = int(input())
a = list(map(int, input().split()))
l = [0] * (n + 1)
l2 = list(range(n + 2))
l3 = list(range(n + 2))
ans = 0
for i in range(n):
    l[a[i]] = i
for i in range(1, n + 1)[::-1]:
    x, y = l2[l[i]], l3[l[i]]
    ans += (l[i] - x + 1) * (y - l[i] + 1) * i
    l2[y + 1], l3[x - 1] = x, y
print(ans)

Measured memory_bytes: 40692
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll n;
string s;
signed main() {
	cin >> n;
	cin >> s;
	if (n >= 3200)cout << s << endl;
	else puts("red");
	ggr
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var Y = cin.ReadInt;
            int x, y, z;
            x = 0;
            y = 0;
            z = 0;
            bool flag = false;
            for (x = 0; x <= N; x++)
            {
                for (y = 0; y <= N - x; y++)
                {
                    z = N - x - y;
                    if (10000 * x + 5000 * y + 1000 * z == Y)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    break;
                }
            }
            if (flag)
            {
                WriteLine(x + " " + y + " " + z);
            }
            else
            {
                WriteLine("-1 -1 -1");
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include <stdio.h>

int main(){
	int i,j,tmp;
	char str[128];

	while(scanf("%s",str) != EOF){
		i = 0;
		while(str[i] != '\0'){
			if(str[i] == '@'){
				i++;
				tmp = str[i] - '0';
				i++;
				for(j = 0;j < tmp;j++){
					putchar(str[i]);
				}
			}else{
				putchar(str[i]);
			}
			i++;
		}
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 524
# import sys

# n = input()
# last = 0
# result = []

# if len(n) == 1:
#     print(int(n))
#     sys.exit()

# for i in range(len(n)-1):
#     print('i',i)
#     s1 = n[:i+1]
#     s2 = n[i+1:]
#     for j in range(len(s2)-1):
#         s21 = s2[:j+1]
#         s22 = s2[j+1:]
#         result.append(int(s1)+int(s21)+int(s22))
#     print('s1 s2',s1,s2)
#     print('sum ',int(s1)+int(s2))
#     result.append(int(s1)+int(s2))

# for i in range(len(n)):
#     print('i n[i]',i,n[i])
#     last += int(n[i])

# result.append(last)
# result.append(int(n))
# print(result)
# print(sum(result))

S = str(input())
N = len(S) - 1
 
res = 0
 
for i in range(1<<N):
    t = ''
    for j in range(N):
        t += S[j]
        if((i>>j&1) > 0): t += '+'
    t += S[-1]
    res += eval(t)
print(res)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL MAXQ = 1007;
const int MAXN = 10007;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//	freopen("In.txt", "r", stdin);

	int h, w;
	cin >> h >> w;
	VVCH a(h, VCH(w));
	FOR(i, 0, h)
		FOR(j, 0, w)
		cin >> a[i][j];

	bool ok = 1;

	int last = 0;
	FOR(i, 0, h)
	{
		FOR(j, 0, last)
			if (a[i][j] == '#')
				ok = 0;

		if (a[i][last] == '.')
			ok = 0;

		while (last < w && a[i][last] == '#')
			++last;
		
		--last;
		FOR(j, last + 1, w)
			if (a[i][j] == '#')
				ok = 0;
	}

	if (ok)
		cout << "Possible";
	else
		cout << "Impossible";
	
	return 0;
}

Measured memory_bytes: 256
import itertools
n,m,q = map(int,input().split())
mx = 0
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
  ai,bi,ci,di = map(int,input().split())
  a[i] = ai-1
  b[i] = bi-1
  c[i] = ci
  d[i] = di
mx = 0
l = [i for i in range(m)]
for v in itertools.combinations_with_replacement(l, n):
  s = 0
  for i in range(q):
    if v[b[i]] - v[a[i]] == c[i]:
      s += d[i]
  if s > mx:
    mx = s
print(mx)

Measured memory_bytes: 68328
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

const int MAX_V = 110;
const int MAX_E = 1100;

int N, M;
int a[MAX_E], b[MAX_E], c[MAX_E]; // 各辺
int dist[MAX_V][MAX_V]; // Floyd-Warshall 用

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

    // Floyd-Warshall でよくやる初期化
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            dist[i][j] = INF;
        }
        dist[i][i] = 0; // ここがポイント
    }

    // 入力
    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        --a[i], --b[i];
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }

    // Floyd-Warshall
    for (int k = 0; k < N; ++k)
        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

    // 集計
    int res = 0;
    for (int i = 0; i < M; ++i) {
        if (c[i] > dist[a[i]][b[i]]) ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	int K = sc.nextInt();
        String S = sc.next();
        if (S.length() <= K)
            System.out.println(S);
        else
            System.out.println(S.substring(0,K) + "...");
    }
}

Measured memory_bytes: 38564
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
#define PP 1000000007
using namespace std;

int main(){
string S;cin >> S;

if(S.back() == 's')cout << S + "es";

else cout << S + 's';


}

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

using namespace std;

int memo[100005];
int stones[100005];

int ans_iterative(int n){
	if (memo[n] != -1){
		return memo[n];
	}
	else{
		for (int i = 2; i < n; ++i){
			memo[i] = min(
				memo[i - 1] + abs(stones[i] - stones[i - 1]),
				memo[i - 2] + abs(stones[i] - stones[i - 2])
			);
		}
		return memo[n - 1];
	}
}

int main() {
	int size;
	int temp;

	memset(memo, -1, sizeof(memo));

	cin >> size;

	for(int i = 0; i < size; ++i){
		cin >> temp;
		stones[i] = temp;
	}

	if(size == 1){
		cout << 0 << endl;
	}
	else{
		memo[0] = 0;
		memo[1] = abs(stones[0] - stones[1]);
		cout << ans_iterative(size) << endl;
	}


	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;

bool comp1(pair<ll int, pair<ll int, ll int > > l , pair<ll int, pair<ll int, ll int > > r){
	return l.first > r.first;
}
int main(){
	fast;
	auto start = high_resolution_clock::now(); 

	int n ;
	cin >> n;

	vector<pair<ll int, pair<ll int, ll int > >> a(n); 

	for(int i = 0 ; i < n ; i++){
		ll int x, y;
		cin >> x >> y;
		a[i] = mp(x+y, mp(x, y));
	}

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

	ll int sum = 0;
	int flag = 1;
	for(int i = 0 ; i<n ; i++){
		if(flag == 1)
			sum += a[i].second.first;
		else
			sum -= a[i].second.second;
		flag *= -1;
	}

	cout << sum ;
	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;


long long mid;
long long search(long long a, long long b){
  long long t = a * b;
  long long left, right;
  left = min(a, b);
  right = max(a, b);
  mid = (left + right) / 2 + 1;
  while (left != right) {
    mid = (left + right) / 2 + 1;
    if (mid * mid > t) {
      right = mid - 1;
    } else {
      left = mid;
    }
    //printf("%lld %lld %lld\n", left, mid, right);
  }
  //printf("\t%lld\n", left);
  mid = left;
  if ((t-1) / left <= left) {
    return left * 2 - 1;
  }
  return  left * 2;
}

int main(){
  int n;
  cin >> n;
  for (int nn = 0; nn < n; nn++ ) {
    long long a, b;
    cin >> a >> b;

    long long u = search(a, b);
    long long ans = u - 1;
    long long t = a * b;
    if (mid == 1) {
      cout << u - 1 << endl;
      continue;
    }
    for (int r = mid; r >= 1; r--) {
      if ((t-1) / r == (t-1) / (r-1)) ans--;
      else break;
    }
    for (int r = mid; r < max(a,b); r++) {
      if ((t-1) / r == (t-1) / (r+1)) ans--;
      else break;
    }
    cout << ans << endl;
  }
  return 0;
}


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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define b_e(a) a.begin(),a.end() //sort(b_e(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(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 p_b push_back
#define SZ(x) ((ll)(x).size()) //size()がunsignedなのでエラー避けに
#define endk '\n'


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


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




// --------- library end - //


int main(){

  ll H, W;
  cin >> H >> W;

  vector<string> cells;
  rep(i, H){
    cells.push_back(is());
  }

  vector<vector<ll> > dp(H, vector<ll>(W, -1) );
  dp[H-1][W-1] = 1;

  DREP(h, H-1, -1) DREP(w, W-1, -1){
    if (dp[h][w] != -1) continue; // ゴールマス
    if (cells[h][w] == '#'){
      dp[h][w] = 0;
      continue;
    }

    // 空マスだった場合
    ll tmp = 0;
    rep(i, 2){
      // 右、下を見る
      ll th = h + dx_4[i];
      ll tw = w + dy_4[i];
      if (th < H && tw < W) tmp += dp[th][tw];
    }
    dp[h][w] = tmp % MOD;
  }

  cout << dp[0][0] << endk;


}

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

#define ITEM_SIZE 100000

int main() {
  int n, k, w[ITEM_SIZE], mw = 0, wsum = 0, aw, awr, minw;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> w[i];
    wsum += w[i];
    if (w[i] > mw) {
      mw = w[i];
    }
  }
  aw = wsum / k;
  awr = wsum % k;
  if (mw > aw) {
    minw = mw;
  } else if (awr != 0) {
    minw = aw + 1;
  } else {
    minw = aw;
  }

  int P = minw;
  while(true) {
    int rk = k;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      if (P < (sum + w[i])) {
        rk--;
        sum = w[i];
      } else {
        sum += w[i];
      }
    }
    if (rk <= 0) {
      P++;
    } else {
      cout << P << endl;
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 3476
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n;
int main()
{
	cin>>n;
	char c=getchar();
	c=getchar();
	while(c>='A'&&c<='Z')
	{
		c+=n;
		while(c>'Z') c-=26;
		cout<<c;
		c=getchar();
	}
	return 0;
}

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

int main() {
    int n;
    std::cin >> n;
    std::vector<int> s(n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        std::cin >>  s[i];
        sum += s[i];
    }

    std::sort(s.begin(), s.end());

    for (int i = 0; i < n; i++) {
        if(sum%10 == 0 && sum != 0){
            if(s[i]%10 == 0) {
                continue;
            }

            sum -= s[i];
        } else {
            break;
        }
    }

    bool f = false;
    for (int i = 0; i < n; i++) {
        if(s[i]%10) {
            f = true;
            break;
        }
    }

    if(!f) {
        sum = 0;
    }

        std::cout << sum << "\n";
}

Measured memory_bytes: 3588
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int X;
	cin >> X;
	eFOR(i, 1,10000000) {
		if (i*(i + 1) >= 2 * X) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 256