akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7
DEBUG = 'ONLINE_JUDGE' not in sys.argv

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)

def main():
    N, K = mis()
    P = list(map(lambda x: x-1, mis()))
    C = lmis()
    ans = -INF
    for i in range(N):
        p = i
        tmp_score = 0
        k = K
        cycle = 0
        while k:
            p = P[p]
            tmp_score += C[p]
            ans = max(ans, tmp_score)
            k -= 1
            cycle += 1
            if p==i:
                if tmp_score < 0:
                    break
                elif k > cycle*2:
                    skip_loop = (k - cycle)//cycle
                    tmp_score *= skip_loop + 1
                    k -= skip_loop * cycle
        ans = max(ans, tmp_score)
    print(ans)








main()



Measured memory_bytes: 70220
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		long ans=0;
		for(int i = 1;i<=n;i++) {
			for(int j = 1;j<=n;j++) {
				for(int k = 1;k<=n;k++) {
					ans+=Gcd(i,Gcd(j,k));
				}
			}
		}
		Console.WriteLine("{0}",ans);
	}
	static long Gcd(long a,long b){
		long c=Max(a,b)%(b=Min(a,b));
		while(c!=0){
			a=b%c;
			b=c;
			c=a;
		}
		return b;
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27544
#include<iostream>
using namespace std;
int main() {
    int n;
    long long k;
    cin >> n >> k;
    long long num[100001] = {0};
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        num[a] += b;
    }
    long long tmp = 0;
    for (int i = 1; i <= 100000; i++) {
        tmp += num[i];
        if (tmp >= k) {
            cout << i << endl;
            break;
        }
    }
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <deque>
using namespace std;
int n, m, i, j, k, t, u, v, w, Max, K;
int x[100010], y[100010];
char c[100010];
int Count[3][2010];
int main(){
	Max=0;
	cin>>n>>k;
	K=2*k;
	for(i=1;i<=n;i++){
		cin>>x[i]>>y[i]>>c[i];
		if(c[i]=='B') y[i]+=k;
		x[i]=x[i]%K;
		y[i]=y[i]%K;
	}
	for(i=0;i<=K-1;i++){
		for(v=0;v<=1;v++){
			for(w=0;w<=K-1;w++){
				Count[v][w]=0;
			}
		}
		for(u=1;u<=n;u++){
			Count[x[u]/k][y[u]]++;
		}
			m=0;
			for(u=0;u<=k-1;u++){
				m+=Count[0][u%K]+Count[1][(u+k)%K];
			}	
			Max=max(Max,m);
		for(j=0;j<=K-1;j++){
			m+=Count[0][(j+k)%K]-Count[0][j]+Count[1][j]-Count[1][(j+k)%K];
			Max=max(Max,m);
		}
		for(u=1;u<=n;u++) x[u]=(x[u]+1)%K;
	}
	cout<<Max;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000009;

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

template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

pair<int,int> operator+(pair<int,int> p1,pair<int,int> p2){
	return make_pair(p1.first + p2.first,p1.second + p2.second);
}

template<class T>
vector<T> dijkstra(const WeightedGraph<T> &G,int source = 0){
	using P = pair<T,int>;
	vector<T> dist(G.size(),make_pair(INF,INF));
	priority_queue<P,vector<P>,greater<P>> que;
	dist[source] = make_pair(0,0);
	que.emplace(dist[source],source);
	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second;
		if(dist[v] < p.first) continue;
		for(const auto &e : G[v]){
			if(dist[e.to] > dist[v] + e.cost){
				dist[e.to] = dist[v] + e.cost;
				que.emplace(dist[e.to],e.to);
			}
		}
	}
	return dist;
}

signed main(){
	int n,t,c[50010];
	vector<int> ss[50010],ts[50010];
	string a,b;
	map<string,int> name_to_index;
	cin >> n >> t >> a >> b;
	name_to_index[a] = 0;
	name_to_index[b] = 1;
	int index = 2,vs = 0;
	for(int i = 0;i < n;i++){
		cin >> c[i];
		for(int j = 0;j < c[i];j++){
			string s;
			cin >> s;
			if(!name_to_index.count(s)) name_to_index[s] = index++;
			ss[i].push_back(name_to_index[s]);
		}
		for(int j = 0;j < c[i] - 1;j++){
			int d;
			cin >> d;
			ts[i].push_back(d);
		}
		vs += c[i];
	}
	WeightedGraph<pair<int,int>> G(vs + index);
	int v = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < c[i];j++){
			if(j){
				G[v + j - 1].emplace_back(v + j,make_pair(ts[i][j - 1],0));
				G[v + j].emplace_back(v + j - 1,make_pair(ts[i][j - 1],0));
			}
			G[v + j].emplace_back(vs + ss[i][j],make_pair(t,1));
			G[vs + ss[i][j]].emplace_back(v + j,make_pair(0,0));
		}
		v += c[i];
	}
	auto dist = dijkstra(G,vs);
	if(dist[vs + 1].first == INF) cout << -1 << endl;
	else cout << dist[vs + 1].first - t << " " << dist[vs + 1].second - 1 << endl;
}


