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

int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	if(k==0)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(i*j+(n-i)*(m-j)==k)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	cout<<"No"<<endl;
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m, q;
	cin >>n >>m >>q;
	vector<VI> b(q, VI(4));
	rep(i, q){
		cin >>b[i][0] >>b[i][1] >>b[i][2] >>b[i][3];
		b[i][0]--; b[i][1]--;
	}
	
	ll ans = 0;
	rep(msk, 1<<(n+m-1)){
		if(__builtin_popcount(msk) != n) continue;
		VI v; int zct= 0;
		rep(i, n+m-1){ if(msk>>i &1) v.push_back(zct); else zct++;}
		ll sm = 0;
		for(auto& x: b){
			if(v[x[1]] - v[x[0]] == x[2]) sm += x[3];
		}
		ans = max(ans, sm);
	}

	cout <<ans <<"\n";
	return 0;
}


Measured memory_bytes: 3608
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, K = MAP()
S = input()

def searchRL(S):
    ans = []
    for i in range(N-1):
        if S[i] == "R" and S[i+1] == "L":
            ans.append(i)
    return ans

def searchLR(S):
    ans = []
    for i in range(N-1):
        if S[i] == "L" and S[i+1] == "R":
            ans.append(i)
    return ans

def reverse(S):
    S = list(S)
    for i in range(len(S)):
        if S[i] == 'L':
            S[i] = 'R'
        if S[i] == 'R':
            S[i] = 'L'
    return ''.join(S)


def solve(S):
    if len(RL) == 0 and len(LR) == 0:
        return S, 0
    if len(RL) == 0:
        S = reverse(S[LR[0]::-1]) + S[LR[0]+1:]
        LR.pop(0)
        return S, 1
    if len(LR) == 0:
        S = reverse(S[RL[0]::-1]) + S[RL[0]+1:]
        RL.pop(0)
        return S, 1
    fir = min(LR[0], RL[0])
    sec = max(LR[0], RL[0])
    S = S[:fir+1] + reverse(S[sec:fir:-1]) + S[sec+1:]
    LR.pop(0)
    RL.pop(0)
    return S, 2

def cal(S):
    ans = 0
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            ans +=1
    return ans

RL = searchRL(S)
LR = searchLR(S)
ans = cal(S)
for i in range(K):
    S, res = solve(S)
    ans += res
print(ans)


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

cum_a = [0]*n
cum_a[0] = a[0]
for i in range(1, n):
    cum_a[i] = cum_a[i-1] + a[i]
res = 0
cnt = {0: 0}
for cum in cum_a:
    if cum not in cnt:
        cnt[cum] = 1
    else:
        res += cnt[cum]
        cnt[cum] += 1
print(res+cnt[0])


