akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define foreach(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define all(c) begin(c),end(c)
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int h,w;cin>>h>>w,h|w;){
		vs d(h);
		rep(i,h) cin>>d[i];
		map<string,int> cnt;
		int di[]={-1,-1,-1,0,0,1,1,1},dj[]={-1,0,1,-1,1,-1,0,1};
		rep(i0,h) rep(j0,w) rep(k,8){
			string s;
			vvi vis(h,vi(w));
			for(int i=i0,j=j0;!vis[i][j];i=(i+di[k]+h)%h,j=(j+dj[k]+w)%w){
				s+=d[i][j];
				vis[i][j]=1;
				cnt[s]++;
			}
		}
		string res;
		for(auto kv:cnt) if(kv.second>=2){
			string s=kv.first;
			if(s.size()>res.size() || s.size()==res.size() && s<res)
				res=s;
		}
		cout<<(res.size()>=2?res:"0")<<endl;
	}
}

Measured memory_bytes: 36048
#include<bits/stdc++.h> 
using namespace std; 
#define deb(x) cout <<"\n"<< (#x) << " = " << (x) << "\n"
const long long  INF = 1e18;
const long long mod=1e9+7 ;
void inputoutput()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); 
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	    
}


vector<int> adj[200500];
vector<int> vis(200500);

void dfs(int v,int& ans)
{
	++ans;
	vis[v]=true;
	for(auto u : adj[v])
	{
		if(!vis[u])
			dfs(u,ans);
	}
}