Measured memory_bytes: 40868
n, m = map(int, input().split())
s = [0] * m
for i in range(m):
    s[i] = list(map(int, input().split()))[1:]
p = list(map(int, input().split()))
ans = 0
for bit in range(2 << (n-1)):
    l = [0] * n
    for i in range(n):
        if bit >> i & 1:
            l[i] += 1
    for i in range(m):
        cnt = 0
        flag = True
        for j in s[i]:
            if l[j-1] == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

const long long MOD = (long long)1e9 + 7;

ll f[400001];

long long mod_pow(long long x_, long long y_){
    if(y_ == 0) return 1;
    long long res = mod_pow(x_ * x_ % MOD, y_ / 2);
    if(y_ & 1) res =  x_ * res % MOD;
    return res;
}

long long mod_inv(long long x){
    return mod_pow(x, MOD - 2);
}

ll comb(ll x, ll y){
    return (((f[x] * mod_inv(f[y]) % MOD) * mod_inv(f[x - y])) % MOD);
}

int main(){
    ll n, k, ans = 0;
    cin >> n >> k;
    f[0] = 1;
    for(int i = 1; i <= 400000; i++){
        f[i] = f[i - 1] * i;
        f[i] %= MOD;
    }
    ll x = min(n - 1, k);
    for(int i = 0; i <= x; i++){
        ans += comb(n, i) * comb(n - 1, i);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  string a;
  cin >> a;
  int64_t n = a.length();
  int64_t answer = 1 + n * (n - 1) / 2;
  for (char c = 'a'; c <= 'z'; c++) {
    int64_t ct = 0;
    for (int32_t i = 0; i < n; i++) {
      if (a.at(i) == c) {
        ct++;
      }
    }
    answer -= (ct * (ct - 1)) / 2;
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 888
open Batteries
let n = read_int ()
let dp = Array.init 4 @@ fun _ -> 0
let rec loop i = 
  if i >= n then () else (
    Scanf.sscanf (read_line()) "%s" (fun a -> 
      if a = "AC" then dp.(0) <- dp.(0) + 1 else
      if a = "WA" then dp.(1) <- dp.(1) + 1 else
      if a = "TLE" then dp.(2) <- dp.(2) + 1 else
      dp.(3) <- dp.(3) + 1
    ); loop (i+1)
  )
let _ = loop 0
let _ = 
  Printf.printf "AC x %d\n" dp.(0); Printf.printf "WA x %d\n" dp.(1); Printf.printf "TLE x %d\n" dp.(2); Printf.printf "RE x %d\n" dp.(3)

Measured memory_bytes: 7536
#include <bits/stdc++.h>
 
using namespace std;
 
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
 
typedef long long ll;
int const inf = 1<<29;
 
namespace flow {
 
class bipartite_matching {
private:
 
  int V;
  vector<vector<int>> G;
  vector<int> match;
  vector<bool> used;
 
  bool dfs(int v) {
    used[v] = 1;
    for(auto& u: G[v]) {
      int w = match[u];
      if(w < 0 || (!used[w] && dfs(w))) {
        match[v] = u;
        match[u] = v;
        return true;
      }
    }
    return false;
  }
 
 
public:
 
  bipartite_matching(int V): V(V) {
    G.resize(V), match.resize(V), used.resize(V);
  }
 
  void add_edge(int u, int v) {
    G[u].push_back(v);
    G[v].push_back(u);
  }
 
  int maximum_matching() {
    int ret = 0;
    match.clear(), match.resize(V, -1);
    rep(v, V) {
      if(match[v] < 0) {
        used.clear(), used.resize(V, 0);
        if(dfs(v)) { ret ++; }
      }
    }
    return ret;
  }
};
 
}
 
int main() {
 
  for(int N; cin >> N && N;) {
    int M; cin >> M;
 
    int dcnt = 0;
    unordered_map<int, int> dayidx;
    rep(i, M) {
      int x; cin >> x;
      if(dayidx.find(x) == dayidx.end()) {
        dayidx[x] = dcnt++;
      }
    }
 
    flow::bipartite_matching bp(dcnt + N);
 
    rep(girl, N) {
      cin >> M;
      rep(i, M) {
        int k; cin >> k;
        if(dayidx.find(k) != dayidx.end())
          bp.add_edge(dayidx[k], dcnt + girl);
      }
    }
 
    cout << bp.maximum_matching() << endl;
  }
   
  return 0;
}

Measured memory_bytes: 3212
N = int(input())
dp=[[0,0,0] for i in range(N)]
satisfy=[[int(x) for x in input().split()] for i in range(N)]
dp[0]=satisfy[0]
for i in range(N-1):
    dp[i+1][0] = dp[i][1] + satisfy[i+1][0] if dp[i][1]>dp[i][2] else dp[i][2] + satisfy[i+1][0]
    dp[i+1][1] = dp[i][0] + satisfy[i+1][1] if dp[i][0]>dp[i][2] else dp[i][2] + satisfy[i+1][1]
    dp[i+1][2] = dp[i][0] + satisfy[i+1][2] if dp[i][0]>dp[i][1] else dp[i][1] + satisfy[i+1][2]
print(max(dp[-1]))

Measured memory_bytes: 73760
#include <iostream>
#include<cmath>

using namespace std;

int isPrime(int p){
  if(p%2==0 && p!=2) return 0;
  for(int j=3;j<=sqrt(p);j=j+2){
    if(p%j==0) return 0;
  }
  return 1;
}

int main(){
  int s=0;
  int n; cin >> n;
  for(int i=0;i<n;i++){
    int p; cin >> p;
    s=s+isPrime(p);
  }
  cout << s << endl;
}

Measured memory_bytes: 3088
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    int A;
    int B;
    int X;
    Scanner sc = new Scanner(System.in);
    A = sc.nextInt();
    B = sc.nextInt();
    X = sc.nextInt();
    if(X <= A + B && X >= A){
      System.out.println("YES");
    }
    else{
      System.out.println("NO");
    }
    return ;
  }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int x;
cin>>x;
if(x<1200)cout<<"ABC"<<endl;
else cout<<"ARC"<<endl;

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e8;
using namespace std;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl



int main(void)
{
	int n, m, c;
	int a[21][21];
	int b[21];
	int count = 0;
	cin >> n >> m >> c;
	
	for (int i = 0;i < m;i++)
	{
		cin >> b[i];
	}

	for (int i = 0;i < n;i++)
	{
		for (int j = 0;j < m;j++)
		{
			cin >> a[i][j];
		}
	}
	
	
	for (int i = 0;i < n;i++)
	{
		ll ans=0;
		for (int j = 0;j < m;j++)
		{
			ans += a[i][j] * b[j];

		}
		if (ans + c > 0)count++;
	}

	cout << count << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N;
cin >> N;
vector<pair<double,string>> vec(N);
for (int i = 0;i < N;i++) {
    cin >> vec.at(i).first >> vec.at(i).second;
}
double ans = 0;
for (int i = 0;i < N;i++) {
if (vec.at(i).second == "BTC") {
    ans += vec.at(i).first * 380000.0;
} else ans += vec.at(i).first;
}

cout << ans << endl;


return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)

#define INF 2e9
#define ALL(v) v.begin(), v.end()

string divide[4]={"dream","dreamer","erase","eraser"};

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

  reverse(ALL(s));
  rep(i,4){
    reverse(ALL(divide[i]));
  }
  bool can=true;
  for(int i=0;i<s.size();){
    bool can2=false;
    rep(j,4){
      string d=divide[j];
      if (s.substr(i,d.size())==d){can2=true;
      i+=d.size();
    }

    }
    if (can2==false){
      can=false;
      break;
    }
  }
  if (can){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
n = int(input())
t,a = list(map(int,input().split()))
h = list(map(int, input().split()))
ans = 1000000000
okok = 0

for i in range(0,n):
  if(ans > abs(a-(t-h[i]*0.006))):
    ans = abs(a-(t-h[i]*0.006))
    okok = i+1

print(okok)

Measured memory_bytes: 3064
x = int(input())

if x < 100:
    print(0)
    exit()

shimo2 = int(str(x)[-2:])
ue = int(str(x)[:-2])

nums = [0]*6

for i in [5,4,3,2,1]:
    nums[i] = shimo2//i
    shimo2 -= nums[i]*i


if ue >= sum(nums):
    print(1)
else:
    print(0)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
 
#define int long long
 
signed main() {
	
	int n, p;
	string s;
	
	cin >> n >> p >> s;
	
	if (p == 2 || p == 5) {
		int ans = 0;
		for (int j=0; j<n; j++) {
			if ((s[j] - '0') % p == 0) {
				ans += (j + 1);
			}
		}
		cout << ans << endl;
	}
	else {
		int d[n+1];
		d[n] = 0;
		int ea[p];
		memset(ea, 0, sizeof ea);
		ea[0] = 1;
		int mul = 1;
		for (long long i=n-1; i>=0; i--) {
			d[i] = (((s[i] - '0') * mul) + d[i+1]) % p;
			ea[d[i]]++;
			// cout << i << '>' << (s[i] - '0') * mul + d[i+1] << ' ' << d[i] << endl;
			mul *= 10;
			mul %= p;
		}
		int x = 0;
		for (int i=0; i<p; i++) {
			// cout << i << ' ' << ea[i] << endl;
			x += (ea[i] * (ea[i] - 1)) / 2;
		}
		cout << x << endl;
	}
	
}


Measured memory_bytes: 2180
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int N;
  cin>>N;
  int P[N+1],L[N+1];
  RREP(i,N){
    cin>>P[i];
    L[P[i]]=i;
  }
  
  if(N==1){
    co(0);
    return 0;
  }
  
  int cnt=1,ans=0;
  for(int i=2; i<=N; ++i){
    if(L[i-1]>L[i] || i==N){
      if(i==N && L[i-1]<L[i]) cnt++;
      chmax(ans,cnt);
      cnt=1;
    }
    else cnt++;
  }
  
  co(N-ans);
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
ll n,m,s[2005],t[2005],dp[2005][2005];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,ans,x,sum,c,k,w,h,y;
    	cin>>n>>m;
    	repi(i,1,n)
    	cin>>s[i];
    	repi(i,1,m)
    	cin>>t[i];
    	memset(dp,0,sizeof(dp));
    	repi(i,1,n)
    	{
    		repi(j,1,m)
    		{
    			dp[i][j]=(dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1]+mod)%mod;
    			if(s[i]==t[j])
    			dp[i][j]=(dp[i][j]+1+dp[i-1][j-1])%mod;
			}
		}
		cout<<1+dp[n][m];
    } 
	return 0;
}