Measured memory_bytes: 41460
#include <iostream>
#include <vector>
#include <string>
int longestLength(const std::string &a, const std::string &b, int aIndex, int bIndex, std::vector<std::vector<int>> &memo) {
	if (aIndex > a.length() || bIndex > b.length()) return 0;
	if (memo[aIndex][bIndex] < 0) {
		memo[aIndex][bIndex] = 0;
		if (aIndex < a.length() && bIndex < b.length()) {
			if (a[aIndex] == 'I' || b[bIndex] == 'I') {
				memo[aIndex][bIndex] = 1;
				if (a[aIndex] == 'I' && aIndex + 1 < a.length() && a[aIndex + 1] == 'O') {
					if (memo[aIndex][bIndex] < longestLength(a, b, aIndex + 2, bIndex, memo) + 2)
						memo[aIndex][bIndex] = longestLength(a, b, aIndex + 2, bIndex, memo) + 2;
				}
				if (b[bIndex] == 'I' && bIndex + 1 < b.length() && b[bIndex + 1] == 'O') {
					if (memo[aIndex][bIndex] < longestLength(a, b, aIndex, bIndex + 2, memo) + 2)
						memo[aIndex][bIndex] = longestLength(a, b, aIndex, bIndex + 2, memo) + 2;
				}
				if ((a[aIndex] == 'I' && b[bIndex] == 'O') || (a[aIndex] == 'O' && b[bIndex] == 'I')) {
					if (memo[aIndex][bIndex] < longestLength(a, b, aIndex + 1, bIndex + 1, memo) + 2)
						memo[aIndex][bIndex] = longestLength(a, b, aIndex + 1, bIndex + 1, memo) + 2;
				}
			}
		}
		else {
			if (aIndex < a.length() && a[aIndex] == 'I') {
				memo[aIndex][bIndex] = 1;
				if (aIndex + 1 < a.length() && a[aIndex + 1] == 'O')
					if (memo[aIndex][bIndex] < longestLength(a, b, aIndex + 2, bIndex, memo) + 2)
						memo[aIndex][bIndex] = longestLength(a, b, aIndex + 2, bIndex, memo) + 2;
			}
			else if (bIndex < b.length() && b[bIndex] == 'I') {
				memo[aIndex][bIndex] = 1;
				if (bIndex + 1 < b.length() && b[bIndex + 1] == 'O')
					if (memo[aIndex][bIndex] < longestLength(a, b, aIndex, bIndex + 2, memo) + 2)
						memo[aIndex][bIndex] = longestLength(a, b, aIndex, bIndex + 2, memo) + 2;
			}
		}
		if (memo[aIndex][bIndex] != 0 && memo[aIndex][bIndex] % 2 == 0) memo[aIndex][bIndex]--;
	}
	return memo[aIndex][bIndex];
}
int main() {
	int m, n;
	std::cin >> m >> n;
	std::string a, b;
	std::cin >> a >> b;
	std::vector<std::vector<int>> memo(m + 1, std::vector<int>(n + 1, -1));
	int max = 0;
	for (auto i = 0; i < a.length(); ++i) for (auto j = 0; j < b.length(); ++j) {
		if (max < longestLength(a, b, i, j, memo)) max = memo[i][j];
	}
	std::cout << max << std::endl;
}



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

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

    double ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 2 == 1) {
            ans++;
        }
    }

    cout << ans / n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef vector<int> vi;

int w,n,a,b;

int main() {
	scanf("%d", &w);
	vi v(w);
	rep(i,w) v[i] = i+1;

	scanf("%d", &n);
	rep(i,n) {
		scanf("%d,%d", &a, &b);
		swap(v[a-1], v[b-1]);
	}

	rep(i,w) printf("%d\n", v[i]);
}

Measured memory_bytes: 1188
n = int(input())
s = input()

R = []
G = []
list = [0]*n
number_B = 0
for i in range(n):
  if s[i] == 'R':
    R.append(i)
  elif s[i] == 'G':
    G.append(i)
  else:
    list[i] = 1
    number_B += 1
    

ans = 0
for i in R:
  for j in G:
    minus = 0
    if i < j:
      if 2*i-j >= 0 and list[2*i-j] == 1:
        minus += 1   
      if (i+j)%2 == 0 and list[int((i+j)/2)] == 1:
        minus += 1      
      if 2*j-i<n and list[2*j-i] == 1:
        minus += 1
    else:
      if 2*j-i >= 0 and list[2*j-i] == 1:
        minus += 1   
      if (i+j)%2 == 0 and list[int((i+j)/2)] == 1:
        minus += 1      
      if 2*i-j<n and list[2*i-j] == 1:
        minus += 1
    ans += (number_B-minus)
    
print(ans)


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

int main() {
  double l;
  cin >> l;

  //最大値は与えられた数字を３で割って３乗したもの
  double x = l/3;
  double ans = pow(x,3);

  printf("%.10f\n",ans); //フォーマット指定子
}


Measured memory_bytes: 384
from collections import deque

H, W = map(int, input().split())
black = 0
s = ["#" * (W+2)]
for _ in range(H):
    row = input()
    black += row.count("#")
    s.append("#" + row + "#")
s.append("#" * (W+2))

def bfs(x, y):
    if s[x][y] == "#":
        return 0
    queue = deque([(x, y)])
    dist = [[-1]*(W+2) for _ in range(H+2)]
    dist[x][y] = 0
    while queue:
        r, c = queue.popleft()
        d = dist[r][c]
        for i in [r-1, r+1]:
            if i >= 0 and i <= H:
                if s[i][c] == "." and dist[i][c] == -1:
                    dist[i][c] = d+1
                    queue.append((i, c))
        for j in [c-1, c+1]:
            if j >= 0 and j <= W:
                if s[r][j] == "." and dist[r][j] == -1:
                    dist[r][j] = d+1
                    queue.append((r, j))
    return dist