void solve()
{
		// dfs implementation in undirected graph
	int n ;   // no. of vertices
	cin>>n ;
	int e;    // no. of edjes
	cin>>e;
	for(int i=0 ; i<e ; ++i)
	{
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int sol=INT_MIN ;
	for(int i=1 ; i<=n ; ++i)
	{
		if(!vis[i])
		{
			int ans=0;
			dfs(i,ans);
			sol=max(sol,ans);
		}
	}

	cout<<sol<<"\n";


}

int32_t main()
{ 
	inputoutput() ;
	solve();


	return 0;
}


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

int main(){
  string s; cin >> s;
  int sz=s.size();
  int ans=sz;
  for(int i=1;i<sz;++i){
    if(s[i-1]!=s[i]) {
      ans=min(ans,max(i,sz-i));
    }
  }
  if(sz==1) ans=1;
  cout << ans << endl;
      
  return 0;
}


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

int main() {
    ll n, m;
    cin >> n >> m;
    if (n >= m / 2) {
        cout << m / 2 << endl;
    } else {
        m -= 2 * n;
        cout << n + m / 4 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d;
  	cin >> a >> b >> c >> d;
  	int x = (a + d - 1) / d;
  	int y = (c + b - 1) / b;
  	x >= y ? (cout << "Yes\n") : (cout << "No\n");
}


Measured memory_bytes: 3584
import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int m = sc.nextInt();
    
    int[] aList = new int[a];
    int[] bList = new int[b];
    
    int aMin = 100000;
    int bMin = 100000;
    
    for(int i = 0; i < a; i++){
      aList[i] = sc.nextInt();
      if (aMin > aList[i]){
        aMin = aList[i];
      }
    }

    for(int i = 0; i < b; i++){
      bList[i] = sc.nextInt();
      if (bMin > bList[i]){
        bMin = bList[i];
      }
    }
    
    int ans = aMin + bMin;

    for(int i = 0; i < m; i++){
      int a1 = sc.nextInt();
      int b1 = sc.nextInt();
      int m1 = sc.nextInt();
      int price = aList[a1-1] + bList[b1-1] - m1;
      
      if (ans > price){
        ans = price;
      } 
    }
    
    System.out.println(ans);
  }
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  vector<int> g(N,0);
  REP(i, M){
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    g[a[i]]++;
    g[b[i]]++;
  }
  REP(i, N){
    cout << g[i]<< endl;
  }


  return 0;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  int a[27] = {};
  bool flag = true;
  for(int i = 0; i < s.size(); i++){
    if(a[t[i] - 'a'] == 0) a[t[i] - 'a'] = (int)s[i] - 'a';
    if(a[t[i] - 'a'] != s[i] - 'a'){
      flag = false;
      break;
    }
  }
  memset(a, 0, sizeof(a));
  for(int i = 0; i < s.size(); i++){
    if(a[s[i] - 'a'] == 0) a[s[i] - 'a'] = (int)t[i] - 'a';
    if(a[s[i] - 'a'] != t[i] - 'a'){
      flag = false;
      break;
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 776
import java.util.*;

public class Main {

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

    void run(){
        Scanner sc = new Scanner(System.in);

        for(;;){
            int n = sc.nextInt();
            if(n == 0){
                break;
            }

            int[] s = new int[n];
            for(int i =0 ; i < n ; i++){
                s[i] = sc.nextInt();
            }
            System.out.println(solve(s));

        }
    }

    int solve(int[] s){
        int min = s[0];
        int max = s[0];
        long sum = 0L;

        for(int i = 0; i < s.length; i++){
            min = Math.min (min, s[i]);
            max = Math.max(max,s[i]);
            sum += s[i];
        }

        return (int)(sum - min -max )/ (s.length-2);

    }

}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/12/12  Problem: ARC 006 A / Link: http://arc006.contest.atcoder.jp/tasks/arc006_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin >> N;
	auto f = [](LL N) {
		string s = to_string(N);
		int ret = accumulate(ALL(s), 0) - SZ(s)*('0');
		return ret;
	};


	string ans = (N%f(N)==0?"Yes":"No");
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] v = new int[n];
		Arrays.fill(v, -1);
		
		for (int i = 0; i < m; i++) {
			int s = sc.nextInt() - 1;
			int c = sc.nextInt();
			
			if (v[s] != -1 && v[s] != c) {
				System.out.println(-1);
				sc.close();
				return;
			}
			
			v[s] = c;
		}
		
		if (n > 1 && v[0] == 0) {
			System.out.println(-1);
			sc.close();
			return;
		}
		
		for (int i = 0; i < v.length; i++) {
			System.out.print(v[i] > 0 ? v[i] : (i == 0 ? (n == 1 ? 0 : 1) : 0));
		}
		System.out.println();
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int VMAX = 2e5+10;

vector<vector<int> > G(VMAX);
vector<int> d(VMAX,0);
vector<int> P(VMAX,0);

void dfs(int cur, int v,int p){
  d[v] = cur;
  for(const int& u : G[v]){
    if(u == p)continue;
    dfs(cur+1,u,v);
  }
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int V;cin >> V;
  rep(i,V-1){
    int x,y;cin >> x >> y;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  dfs(0,1,0);

  int n_odd = 0;
  int n_even = 0;
  repp(v,1,V+1){
    if(d[v]%2==1) ++n_odd;
    else ++n_even;
  }

  vector<int> P(VMAX,0);
  int X[3];
  X[0] = 3;
  X[1] = 1;
  X[2] = 2;
  auto add = [](int& x, int & y){
    x = y;
    y+=3;
  };
  repp(v,1,V+1){
    if(n_odd <= V/3){
      if(d[v]%2==1) add(P[v],X[0]);
      else if(X[1] <= V) add(P[v],X[1]);
      else if(X[2] <= V) add(P[v],X[2]);
      else add(P[v],X[0]);

    }else if(n_even <= V/3){
      if(d[v]%2==0) add(P[v],X[0]);
      else if(X[1] <= V) add(P[v],X[1]);
      else if(X[2] <= V) add(P[v],X[2]);
      else add(P[v],X[0]);

    }else{
      if(d[v]%2==1){
        if(X[1] <= V) add(P[v],X[1]);
        else add(P[v],X[0]);

      }else{
        if(X[2] <= V) add(P[v],X[2]);
        else add(P[v],X[0]);
      }
    }
  }

  repp(v,1,V+1) cout << P[v] SPF;
  cout << endl;
  return 0;
}


Measured memory_bytes: 20224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		String str = scn.next();
		if (str.charAt(2) == str.charAt(3) && str.charAt(4) == str.charAt(5))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 23252
def main():
    h, w = map(int, input().split())
    grid = [input() for _ in [0]*h]
    ans_list = []
    for i in range(h):
        for j in range(w):
            if grid[i][j] == ".":
                ans_list.append((i, j))
    m = 0
    for i, j in ans_list:
        q = [(i, j)]
        dist = [[-1]*w for _ in [0]*h]
        cnt = 0
        dist[i][j] = 0
        while q:
            qq = []
            cnt += 1
            while q:
                x, y = q.pop()
                if x > 0:
                    if dist[x-1][y] == -1:
                        if grid[x-1][y] == ".":
                            dist[x-1][y] = cnt
                            qq.append((x-1, y))
                if x < h-1:
                    if dist[x+1][y] == -1:
                        if grid[x+1][y] == ".":
                            dist[x+1][y] = cnt
                            qq.append((x+1, y))
                if y > 0:
                    if dist[x][y-1] == -1:
                        if grid[x][y-1] == ".":
                            dist[x][y-1] = cnt
                            qq.append((x, y-1))
                if y < w-1:
                    if dist[x][y+1] == -1:
                        if grid[x][y+1] == ".":
                            dist[x][y+1] = cnt
                            qq.append((x, y+1))
            q = qq
        m = max(m, max([max([l for l in k]) for k in dist]))
    print(m)


main()


Measured memory_bytes: 3188
fun main(args: Array<String>) {
    val (a,b) = readLine()!!.split(" ").map { it.toLong() }
    println(lcm(a,b))
}

fun gcd(a: Long, b: Long): Long = if(a < b) gcd(b, a) else if(b == 0L) a else gcd(b, a % b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

Measured memory_bytes: 36080
import java.util.Scanner;

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

        int maxLen = 0;
        int tmpLen = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == 'A' || S.charAt(i) == 'C' || S.charAt(i) == 'G' || S.charAt(i) == 'T') {
                tmpLen++;
                maxLen = Math.max(maxLen, tmpLen);
            } else {
                maxLen = Math.max(maxLen, tmpLen);
                tmpLen = 0;
            }
        }

        System.out.println(maxLen);
    }
}


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