Measured memory_bytes: 31744
import fractions

A,B,C,D = map(int,input().split())

def div(a,c,d):
    ac=a//c
    ad=a//d
    cd=c*d//fractions.gcd(c,d)
    acd=a//cd
    return ac+ad-acd

ans=B-(A-1)-(div(B,C,D)-div(A-1,C,D))
print(ans)

Measured memory_bytes: 64876
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")
 
bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}
 
int main(){
  string s;
  cin >> s;
  cout << s.substr(0,3) << 8 << s.substr(4,6);
  return 0;
}

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

int main(){
	int N,ans=0;
	cin>>N;
	while(N--){
		int l,r;
		cin>>l>>r;
		ans+=(r-l)+1;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
s = []
for _ in range(n):
    s.append(input())
s = Counter(s)
words, counts = zip(*s.most_common())
selected = []
num = None
for w, c in zip(words, counts):
    if num == None:
        num = c
        selected.append(w)
    else:
        if c == num:
            selected.append(w)
        else:
            break
print(*sorted(selected), sep='\n')

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

int main(){
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << setprecision(5) << W*H/2 << " ";
  if(x==W/2 && y==H/2){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
"use strict";

const main = arg => {
    const inputList = arg.trim().split("\n");
    // 回答を記述
    const N = BigInt(inputList[0].split(" ")[0]);
    const AList = inputList[1].split(" ");

    if (AList.some(ele => ele == 0)) {
        console.log(0);
    } else {
        let num = 1n;
        for (let i = 0; i < AList.length; i++) {
            num *= BigInt(AList[i]);
            if (num > 10n ** 18n) {
                num = -1n;
                break;
            }
        }

        console.log(BigInt.asIntN(64, num).toString())
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 42308
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();

            var numsDic = Console.ReadLine().Split(' ').Select(num => long.Parse(num)).GroupBy(x => x).ToDictionary(g => g.Key, g => g.Count());
            var total = numsDic.Sum(kvp => kvp.Key * kvp.Value);

            var q = int.Parse(Console.ReadLine());
            var list = new List<long>();
            for (var i = 0; i < q; i++)
            {
                var bc = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
                var b = bc[0];
                var c = bc[1];

                if (!numsDic.TryGetValue(b, out _))
                {
                    list.Add(total);
                    continue;
                }
                var sa = c - b;
                total += numsDic[b] * sa;
                list.Add(total);
                if (numsDic.TryGetValue(c, out _))
                {
                    numsDic[c] += numsDic[b];
                }
                else
                {
                    numsDic.Add(c, numsDic[b]);
                }
                numsDic[b] = 0;
            }

            for (var i = 0; i < list.Count; i++)
            {
                Console.WriteLine(list[i]);
            }
        }
    }
}

Measured memory_bytes: 51192
#include <iostream>

using namespace std;

int c[7][7];
int cc[7][7];

int main() {
    
    int h, w, k;
    cin >> h >> w >> k;
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char ccc;
            cin >> ccc;
            if (ccc == '.') {
                c[i][j] = 0;
            } else {
                c[i][j] = 1;
            }
        }
    }
    
    
    int cnt = 0;
    int total = 0;
    
    for (int i = 0; i < (1 << h); i++) {
        for (int j = 0; j < (1 << w); j++) {
            
            cnt = 0;
            
            for (int ii = 0; ii < h; ii++) {
                for (int jj = 0; jj < w; jj++) {
                    cc[ii][jj] = c[ii][jj];
                }
            }
            
            for (int ii = 0; ii < h; ii++) {
                if (i & (1 << ii)) {
                    for (int jj = 0; jj < w; jj++) {
                        cc[ii][jj] = 2;
                    }
                }
            }

            for (int jj = 0; jj < w; jj++) {
                if (j & (1 << jj)) {
                    for (int ii = 0; ii < h; ii++) {
                        cc[ii][jj] = 2;
                    }
                }
            }

            
            for (int ii = 0; ii < h; ii++) {
                for (int jj = 0; jj < w; jj++) {
                    cnt += int(cc[ii][jj] == 1);
                }
            }

            if (cnt == k) {
                total++;
            }
            
        }
    }
    
    cout << total << endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<queue>
#include<set>
#include<climits>
using namespace std;

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

  if (a > c)
    cout << "NO" << endl;
  else if (a + b < c)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}


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

int main(void) {
	int N;
	cin >> N;
	if (N < 1200)
		cout << "ABC" << endl;
	else if (N < 2800)
		cout << "ARC" << endl;
	else
		cout << "AGC" << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = []
flag = True
for i in range(N):
	a = int(input())
	if i == 0:
		if a > 0:
			flag = False
	if i > 0:
		if a > A[i-1] + 1:
			flag = False
	A.append(a)

if not flag:
	print(-1)
	exit()
A.reverse()
last = 0
ans = 0
for i in range(N):
	a = A[i]
	if a != last - 1:
		ans += a
	last = a
print(ans)

Measured memory_bytes: 10984
// God put a smile upon your face <3

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

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

	ll a, b, v, w, t;

	while(cin >> a >> v >> b >> w >> t)
	{
		ll diff = v - w;

		if(a < b)
		{
			if(diff <= 0) ans = 0;
			else
			{
				ll dist = (t * diff);

				if(dist + a < b) ans = 0;
				else ans = 1;
			}
		}
		else
		{
			diff *= 1;

			if(diff <= 0) ans = 0;
			else
			{
				ll dist = (t * diff);

				if(dist + b < a) ans = 0;
				else ans = 1;
			}
		}

		if(ans) printf("YES\n");
		else printf("NO\n");
	}


}





Measured memory_bytes: 3624
// dp[i][v] = tuye i taye aval ye tedadi ro var darim ke majume arzeshashun beshe v, hade aghal vazneshun che ghadre !
// dp[0][v[0]] = w[0]
// dp[0][0] = 0
// else dp[0][i] = oo

#include <bits/stdc++.h>

using namespace std;

const int N = 110;
const int V = 1e3 + 10;

long long n, W, v[N], w[N], dp[N][N * V];

int main() {
    ios::sync_with_stdio(0);

    cin >> n >> W;
    for (int i = 0; i < n; i++)
        cin >> w[i] >> v[i];

    memset(dp, 63, sizeof(dp));
    dp[0][0] = 0;
    dp[0][v[0]] = w[0];

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < N * V; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j - v[i] >= 0)
                dp[i][j] = min(dp[i - 1][j - v[i]] + w[i], dp[i - 1][j]);
        }
    }

    for (int i = N * V - 1; ~i; i--)
        if (dp[n - 1][i] <= W) {
            cout << i << endl;
            return 0;
        }


    return 0;
}