ans = bfs(1,1)[-2][-2]
if ans != -1:
    print(H*W-bfs(1,1)[-2][-2]-1-black)
else:
    print(-1)

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

int main() {
	int n;
	int number[200][3];
	int score[200] = {0};
	int judge = 0;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> number[i][0] >> number[i][1] >> number[i][2];
	}
	for(int ii = 0; ii < n; ii++) {
		for(int g = 0; g < 3; g++) {
			judge = 0;
			for(int i = 0; i < n; i++) {
				if(ii == i) {
					continue;
				}
				if(number[ii][g] == number[i][g]) {
					judge++;
				}
			}
			if(judge == 0) {
				score[ii] += number[ii][g];
			}
		}
	}
	for(int i = 0; i < n; i++) {
		cout << score[i] << endl;
	}
	return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;

  ll T, A;
  ll min_A, min_T;
  min_A = 1;
  min_T = 1;
  rep(i, N){
    cin >> T >> A;
    
    ll max_mult = max((min_T + T - 1) / T,((min_A + A - 1) / A));

    min_A = A * max_mult;
    min_T = T * max_mult;

  }
  cout << min_A + min_T << endl;

  return 0;
}


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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            Console.WriteLine(Math.Min(a, b) + Math.Min(c, d));
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args){

		Scanner scn = new Scanner(System.in);
		
		int S = scn.nextInt();

		System.out.println(S / 3600+ ":" + (S % 3600)/60 + ":" + S%60);
	}
}

Measured memory_bytes: 26308
f = lambda: map(int,input().split())


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


n, X = f()
x = list(f())
ans = x[0]-X

for i in range(1,n):
    ans = gcd(ans,x[i]-X)
print(abs(ans))

Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

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

  int x = 0;
  for(int i=0; i<n; i++) {
    if (a[i] == x+1) x++;
  }
  if (x == 0) {
    cout << -1 << endl;
  } else {
    cout << n - x << endl;
  }

  return 0;
}


// EOF


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

int main() {
	long long n,k;
	cin >> n;
	
	string s="";
	char c;

	while(n>0){
		n--;
		k=n%26;
		n/=26;
		c='a'+k;
		s.push_back(c);
	}
	reverse(s.begin(),s.end());
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<set>
#define maxn 200005
using namespace std;
int n,k;
int p[maxn];
set<int> s1,s2;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	scanf("%d",&p[i]);
	p[0]=-1;
	int cnt=0,flag=1;
	for(int i=1;i<=k;i++)
	{
		s1.insert(p[i]);
		s2.insert(-p[i]);
		if(p[i]>p[i-1])
			cnt++;
		else
			cnt=1;
	}
	if(cnt==k)
		flag=0;	
	int ans=1;
	for(int i=k+1;i<=n;i++)
	{
		if(p[i]>p[i-1])
			cnt++;
		else
			cnt=1;
		s1.erase(p[i-k]);
		s2.erase(-p[i-k]);
		int minn=(*s1.begin());
		int maxx=(-(*s2.begin()));
		if(maxx<p[i] && minn>p[i-k])
		1;
		else
		{
			if(cnt>=k)
			{
				if(flag==1)
				{
					flag=0;
					ans++;
				}
				else
				{
					flag=0;
				}
			}
			else
				ans++;
		}
		s1.insert(p[i]);
		s2.insert(-p[i]);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 19712
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int res[20] = {0};
signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n); if(!n)break;
    rep(i, 20)res[i] = -1;
    int head = 0;

    for(;n > 0;){
      res[head++] = n % 8;
      if(res[head - 1] >= 4)res[head - 1]++;
      if(res[head - 1] >= 6)res[head - 1]++;
      n /= 8;
    }
    per(i, head)cout << res[i];
    kara;



//*/

//*/ break;
  }
  return 0;
}

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

int H, W;
vector<string> v;
int lefts[2100][2100], rights[2100][2100], ups[2100][2100], downs[2100][2100];