int main(){
    int k,x; cin>> k >> x;
    int kk=k*2-1;
    for(int i=max(-1000000,x-k+1); kk>0; i++){
        printf("%d ",i);
        kk--;
    }

return 0;
}


Measured memory_bytes: 256
N = int(input())
T = list(map(int,input().split()))
M = int(input())
mat = [list(map(int,input().split())) for i in range(M)]
ans = [0]*M
time = sum(T)
for i in range(M):
    ans[i] = time-T[mat[i][0]-1]+mat[i][1]
for j in range(len(ans)):
    print(ans[j])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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 MOD = 1000000007;
ll INF =1<<30;
ll dp[110][100100];


int main(){
    int n,m;
    cin >> n >> m;
    int ans = 0;
    vector<int> cnt(m,0);
    rep(i,n){
        int k; cin >> k;
        rep(i,k){
            int a; cin >> a; a--;
            cnt[a]++;
        }
    }
    rep(i,m){
        if(cnt[i]==n) ans++;
    }
    cout << ans <<endl;
}


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

void solve() {
    int N, m;
    cin >> N;
    m = N - (N % 2);
    vector<vector<int>> ans(0, vector<int>(2));
    for (int i = 1; i <= N; i++) {
        if (N % 2 == 1 && i == N) {
            for (int j = 1; j < N; j++) {
                ans.push_back({j, N});
            }
        } else {
            for (int j = i + 1; j <= m; j++) {
                if (i + j == m + 1) continue;
                ans.push_back({i, j});
            }
        }
    }
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
        cout << ans.at(i).at(0) << " " << ans.at(i).at(1) << endl;
    }
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#define MAX 1001
 
int LCS();

char X[MAX], Y[MAX];
 

int main() {
    int n, i;
 
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s%s", X, Y);
        printf("%d\n", LCS());
    }
 
    return 0;
}