Measured memory_bytes: 95744
import java.util.*;

public class Main {
    public static List<int[]> list = new ArrayList<>();
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int tmp = sc.nextInt();
        boolean big = false;
        boolean small = false;
        int count = 0;
        for (int i = 1; i < N; i++) {
            int now = sc.nextInt();
            if (now < tmp) {
                if (big) {
                    big = false;
                    count++;
                } else {
                    small = true;
                }
            } else if (tmp < now) {
                if (small) {
                    small = false;
                    count++;
                } else {
                    big = true;
                }
            } else {
                continue;
            }
            tmp = now;
        }
        System.out.println(count+1);
    }
}

Measured memory_bytes: 48988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll x,y; cin>>x>>y;
  int ret=0;
  ll element = y/x;
  while ( element ){
    element /= 2;
    ++ret;
  }

  cout << ret <<endl;
  return 0;
}

Measured memory_bytes: 256
from math import floor
from typing import NoReturn


def calc_equation(a: int, b: int, x:int) -> int:
    return floor(a * x / b) - a * floor(x / b)


def main() -> NoReturn:
    a, b, n = map(int, input().split())  # type: int, int, int

    if b > n:
        print(calc_equation(a, b, n))
    else:
        print(calc_equation(a, b, b - 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10104
require 'pp'

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N = gets_i
a_list = gets_i_list

a_total = 0
b_total = 0

a_list.sort.reverse.each_with_index do |a, i|
    if i.even?
      a_total += a
    else
      b_total += a
    end
end
puts a_total - b_total


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


int main () {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int minv;
    minv = max(X, Y) * 2 * C;
    if ( X >= Y ){
        minv = min(minv, min(X, Y) * 2 * C + (X - Y) * A);
    } else{
        minv = min(minv, min(X, Y) * 2 * C + (Y - X) * B);
    }
    minv = min(minv, X*A + Y*B);
    
    cout << minv;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second
 
ll mod = 1e9+7;
 
ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}
vector<vector<ll>> adj;
vector<ll> vis;
ll ct;

void dfs(ll u) {
	ct++;
	vis[u]=1;
	for(ll v : adj[u]) {
		if(vis[v]==0) {
			dfs(v);
		}
	}	
}

int main() {
	ll ttt;
	//cin>>ttt;
	ttt = 1;
	while(ttt--) {
		ll n,m; cin>>n>>m;
		adj.resize(n+1);
		vis.assign(n+1,0);
		for(int i=0; i<m; i++) {
			ll x,y; cin>>x>>y;
			adj[x].pb(y); adj[y].pb(x);
		}
		ll ans = 0;
		for(ll i=1; i<=n; i++) {
			if(vis[i]==0) {
				ct = 0;
				dfs(i);
				ans = max(ans,ct);
			}
		}
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 21900
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define CLR2d(x,m,n) memset(x, -1, sizeof(x[0][0]) * m * n)
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
ll po(ll b,ll p){
    ll res=1;
    while(p){
        res*=b;
        p--;
    }
    return res;
}
ll lg2(ll x){
    ll res=0;
    while(x>1){
        res++;
        x/=2ll;
    }
    return res;
}
void solve(){
    char ch;
    cin>>ch;
    ch++;
    cout<<ch<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah



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

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

	cin >> N;
	ll ans = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			int tmp = gcd(i+1, j+1);
			for (int k = 0; k < N; k++)
			{
				ans += gcd(tmp, k+1);
			}
			
		}
		
	}
	cout << ans << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n, k;
  cin >> n >> k;
  int count = 1;
  // int sum1 = pow(k, 1);
  while (n >= pow(k, count)){
    count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int, int>pii;
vector<pii>pat[100000];
bool flag[100000];
int d[100000];
void dfs(int node, int t)
{
	if (flag[node])
	{
		if (d[node] != t)
		{
			printf("No\n");
			exit(0);
		}
		return;
	}
	flag[node] = true;
	d[node] = t;
	for (int i = 0; i < pat[node].size(); i++)dfs(pat[node][i].first, t + pat[node][i].second);
}
int main()
{
	int num, way;
	scanf("%d%d", &num, &way);
	for (int i = 0; i < way; i++)
	{
		int za, zb, zc;
		scanf("%d%d%d", &za, &zb, &zc);
		za--, zb--;
		pat[za].push_back(make_pair(zb, zc));
		pat[zb].push_back(make_pair(za, -zc));
	}
	for (int i = 0; i < num; i++)
	{
		if (!flag[i])dfs(i, 0);
	}
	printf("Yes\n");
}


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

int n;

int main(){
    cin >> n;
    int b[n-1];
    int a[n];
    for(int i=0; i<n-1; i++){
        cin >> b[i];
        if (b[i] > b[i-1] && i != 0){
            a[i] = b[i-1];
        } else {
            a[i] = b[i];
        }
    }
    a[n-1] = b[n-2];
    cout << accumulate(a,a+n,0);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#define fo(x,a,b) for(int x=(a),_e=(b);x<=_e;x++)
#define fd(x,a,b) for(int x=(a),_e=(b);x>=_e;x--)
using namespace std;
typedef long long ll;

int main(){
	int n,x,t;
	scanf("%d %d %d",&n,&x,&t);
	printf("%d",(int)ceil(n*1.0/x)*t);
	return 0;
}


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

int main()
{
    ll x,a,b;
    cin>>x>>a>>b;
    if(b<=a)
		cout<<"delicious";
	else if(x+a>=b)
		cout<<"safe";
	else
		cout<<"dangerous";  
    
    return 0;
}

Measured memory_bytes: 3632
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	X := sc.i()
	Y := sc.i()

	for i := 0; X-i >= 0; i++ {
		j := X - i
		if 2*i+4*j == Y {
			fmt.Println("Yes")
			return 0
		}
	}

	fmt.Println("No")

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


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

int main() {
  int N, rcd, big, lsize = 101, num = 0;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++)
    cin >> d.at(i);
  for (int i = 0; i < N; i++) {
    big = 0;
    for (int j = 0; j < N; j++) {
      if (lsize > d.at(j) && d.at(j) > big)
        big = d.at(j);
    }
    if (big == 0)
      break;
    lsize = big;
    num++;
  }
  cout << num << endl;
}

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

int main()
{
    int n, x, count = 1;
    int ans = 0;
    cin >> n >> x;
    for (int i = 0; i < n; i++)
    {
        int l;
        cin >> l;
        ans += l;
        if (ans <= x)
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int output = 0;	
      int N = sc.nextInt();
      int H = sc.nextInt();
      int W = sc.nextInt();
      while(sc.hasNext()){
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A >= H && B >= W){
          output++;
        }
      }
      System.out.println(output);
	}
}


Measured memory_bytes: 25968
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int c1=0;
  int c2=0;
  int c3=0;
  int c4=0;
  string s;
  while(n--)
  {
    cin>>s;
    if(s=="AC")
      c1++;
    if(s=="WA")
      c2++;
    if(s=="TLE")
      c3++;
    if(s=="RE")
      c4++;
    
    

    
  }
  cout<<"AC"<<" "<<"x"<<" "<<c1<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<c2<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<c3<<endl;
  
  cout<<"RE"<<" "<<"x"<<" "<<c4<<endl;
  
  
  
  
}


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

const int _ = 1e5 + 7;
struct Edge{int end , upEd;}Ed[_ << 1];
int head[_] , dir[_] , d[_] , dep[_] , cntEd = 1 , N , M;

void addEd(int a , int b){Ed[++cntEd] = (Edge){b , head[a]}; head[a] = cntEd;}

int dfs(int x , int p){
	dep[x] = dep[p] + 1;
	for(int i = head[x] ; i ; i = Ed[i].upEd)
		if(Ed[i].end != p)
			if(!dep[Ed[i].end]){int t = dfs(Ed[i].end , x); dir[i >> 1] = (i & 1) ^ t; if(!t) ++d[x];}
			else if(dep[Ed[i].end] < dep[x]){++d[x]; dir[i >> 1] = i & 1;}
	return d[x] & 1;
}

int main(){
	cin >> N >> M; for(int i = 1 ; i <= M ; ++i){int p , q; cin >> p >> q; addEd(q , p); addEd(p , q);}
	if(M & 1){puts("-1"); return 0;}
	dfs(1 , 0);
	for(int i = 1 ; i <= M ; ++i)
		printf("%d %d\n" , Ed[(i << 1 | dir[i]) ^ 1].end , Ed[i << 1 | dir[i]].end);
	return 0;
}


Measured memory_bytes: 9216
n, m = map(int, input().split())
aa = reversed(sorted(map(int, input().split())))

t = ['_', 2, 5, 5, 4, 5, 6, 3, 7, 6]

# n 本使ってできる最大の桁数
dp = [-1 for _ in range(n + 1)]
dp[0] = 0

for a in aa:
    for i in range(len(dp)):
        if dp[i] >= 0 and i + t[a] < len(dp):
            dp[i + t[a]] = max(dp[i + t[a]], dp[i] * 10 + a)

print(dp[n])


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

using namespace std;

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

vector<string> board(70);
string memo[70][70];
int W, H;

inline bool isDigit(int x, int y)
{
    if ('0' <= board[y][x] && board[y][x] <= '9')
        return true;
    else
        return false;
}

string Rec(int x, int y)
{
    if (memo[y][x].size() != 0)
        return memo[y][x];

    string s, tmp;
    for (int d = 0; d < 2; ++d) {
        int nx = x + dx[d];
        int ny = y + dy[d];

        if (nx < 0 || nx >= W || ny < 0 || ny >= H || !isDigit(nx, ny))
            continue;

        tmp = Rec(nx, ny);
        if (tmp.size() > s.size() || (tmp.size() == s.size() && tmp > s))
            s = tmp;
    }

    return memo[y][x] = board[y][x] + s;
}

int main()
{
    while (cin >> W >> H, W || H) {
        // Input
        for (int i = 0; i < H; ++i) {
            cin >> board[i];
            for (int j = 0; j < W; ++j)
                memo[i][j] = "";
        }

        // Solve
        string tmp, ans;
        for (int i = 0; i < H; ++i)
            for (int j = 0; j < W; ++j)
                if (isDigit(j, i) && memo[i][j].size() == 0) {
                    tmp = Rec(j, i);
                    int index = 0;
                    while (tmp[index] == '0')
                        index++;
                    tmp = tmp.substr(index);

                    if (tmp.size() > ans.size() || (tmp.size() == ans.size() && tmp > ans))
                        ans = tmp;
                }

        // Output
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1384
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  h=LI()
  h.append(inf)

  dp=[inf]*114514
  dp[1]=0
  for i in range(1,n):
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i-1]))
    dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+1]-h[i-1]))
  return dp[n]

# main()
print(main())


Measured memory_bytes: 15916