int main() {
    cin >> H >> W;

    v.resize(H);
    for (int i = 0; i < H; i++){
        cin >> v[i];
    }

    for (int i = 0; i < H; i++){
        int cur = 0;
        for (int j = 0; j < W; j++)
        {
            if(v[i][j] == '#') cur = 0;
            else cur++;
            lefts[i][j] = cur;
        } 
    }

    for (int i = 0; i < H; i++){
        int cur = 0;
        for (int j = W-1; j >= 0; j--)
        {
            if(v[i][j] == '#') cur = 0;
            else cur++;
            rights[i][j] = cur;
        } 
    }

    for (int j = 0; j < W; j++){
        int cur = 0;
        for (int i = 0; i < H; i++)
        {
            if(v[i][j] == '#') cur = 0;
            else cur++;
            ups[i][j] = cur;
        } 
    }

    for (int j = 0; j < W; j++){
        int cur = 0;
        for (int i = H-1; i >= 0; i--)
        {
            if(v[i][j] == '#') cur = 0;
            else cur++;
            downs[i][j] = cur;
        } 
    }

    int res = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if(v[i][j] == '#') continue;
            res = max(res, ups[i][j] + downs[i][j] + lefts[i][j] + rights[i][j]-3);
        }
    }
    cout << res << endl;
}

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

typedef long long int ll;

ll gcd(ll a, ll b){
	return b == 0 ? a : gcd(b, a%b); 
}

ll lcm(ll a, ll b){
	return (a*b)/gcd(a, b);
}

int main()
{
	ll a, b;
	cin >> a >> b;
	cout << lcm(max(a, b),min(a, b)) << endl;

	return 0;
}

Measured memory_bytes: 256
def main():
    idnum,gatenum = [int(element) for element in input().split(" ")]
    minid = 0
    maxid = idnum

    for gete in range(gatenum):
        condmin,condmax = [int(element) for element in input().split(" ")]
        if(minid<condmin):
            minid = condmin
        if(maxid>condmax):
            maxid = condmax

    if(maxid<minid):
        print(0)
    else:
        print(maxid-minid+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    int n; cin >> n;

    long long p, a, tot = 0;

    for(int i = 1; i < n; ++i){
        cin >> a;
        if(i == 1) tot += a;
        else tot += min(a, p);
        p = a;
    }

    cout << tot + p;

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
// #include <atcoder/all>
// using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<P> p(n);
    rep (i, n) cin >> p[i].first >> p[i].second;
    vector<ll> a(n), b(n);
    rep (i, n) {
        a[i] = p[i].first - p[i].second;
        b[i] = p[i].first + p[i].second;
    }
    sort(all(a)); sort(all(b));
    cout << max(a.back() - a.front(), b.back() - b.front()) << "\n";
    /***************************************************/
    /* Submit this code from the browser if using ACL! */
    /***************************************************/
    return 0;
}

Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
 
long long h, w, n;
map<long long, long long> mp;
long long dx[9] = {0, -1, -2, 0, -1, -2, 0, -1, -2};
long long dy[9] = {0, 0, 0, -1, -1, -1, -2, -2, -2};
long long ans[10];
long long GetNo(long long x, long long y)
{
    if(x < 1 || y < 1)
        return -1;
    if(x > h - 2 || y > w - 2)
        return -1;
    return (x - 1) * (w - 2) + y;
}
void Add(long long x, long long y)
{
    for(long long i = 0;i < 9;++i)
    {
        long long nx = x + dx[i];
        long long ny = y + dy[i];
        long long res = GetNo(nx, ny);
        if(res != -1)
            ++mp[res];
    }
}
int main()
{
    scanf("%lld%lld%lld", &h, &w, &n);
    for(long long i = 1;i <= n;++i)
    {
        long long x, y;
        scanf("%lld%lld", &x, &y);
        Add(x, y);
    }
    memset(ans, 0, sizeof(ans));
    ans[0] = GetNo(h - 2, w - 2);
    for(auto it = mp.begin();it != mp.end();++it)
    {
        long long cnt = it->second;
        ++ans[cnt];
        --ans[0];
    }
    for(long long i = 0;i < 10;++i)
        printf("%lld\n", ans[i]);
    return 0;
}
/*
4 5 8
1 1
1 4
1 5
2 3
3 1
3 2
3 4
4 4
*/