int LCS() {
    int i, j;
    int m = strlen(X);
    int n = strlen(Y);
    int c[m + 1][n + 1];
 
    for (i = 1; i <= m; i++) c[i][0] = 0;
    for (j = 0; j <= n; j++) c[0][j] = 0;
 
    for (i = 1; i <= m; i++) {
        for (j = 1; j <= n; j++) {
            if (X[i - 1] == Y[j - 1]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            } else if (c[i - 1][j] >= c[i][j - 1]) {
                c[i][j] = c[i - 1][j];
            } else {
                c[i][j] = c[i][j - 1];
            }
        }
    }
 
    return c[m][n];
}

Measured memory_bytes: 4512
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int[][] a=new int[n][n];
		for (int i=0;i<n;++i)
			for (int j=0;j<n;++j)
				a[i][j]=in.nextInt();
		long[] dp=new long[1<<n];
		long[] val=new long[1<<n];
		for (int i=0;i<1<<n;++i)
			for (int j=0;j<n;++j) if ((i>>j&1)>0)
				for (int k=j+1;k<n;++k) if ((i>>k&1)>0)
					val[i]+=a[j][k];
		for (int i=0;i<1<<n;++i) {
			int s=i;
			do {
				dp[i]=Math.max(dp[i],dp[i^s]+val[s]);
				s=i&(s-1);
			} while (s>0);
		}
		System.out.println(dp[(1<<n)-1]);
	}
}

Measured memory_bytes: 24684
import java.io.*;

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

	String  str = br.readLine();

	String[] ar = str.split("");

	for(int i=0; i<str.length(); i++){
	    if(ar[i].equals("9"))
		ar[i]="1";
	    else if(ar[i].equals("1"))
		ar[i]="9";
	}
	
	System.out.println(ar[0]+ar[1]+ar[2]);
    }
}

Measured memory_bytes: 21204
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long X = sc.nextLong();
    X=Math.abs(X);
    long K = sc.nextLong();
    long D = sc.nextLong();
    long quo = X/D; //商; 0 に到達するまでの回数
    long ans = 0;
    
    if(quo>=K) {
      ans=X-K*D;
    } else {
      if((K-quo)%2 == 0) {
        ans=X-quo*D;
      } else {
        ans=X-(quo+1)*D;
      }
    }
    
    System.out.println(Math.abs(ans));
  }
}

Measured memory_bytes: 36188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll q;
    cin >> q;
    priority_queue<ll> lpq;
    priority_queue<ll, vector<ll>, greater<ll>> rpq;
    ll asum = 0, bsum = 0;
    rep(i, q) {
        ll c;
        cin >> c;
        if (c == 1) {
            ll a, b;
            cin >> a >> b;
            bsum += b;
            lpq.push(a);
            rpq.push(a);
            ll l = lpq.top(); lpq.pop();
            ll r = rpq.top(); rpq.pop();
            if (l > r) {
                asum += l - r;
                swap(l, r);
            }
            lpq.push(l);
            rpq.push(r);
        }
        else {
            printf("%lld %lld\n", lpq.top(), asum + bsum);
        }
    }
    return 0;
}


Measured memory_bytes: 4588
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

bool flag[200001];
int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> route(N);
	REP(i, 0, M) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		route[a].push_back(b);
		route[b].push_back(a);
	}

	REP(i, 0, route[0].size()) {
		flag[route[0][i]] = true;
	}
	bool possible = false;
	REP(i, 0, route[N - 1].size()) {
		if (flag[route[N - 1][i]]) possible = true;
	}

	if (possible) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 12144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define esp 1e-9

int main(){
    int n,a,b;
    cin>>a>>b;
    b=(double)b/0.1+0.5;
    int mid,i;
    for(i = b;i < b+10;i++){
        mid=i*0.08;
        if(mid==a){
            cout<<i;
            break;
        }
    }
    if(mid!=a) cout<<-1;
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

# 下がtrue, falseになる最小値を返す
def bs(f, mi, ma):
    mm = -1
    while ma > mi:
        mm = (ma+mi) // 2
        if f(mm):
            mi = mm + 1
        else:
            ma = mm
    if f(mm):
        return mm + 1
    return mm

def main():
    n = I()
    a = LI()

    def f(i):
        for c in a:
            i -= i%c
        return i < 2

    def g(i):
        for c in a:
            i -= i%c
        return i <= 2

    mi = bs(f,0,sum(a)+3)
    ma = bs(g,0,sum(a)+3) - 1
    if mi <= ma:
        return '{} {}'.format(mi,ma)
    return -1




print(main())




Measured memory_bytes: 16644
#include <stdio.h>


static int binarysearch(const int S[], int lo, int hi, int t) {
    int mid = (hi + lo) / 2;

    if ( hi == lo ) {
        return 0;
    }

    if ( t == S[mid] ) {
        return 1;
    }
    if ( t < S[mid] ) {
        return binarysearch(S, lo, mid, t);
    } else {
        return binarysearch(S, mid+1, hi, t);
    }
}


int main(int argc, char* argv[]) {
    int n, q, i;
    int S[100000+1];
    int T[50000+1];
    int c = 0;

    scanf("%d\n", &n);
    for ( i = 0; i < n; i++ ) {
        scanf("%d", &S[i]);
    }

    scanf("%d\n", &q);
    for ( i = 0; i < q; i++ ) {
        scanf("%d", &T[i]);
    }

    for ( i = 0; i < q; i++ ) {
        c += binarysearch(S, 0, n, T[i]);
    }

    printf("%d\n", c);

    return 0;
}



Measured memory_bytes: 2308
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;

vector<int> g[N];
int from[N], tot, use[N];

int n, a[N], b[N], c[N], d[N];

bool match(int x) {
    for (int v: g[x]) {
        if (!use[v]) {
            use[v] = 1;
            if (from[v] == -1 || match(from[v])) {
                from[v] = x;
                return 1;
            }
        }
    }
    return 0;
}

int hungary() {
    tot = 0;
    memset(from, -1, sizeof from);
    for (int i = 0; i < n; ++i) {
        memset(use, 0, sizeof use);
        if (match(i)) ++tot;
    }
    return tot;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
    for (int i = 0; i < n; ++i) cin >> c[i] >> d[i];
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            if (a[i] < c[j] && b[i] < d[j])
                g[i].push_back(n + j);
    cout << hungary() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

string six(int num) {
	string temp;
	temp = to_string(num);
	while (temp.size() < 6) {
		temp = "0" + temp;
	}
	return temp;
}
	vector<pair<int, int>> py[100001];
	string ans[100001];

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

	int a, b, maxxa = -1;

	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		py[a].push_back(make_pair(b, i));
		maxxa = max(maxxa, a);
	}
	
	for (int i = 1; i <= maxxa; i++) {
		sort(py[i].begin(), py[i].end());
		for (int j = 0; j < py[i].size(); j++) {
			ans[py[i][j].second] = six(i) + six(j+1);
		}
	}

	for (int i = 0; i < m; i++) {
		cout << ans[i] << endl;
	}
	//cout << six(2);



	//cout << endl;
	return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
 
long long rec(long long H){
  if(H==1){
    return 1;
  }
  else{
    return rec(H/2)*2+1;
  }
}
    
int main() {
  long long H;
  cin >>H;
cout <<rec(H)<<endl;
}

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

int n, m;

int main(){
	cin >> n >> m;
	vector<pair<int, int> > require(m);

	for (int i = 0;i<m;i++){
		int a1,a2;
		cin >> a1 >> a2;
		require.at(i) = make_pair(a2-1,a1-1);
	}

	sort(require.begin(), require.end());
	vector<int> bridge;
	bridge.push_back(require.at(0).first - 1);
	for (int i = 1;i<m;i++){
		int n_bridge = bridge.size();
		bool flag = false;
		for (int j = 0;j < n_bridge;j++){
			if (bridge.at(j) >= require.at(i).second && bridge.at(j) < require.at(i).first) flag = true;
		}
		if (flag == false){
			bridge.push_back(require.at(i).first- 1);
		}
	}
	cout << bridge.size() << endl;
}

Measured memory_bytes: 1024
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    int a[3] ;
    for(int i = 0 ; i < 3 ; i++)
        cin >> a[i] ;
    sort(a , a+3) ;
    cout << a[0] + a[1] ;


























return 0 ;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define MAX_N 100000

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

  cout << 50 << endl;

  ll b = n / 50;
  int a = n % 50;
  ll flag = 0;
  REP(i,50){
    if(i<a){
      flag = 1;
    }else{
      flag = 0;
    }
    cout << i + (b + flag) * 51 - n << ' ';
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include<unordered_map>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define pop pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 1000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }
ll power(ll x, ll y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}

int main()
{
    jaldi
    #ifndef ONLINE_JUDGE
    //TakeInput
    #endif
    ll m,n,i,j;
    cin>>m>>n;
    ll a[n+1],v[n+1];
    ll dp[n+1][m+1];
    //ininf(dp);
    dp[0][0]=0;
    fon(i,1,n+1){
        
        cin>>a[i]>>v[i];
        dp[i][0]=0;
    }
    in(i,n+1){
        in(j,m+1){
            if(i==0 && j!=0){
                dp[i][j]=I;
                //cout<<i<<" "<<j<<endl;
            }
            else if( j==0)dp[i][j]=0;
            else{
                ll l=max(j-a[i],0ll);
                dp[i][j]=min(dp[i][l]+v[i],min(dp[i-1][l]+v[i],dp[i-1][j]));
               
            }
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<dp[n][m]<<endl;
}








 




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

using namespace std;
typedef long long ll;
int main()
{
string s;
cin>>s;
ll f=0;
if(s.length()==6)
{
    if((s[2]==s[3])&&(s[4]==s[5]))
        f=1;

}
if(f==1)
    cout<<"Yes";
else
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int D = sc.nextInt();
		int x = sc.nextInt();

		int prev = x;
		for (int i = 0; i < 10; i++) {
			prev = r * prev - D;
			System.out.println(prev);
		}
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 22356
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		int n=nextInt();
		out.println(1000-(n%1000==0?1000:n%1000));
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

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

p = list(map(int, input().split()))

class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for i in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        elif self.rank[y] < self.rank[x]:
            self.par[y] = x
        else:
            self.rank[y] += 1
            self.par[x] = y
        

uf = UnionFind(N)

for i in range(M):
    x, y = map(int, input().split())
    uf.unite(x-1, y-1)

ans = 0
for i in range(N):
    if uf.find(p[i]-1) == uf.find(i):
        ans += 1

print(ans)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define Speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

#define st              first
#define nd              second
#define pb              push_back
#define pf              push_front
#define all(a)          (a).begin(), (a).end()
#define lwb             lower_bound
#define upb             upper_bound
#define vvll            vector<vector<ll> >
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       sort(all(a)); (a).resize(unique(all(a)) - (a).begin())

typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;
const int oo = 2e9;
const ld PI = acos((ld) -1);
int Getbit(ll x, int k){return (x >> (k - 1)) & 1;}
ll Lcm(ll a, ll b) {return a / __gcd(a, b) * b;}
bool isPrime(ll n){for(ll i = 2; i * i <= n; i++){if(n % i == 0) return 0;} return (n > 1) ? 1 : 0;}
ll Powmod(ll n, ll k, ll p = MOD) {ll r = 1; for(; k; k /= 2, n = n * n % p){if(k & 1) r = r * n % p;} return r;}

const int N = 2e5 + 5;

ll n, m, query;

ll a[N];

void Solve(){
    cin >> n;
    cout << n * n;
}

int main(){
    Speed;
    int query = 1; // cin >> query;
    while(query--){
        Solve();
    }
}






Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    long long n, k; std::cin >> n >> k;
    std::vector<int> t(n);
    std::vector<long long> d(n);
    for (int i = 0; i < n; i++) std::cin >> t[i] >> d[i];
    std::vector<int> id(n);
    std::iota(id.begin(), id.end(), 0);
    std::sort(id.begin(), id.end(), [&](int i, int j) {
        return d[i] > d[j];
    });
    std::priority_queue<long long> que1, que2;
    std::set<int> used;
    long long sum = 0;
    for (int i : id) {
        if (used.count(t[i]) || used.size() >= k) {
            que1.push(d[i]);
            continue;
        }
        used.insert(t[i]);
        sum += d[i];
        que2.push(-d[i]);
    }
    while (que2.size() < k) {
        sum += que1.top();
        que2.push(-que1.top());
        que1.pop();
    }
    long long ans = sum + used.size()*used.size();
    for (long long i = used.size() - 1; i >= 1; i--) {
        if (que1.empty()) break;
        sum += que1.top();
        que2.push(-que1.top());
        sum -= -que2.top();
        que1.pop();
        que2.pop();
        ans = std::max(ans, sum + i*i);
    }
    std::cout << ans << std::endl;
    return 0;
}


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

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

	if (a >= b) {
		cout << "delicious" << endl;
	} else if (b - a <= x) {
		cout << "safe" << endl;
	} else {
		cout << "dangerous" << endl;
	}
	return 0;
}


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

constexpr int inf = 1e9;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int pos = min_element(begin(a), end(a)) - begin(a);
    int ans = (k == n ? 1 : inf);
    for(int i = 0; i + k <= n; ++i) {
        if(i <= pos && pos < i + k) {
            auto left_num = i;
            auto right_num = n - left_num - k;
            //cout << "pos: " << i << ' ' << left_num << ' ' << right_num << endl;
            ans = min(ans, 1 + (left_num + k - 2) / (k - 1) + (right_num + k - 2) / (k - 1));
        }
    }
    cout << ans << endl;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, W, X, Y, Z;
string S, T;

signed main(){
	std::cin >>A>>B>>C ;
	if(4*A*B<(C-A-B)*(C-A-B)&&C-A-B>0)std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
for i in range(n):
    ctn = 0
    x = set(s[:i])
    y = set(s[i:])
    for j in x:
        if j in y:
            ctn += 1
    if ans < ctn:
        ans = ctn
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
const int INF=1e6;
const ll int MOD=998244353;

main(){
    int a=in();
    char c;cin>>c;
    int b=in();
    if(c=='+')cout<<a+b;
    else cout<<a-b;
}

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

int n, m, ans, d;

int main(){
    cin >> n >> m;
    vector<int> x(m), l(m - 1);
    for (int i = 0; i < m; i++) cin >> x[i];
    sort(x.begin(), x.end());
    for (int i = 0; i + 1 < m; i++) d = abs(x[i] - x[i + 1]), ans += d, l[i] = d;
    sort(l.rbegin(), l.rend());
    d = min(n - 1, m - 1);
    for (int i = 0; i < d; i++) ans -= l[i];
    cout << ans << endl;
}

Measured memory_bytes: 1024
public class Main {

	public static void main(String[] args) {
		
		int i, j;
		
		for(i = 1; i < 10; i++) {
			for(j = 1; j < 10; j++) {
				System.out.println(i + "x" + j + "=" + i*j);
			}
		}
		
	}

}


Measured memory_bytes: 23992
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		string s = GetString();
		
		int ans = 0;
		for(int i = 0; i < s.Length; i++)
		{
			if(i % 2 == 0)
				ans += (s[i] == 'g') ? 0 : -1;
			else
				ans += (s[i] == 'g') ? 1 : 0;
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





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

int main(){
int A,B,K;
  cin>>A>>B>>K;
  
  if(A+K>=B || A+K>B-K){
   for(int i=0; i<=B-A; i++){
    cout<<A+i<<endl; }
  }
  
  else{
   for(int i=0; i<K; i++){
    cout<<A+i<<endl; }
   for(int i=B-K+1; i<=B; i++){
    cout<<i<<endl; } 
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll m=1e9+7;
ll s,dp[2005];
int main()
{
	cin>>s;
	dp[3]=1,dp[4]=1;
	ll now=2;
	for(int i=5;i<=s;i++)
	{
		dp[i]=(1+now-dp[i-1]-dp[i-2])%m;
		now+=dp[i];
	}
	cout<<dp[s]%m<<endl;
}

Measured memory_bytes: 3648
#include <stdio.h>

#define FAT 25

int main(void)
{
	int number;
	double weight, height;
	while (scanf("%d,%lf,%lf", &number, &weight, &height) != EOF) {
		if (weight / (height * height) >= FAT)
			printf("%d\n", number);
	}
	return 0;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,k;
ll a[200001];
bool check(ll now){
	ll res=0;
	rep(i,n){
		res+=a[i]/now;
		if(a[i]%now)
		res++;
		res--;
	}
	re res<=k;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>k;
	rep(i,n)
	cin>>a[i];
	sort(a,a+n);
	ll l=1,r=1e9;
	while(l<r){
		ll mid=(l+r)/2;
		if(check(mid))
		r=mid;
		else
		l=mid+1;
	}
	cout<<l;
	re 0;
}

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

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

    int a = 0, b = 0;
    for(int i = 0; i < (int)s.size(); ++i){
        char ch = s[i];
        if(ch == '0'){
            a++;
        }else{
            b++;
        }
    }
    cout << min(a, b) * 2;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#define LL long long
#define LD long double
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
using namespace std;

int main()
{
	FIO;
	LD a, x; cin>>a, x=a/3;
	printf("%LF", x*x*x);
}

Measured memory_bytes: 3780
package main

import "fmt"

func main() {
	var n, m, k int
	fmt.Scan(&n, &m, &k)

	comInit()

	// (M * pow(M-1, N-ki-1)) * (comb(N-1, ki))
	ans := 0
	for i := 0; i <= k; i++ {
		c := mul(
			mul(m, pow(m-1, n-i-1)),
			com(n-1, i),
		)
		ans = add(ans, c)
	}
	fmt.Println(ans)
}

const mod int = 998244353

func pow(n, k int) int {
	if k == 0 {
		return 1
	} else if k%2 == 1 {
		return pow(n, k-1) * n % mod
	} else {
		t := pow(n, k/2)
		return t * t % mod
	}
}

func add(a, b int) int {
	return (a + b) % mod
}

func sub(a, b int) int {
	return (a + mod - b) % mod
}

func mul(a, b int) int {
	return a % mod * b % mod % mod
}

func div(a, b int) int {
	return mul(a, pow(b, mod-2))
}

// func comb(n, r int) int {
// 	nu := 1
// 	for i := 0; i < r; i++ {
// 		nu = mul(nu, n-i)
// 	}
//
// 	de := 1
// 	for i := 1; i <= r; i++ {
// 		de = mul(de, i)
// 	}
//
// 	return div(nu, de)
// }

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#5-二項係数-ncr
const max int = 1e5*2 + 1000

var fac [max]int
var finv [max]int
var inv [max]int

// テーブルを作る前処理
func comInit() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for 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
	}
}

// 二項係数計算
func com(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod
}


Measured memory_bytes: 6556
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	//cout.tie(NULL);
	//freopen("in.txt","r",stdin);
	int T;
	cin>>T;
	while(T--){
		int n;
		cin>>n;
		long long sum=0;  //最后的答案 
		vector<pair<int, int>>v, v2;  //v用来存靠右的，v2用来存靠左的 
		set<int>s, s2;
		for(int i=1;i<=n;i++){
			int k, l, r;
			cin>>k>>l>>r;
			if(l<r) v.push_back({l-r, k});
			else v2.push_back({l-r, k});
			sum+=r;            //先加上r 
		}
		for(int i=1;i<=v2.size();i++) s2.insert(i);  //s2 存靠左的个数 
		for(int i=v2.size()+1;i<=n;i++) s.insert(i);  //s用来存靠右的个数 
		sort(v.begin(), v.end());    //对于靠右，r大的排前面 
		sort(v2.begin(), v2.end()); 
		reverse(v2.begin(), v2.end());  //对于靠左 l大的排前面 
		for(auto i:v){
			auto it=s.upper_bound(i.second);  
			if(it==s.end()) {
				sum+=i.first;
				s.erase(s.begin());
			}
			else s.erase(it);
		}
		for(auto i:v2){
			auto it=s2.upper_bound(i.second);
			if(it!=s2.begin()){
				it--;
				s2.erase(it);
				sum+=i.first;
			}else{
				s2.erase(--s2.end());
			}
		}
		cout<<sum<<"\n";
	}
}


Measured memory_bytes: 14260