Measured memory_bytes: 56448
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstdint>

#define rep(ident, start, end) for(int ident=start;ident<end;ident++)

using namespace std;

int main(void){
	int N;
	cin >> N;
	if (N < 105)cout << 0 << endl;
	else if (N < 135)cout << 1 << endl;
	else if (N < 165)cout << 2 << endl;
	else if (N < 189)cout << 3 << endl;
	else if (N < 195)cout << 4 << endl;
	else cout << 5 << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

def gcd(a,b):
  if b == 0:
    return a
  return gcd(b,a % b)

g = gcd(A[0],A[1])

for i in range(2,N):
  g = gcd(g,A[i])
  
print(g)

Measured memory_bytes: 15376
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long n, k;
  long x, y;
  Solver() {
    S002 r;
    r >= n >= k >= x >= y;
  }
  void solve() {
    long res = std::min(n, k) * x + std::max((long)0, n - k) * y;
    printf("%ld\n", res);
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;
static const int MAX = 100000;

int main() {
    int N;
    cin >> N;
    
    int h, maxcnt = 0, cnt = 0;
    int prev = 0;
    for (int i = 0; i < N; i++) {
        cin >> h;
        if (h <= prev) {
            cnt++;
            maxcnt = max(maxcnt, cnt);      
        } else {
            cnt = 0;
        }
        prev = h;
        
    }
    
    cout << maxcnt;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
              
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

using namespace std;

const int maxn = (int)2e5 + 100;
//const int mod = (int)1e9 + 7;
const int P = (int) 1e6 + 7; 

//#define inf mod

typedef long double ld;                          
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;                        

int n, mod, dp1[maxn], pos[maxn], dp2[maxn], pos1[maxn], pos2[maxn];
vi g[maxn], pref[maxn], suf[maxn];
void dfs(int v, int p = 0){
  dp1[v] = 1;
  for(int to : g[v]){
    dfs(to, v);
    dp1[v] = (dp1[v] * 1ll * (dp1[to] + 1)) % mod;
    pos1[to] = sz(pref[v]);
      pref[v].pb(dp1[v]);
  }
  dp1[v] = 1;
  forev(i, sz(g[v]) - 1, 0){
    int to = g[v][i];
    dp1[v] = (dp1[v] * 1ll * (dp1[to] + 1)) % mod;
    pos2[to] = sz(suf[v]);
    suf[v].pb(dp1[v]);
  }
}
void dfs1(int v, int p = 0){
  if(!p) dp2[v] = 1;
  else{
    int tot = 1;
    if(pos1[v]) tot = pref[p][pos1[v] - 1];
    if(pos2[v]) tot = (tot * 1ll * suf[p][pos2[v] - 1]) % mod; 
    tot = (tot * dp2[p]) % mod;
    dp2[v] = (tot + 1) % mod;
  }
  for(int to : g[v]){
    if(to != p)
      dfs1(to, v);
  }
}      
int todel[maxn];
void del(int v, int p = 0){
  forn(i, 0, sz(g[v]) - 1){
    int to = g[v][i];
    if(to == p) todel[v] = i;
    else del(to, v);
  }
}
main () {
  cin >> n >> mod;               
  forn(i, 1, n - 1){
    int u, v;
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  memset(todel, -1, sizeof(todel));
  del(1);
  forn(i, 1, n)
    if(todel[i] != -1)
      g[i].erase(g[i].begin() + todel[i]);
  dfs(1);
  dfs1(1);
  forn(i, 1, n){
    cout << (dp1[i] * 1ll * dp2[i]) % mod << endl;
  }
}

Measured memory_bytes: 38272
#include<iostream>

using namespace std;

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

	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;

		H -= A;
	}

	if (H <= 0) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ll k, a, b; cin >> k >> a >> b;

    if (b - a <= 2 || k < a-1) cout << k + 1 << endl;
    else {
        ll res = a;
        k -= a - 1;
        if (k % 2 == 1) res++, k--;
        res += (b - a) * (k / 2);
        cout << res << endl;
    }
}


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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x,ll y,ll m) 
{
    ll res = 1; 
    x = x % m;                
    if (x == 0)
        return 0; 
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

ll gcd(ll a,ll b) 
{
    if(b==0) return a;
    return gcd(b,a%b);
}

void solve()
{
    ll x;
    cin>>x;
    ll v=100;

    ll c=0;
    while(v<x) {
        c++;
        v=v+v/100;
    }
    cout<<c;
}

int main()
{
    fastio;
    int t;
    t=1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        //cout<<newl;
    }

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N, D, A;
    cin >> N >> D >> A;

    vector<pair<int,int>> XH(N);
    rep(i, N) {
        cin >> XH[i].first >> XH[i].second;
    }
    sort(XH.begin(), XH.end());

    LL ans = 0;
    int tot = 0;
    queue<pair<int, int>> q;
    for (int i = 0; i < N; ++i) {
        while (!q.empty() && q.front().first < XH[i].first) {
            tot -= q.front().second;
            q.pop();
        }

        if (tot < XH[i].second) {
            int a = (XH[i].second-tot+A-1) / A;
            ans += a;
            tot += a * A;
            q.push(make_pair(XH[i].first + 2 * D, a * A));
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2688
S = gets.chomp.split("")

# puts S*" "

children = Array.new(S.length)

for i in 0...(S.length - 1) do
  if S[i] == "R" && S[i+1] == "R" then
    children[i] = 0
  elsif S[i] == "L" && S[i+1] == "L" then
    children[i+1] = 0
  end
end

pointR = 0
for i in 0...S.length do
  pointR += 1 if S[i] == "R"
  if children[i] == nil && S[i] == "R" then
    children[i] = pointR
    next
  elsif S[i] == "L" then
    pointR = 0
  end
end

pointL = 0
for i in (S.length-1).downto(0) do
  pointL += 1 if S[i] == "L"
  if children[i] == nil && S[i] == "L" then
    children[i] = pointL
    next
  elsif S[i] == "R"
    pointL = 0
  end
end

# puts children*" "

for i in 0...(S.length-1) do
  if [S[i], S[i+1]] == ["R", "L"] then
    if (children[i+1] - children[i]).modulo(2) == 0 then
      children[i] = (children[i] + children[i+1]) / 2
      children[i+1] = children[i]
    elsif children[i].even?
      children[i] = (children[i] + children[i+1]) / 2
      children[i+1] = children[i] + 1
    elsif children[i].odd?
      children[i+1] = (children[i] + children[i+1]) / 2
      children[i] = children[i+1] + 1
    end
  end
end

puts children*" "


Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,cnt,p[200000],mn;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&p[i]);
	mn=p[0];	cnt=1;
	for(i=1;i<n;i++)	{
		mn=min(mn,p[i]);
		if(p[i]<=mn)	cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double 
const long double pi = 3.1415926535898;
#define dec greater<lli>()
const lli mod=1000000007;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    fio;
    lli n,k;
    cin>>n>>k;
    lli a[n];
    for (int i=0;i<n;i++)
    cin>>a[i];
    for (int i=0;i<n-k;i++)
    {
        if (a[i]<a[i+k])
        {
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
        }
    }
    return 0;
}

Measured memory_bytes: 5236
/************************************************************
	>>--> Author: Frederick
	>>--> Mail: 197***3881@qq.com
************************************************************/
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
#define ull unsigned long long
#define CIN ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int maxn=2e5+5;
const ll MOD=1e9+7;
const int INF = 0x3f3f3f3f;

int main(){
    CIN;
    int n;
    string s;
    cin>>n;
    cin>>s;
    int cnt=0;
    for(int i=0;i<=s.size();i++){
    	if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}



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

int main(){
    int N;
    cin >> N;
    vector<int> edges[200000];
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<int> C[2];
    auto dfs = [&](auto&& dfs, int i, int p, int c)->void{
        C[c].push_back(i);
        for(int j : edges[i]) if(j != p) dfs(dfs, j, i, 1-c);
    };
    dfs(dfs, 0, -1, 0);

    if(C[0].size() > C[1].size()) swap(C[0], C[1]);

    vector<int> V[3];
    for(int i=1; i<=N; i++) V[i%3].push_back(i);

    vector<int> ans(N);
    for(int a : V[1]){
        ans[C[1].back()] = a;
        C[1].pop_back();
    }
    if(V[2].size() <= C[1].size()){
        for(int a : V[2]){
            ans[C[1].back()] = a;
            C[1].pop_back();
        }
    }else{
        for(int a : V[2]){
            ans[C[0].back()] = a;
            C[0].pop_back();
        }
    }
    for(int a : V[0]){
        if(C[0].size()){
            ans[C[0].back()] = a;
            C[0].pop_back();
        }else{
            ans[C[1].back()] = a;
            C[1].pop_back();
        }
    }
    for(int i=0; i<N; i++) cout << ans[i] << " \n"[i==N-1];
    return 0;

}


Measured memory_bytes: 18036
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ll INF = 1e15;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll pow(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	if (b == 1) {
		return a;
	}
	ll ans = pow(a, b / 2);
	ans *= ans;
	ans *= b % 2 == 1 ? a : 1;
	return ans;
}

namespace SOLVE {
	struct edge {
		ll to, from, weight;
	};

	vector<vector<edge>> edges;

	int farthest;
	int nextindex;

	void dfs(int at, int weight, int previous) {
		if (weight > farthest) {
			farthest = weight;
			nextindex = at;
		}
		for (edge e : edges[at]) {
			if (e.to != previous) {
				dfs(e.to, weight + e.weight, at);
			}
		}
	}

	void main() {
		int n, a, b, c;
		cin >> n;
		edges.resize(n);

		REP(i, 0, n - 1) {
			cin >> a >> b >> c;
			edge e1, e2;
			e1.from = a;
			e1.to = b;
			e1.weight = c;
			e2.from = b;
			e2.to = a;
			e2.weight = c;
			edges[a].push_back(e1);
			edges[b].push_back(e2);
		}

		farthest = 0;
		nextindex = 0;
		dfs(0, 0, -1);

		dfs(nextindex, 0, -1);
		cout << farthest << endl;
	}
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t;
	//    in(t);
	t = 1;
	while (t--) {
		SOLVE::main();

	}

	return 0;
}



Measured memory_bytes: 16056
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    edge=[]
    for i in range(M):
        a,b,c=map(int1,input().split())
        c+=1
        edge.append((a,b,-c))
    d=[INF]*N
    d[0]=0
    f=False
    for i in range(N*2):
        for a,b,c in edge:
            if d[b]>d[a]+c:
                if i<N-1:
                    d[b]=d[a]+c
                else:
                    if d[a]<10**17:
                        d[b]=-INF
                    if b==N-1:
                        f=True
    if f:
        print('inf')
    else:
        print(-d[N-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 40944
#include<stdio.h>
int main(void){



int a,b,c;

int i;


int count=0;


scanf("%d %d %d",&a,&b,&c);


for(i=a;i<=b;i++){


if(c%i==0){


count++;


}


}


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


return 0;

}

Measured memory_bytes: 596
#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#ifdef DEBUG
	#include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
	#define debug(x...) { dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals); }
	#define light_debug(x) { dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0; }
#else
	#define debug(x...)
	#define light_debug(x) 
#endif

template<typename T>
inline T& ckmin(T& a, T b) { return a = a > b ? b : a; }

template<typename T>
inline T& ckmax(T& a, T b) { return a = a < b ? b : a; }

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;


int main() {

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

	#ifdef DEBUG
		freopen("debug", "w", stderr);
	#endif
	
	int n; cin >> n;
	ll ans = 0;
	rep1(i, n) 
		ans += (n - 1) / i;
	
	cout << ans << '\n';

	#ifdef DEBUG
		dbg::dout << "\nExecution time: " << clock() << "ms\n";
	#endif

	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed;
    cout<<setprecision(10);

    ll n,k;
    cin>>n>>k;
    ll a[n+5];
    for (int i=0;i<n;i++)
        cin>>a[i];
    ll mx=0;
    ll sum=0;
    for (int i=0;i<k;i++)
    {
        sum+=a[i];
    }
    mx=sum;
    for (int i=k;i<n;i++)
    {
        sum-=a[i-k];
        sum+=a[i];
        mx=max(mx,sum);
    }
    double ans=(mx+k)/2.0;
    cout<<ans<<endl;



    return 0;
}


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

    string res = "";
    for (int i = 0; i < n; i++) {
        if (i == k -1) res += tolower(s[i]);
        else res += s[i];
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int n, b, f, r, v;
	int a[4][3][10] = { 0 };

	scanf("%d", &n);

	for (int n_i = 0; n_i < n; n_i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);

		a[b-1][f-1][r-1] += v;
	}

	for (int b_i = 0; b_i < 4; b_i++) {
		for (int f_i = 0; f_i < 3; f_i++) {
			for (int r_i = 0; r_i < 10; r_i++) {
				if (r_i == 9) {
					printf(" %d\n", a[b_i][f_i][r_i]);
				}
				else {
					printf(" %d", a[b_i][f_i][r_i]);
				}
			}
		}

		if (b_i < 3) {
			puts("####################");
		}
	}

	return 0;
}




Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL << 60;
const int MOD = (int) 1e9 + 7;

signed main(){
    int n, m;
    cin >> n >> m;
    vector<string> va(n);
    vector<string> vb(m);
    for (int i = 0; i < n; i++) {
        cin >> va[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> vb[i];
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (va[i][j] == vb[0][0]) {
                bool flag = true;
                for (int I = 0; I < m; I++) {
                    for (int J = 0; J < m; J++) {
                        if (i + I >= n || j + J >= n)
                            flag = false;
                        else if (va[i + I][j + J] != vb[I][J])
                            flag = false;
                    }
                }
                if (flag) {
                    cout << "Yes" << "\n";
                    return 0;
                }
            }
        }
    }
    cout << "No" << "\n";
}

Measured memory_bytes: 256
/* ex3_2
        fmuacshai */

#include<stdio.h>
int main(void){
    //整数nとnの1の位ones_placeを定義
    int n,ones_place;
    //nを入力
    scanf("%d",&n);
    //nの1の位を計算
    ones_place=n%10;
    //nの1の位によって場合分け
    if(ones_place==3){
        //bonの場合
        printf("bon\n");
    }else if(ones_place==0 || ones_place==1 || ones_place==6 || ones_place==8){
        //ponの場合
        printf("pon\n");
    }else{
        //honの場合
        printf("hon\n");
    }
    return 0;
}

Measured memory_bytes: 1640
#include <iostream>

using namespace std;

string f(int x, int a, int b) {
    if (a >= b) {
        return "delicious";
    }
    if (a + x >= b) {
        return "safe";
    }
    return "dangerous";
}

int main() {

    int x, a, b;
    cin >> x >> a >> b;

    string result = f(x, a, b);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string.h>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	string s, ans;
	cin >> s;
	int N = s.size();

	for (int i = 0; i < N; i=i+2) ans += s[i];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  n <- unsafeSignedDecimal <$> T.getLine :: IO Int
  print $ 180 * (n - 2)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#include <iostream>

int main(int argc, char** argv)
{
	long long num, sum=0;
	std::cin >> num;
	for (long long i = 0; i <= num; i++)
	{
		if(i % 3 != 0 && i % 5 != 0)
		{
			sum += i;
		}
	}
	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        Integer n = Integer.parseInt(sc.next());
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }

        // 主処理
        Map<String, Integer> map = new HashMap<>();
        int max = 0;
        List<String> list = new ArrayList<>();
        for (String str : s) {
            if (map.containsKey(str)) {
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            }
            if (max == map.get(str)) {
                list.add(str);
            } else if (max < map.get(str)) {
                list = new ArrayList<>();
                list.add(str);
            }
            max = Math.max(max, map.get(str));
        }
        String[] arr = list.toArray(new String[list.size()]);
        Arrays.sort(arr);

        String result = String.join("\r\n", arr);

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 85420
import java.util.Scanner;

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

        String string = scanner.next();
        int tmp = Integer.parseInt(string);
        int a = tmp / 100;
        int b = tmp % 100;

        if ((a > 12 || a < 1) && (b <= 12 && b >= 1)) {
            System.out.println("YYMM");
        } else if ((b > 12 || b < 1) && (a <= 12 && a >= 1)) {
            System.out.println("MMYY");
        } else if ((a <= 12 || a >= 1) && (b <= 12 && b >= 1)) {
            System.out.println("AMBIGUOUS");
        } else {
            System.out.println("NA");
        }
    }
}

Measured memory_bytes: 21844