akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	int a[100000];
	int b[100000];
	int c, d;
	int k;
	long long n, m;
	int s, t;
	long long w, x, y, z;
	long long ans;

	scanf("%lld %lld %lld %lld", &w, &x, &y, &z);

	scanf("%lld", &n);

	if (4 * w < 2 * x)m = 4 * w;
	else m = 2 * x;
	if (y < m)m = y;
	if (2 * m < z){
		ans = m*n;
		printf("%lld\n", ans);
	}
	else {
		ans = (z*(n / 2)) + (m*(n % 2));
		printf("%lld\n", ans);
	}


	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
    ll k,a,b;
    scanf("%lld%lld%lld",&k,&a,&b);
    ll ans,s;
    if(a >= k)
    {
        printf("1\n");
        return 0;
    }
    if(a <= b)
    {
        printf("-1\n");
        return 0;
    }
    s = (k-a)/(a-b);
    ans = s*(a-b)+a;
    s = s*2+1;
    if(ans >= k)
        printf("%lld\n",s);
    else
        printf("%lld\n",s+2);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace  std;
int n,k,i,j;
int main() 
{
  cin>>n;
  pair<int,int> h[n+1];
  for(i=1;i<=n;i++)
  {
    cin>>h[i].first;
    h[i].second=i;
  }
  sort(h+1,h+n+1);
  for(i=1;i<=n;i++)
  {
    cout<<h[i].second<<" ";
  }
}

Measured memory_bytes: 1536
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AAirplane solver = new AAirplane();
        solver.solve(1, in, out);
        out.close();
    }

    static class AAirplane {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            PriorityQueue<Integer> pq = new PriorityQueue<>(3);
            for (int i = 0; i < 3; i++) pq.add(s.nextInt());
            w.println(pq.poll() + pq.poll());
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
 
using namespace std;

map <int, int> m;

void nope() {
	printf ("No\n");
	exit(0);
}

void yep() {
	printf ("Yes\n");
	exit(0);
}

int main() {
	int n, a;
	scanf ("%d", &n);
	rep(i, 1, n) {
		scanf ("%d", &a);
		m[a]++;
		if (ss(m) > 3) 
			nope();
	}
	if (ss(m) == 1) {
		if (m.count(0)) 	
			yep();
		else
			nope();
	}
	if (ss(m) == 2) {
		if (n % 3 || !m.count(0) || m[0] != n / 3) nope();
		yep();
	}
	assert(ss(m) == 3);
	if (n % 3) nope();
	int XOR = 0;
	for (auto it : m) {
		if (it.se != n / 3) nope();
		XOR ^= it.fi;
	}
	if (XOR) nope();
	yep();
	
	
	return 0;
}	


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

int main(){
   string s1, s2, s3;
   cin >> s1 >> s2 >> s3;
   if (s1[s1.length()-1]==s2[0]&&s2[s2.length()-1]==s3[0]){
     cout <<"YES" << endl;
   }
   else {
      cout << "NO" << endl;
   }
}

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

const Int MOD = 998244353;

vector<Int> f(200010), invf(200010);


//---------- べき乗 ----------
Int power(Int a, Int n){
    if(a == 0) return 0;
    if(n == 0) return 1;
    
    Int res = 1;
    while(n > 0){
        if(n % 2 == 1) res = res * a % MOD;
        a = a * a % MOD; n /= 2;
    }
    return res;
}

//---------- 逆元 ----------
Int inv(Int a){
    return power(a, MOD-2);
}

//---------- 階乗 ----------
vector<Int> factorial(Int n){
    vector<Int> res(n+1, 1);
    for(int i=1; i<=n; i++) res[i] = i * res[i-1] % MOD;

    return res; // nまでの階乗の配列を返す
}


//--------- 組み合わせ ---------
Int comb(Int n, Int r){
    return (f[n] * invf[r] % MOD) * invf[n-r] % MOD;
}


int main(){
    Int N, M, K;
    cin >> N >> M >> K;

    if(M==1){
        if(K == N-1) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }

    f = factorial(N);
    rep(i,f.size()) invf[i] = inv(f[i]);

    Int ans = 0, p = inv(M-1);
    for(Int i=N-1; i>=0; i--){
        p = p * (M-1) % MOD;
        //cout << p << endl;
        if(i > K) continue;
        
        Int tmp = M;
        tmp = tmp * comb(N-1,i) % MOD;
        tmp = tmp * p % MOD;

        ans = (ans + tmp) % MOD;
    }

    cout << ans << endl;

}


Measured memory_bytes: 7948
#include <iostream>

int main() {

	while (true) {
		std::string n;
		std::cin >> n;
		if (n != "0") {
			int digits_sum = 0;
			for (const char &c : n) digits_sum += (c - '0');
			std::cout << digits_sum << '\n';
		} else {
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3160
n = int(input())
lst = []
for _ in range(n):
    a = [int(x) for x in input().split()]
    lst.append(a)

possible = True
for i in range(n):
    if i == 0:
        dif = lst[i][1] + lst[i][2]
        tdif = lst[i][0]
    else:
        dif = abs((lst[i][1] + lst[i][2]) - (lst[i-1][1] + lst[i-1][2]))
        tdif = lst[i][0] - lst[i-1][0]
    if tdif < dif:
        possible = False
        break
    if (tdif - dif) % 2 != 0:
        possible = False
        break

if possible:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21180
from bisect import bisect_left,bisect_right
N = int(input())
L = list(map(int,input().split()))
count = 0
L.sort()

for i in range(N-2):
    for j in range(i+1,N-1):
            count += max(bisect_right(L,L[i]+L[j]-1)-j-1,0)

print(count)


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

const int INF = 1001001001;

int main() {
    int k;
    cin >> k;
    int ans = -1;
    int n = 7 % k;
    for (int i = 0; i < k; ++i) {
        if (n == 0) {
            ans = i + 1;
            break;
        }
        n = (n * 10 + 7) % k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define INF (int)1e9+5
#define nax (int)1e5+2
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hello\n"
using namespace std;

void DFS(int);
int n,m;
vector<int> adj[nax];
vector<int> dist;
vector<int> se;
vector<bool> visited;
vector<bool> visited1;
void add(int s,int e){
	adj[s].pb(e);
}

void dfs(){
	visited.resize(n+1,false);
	for(int i=1;i<=n;i++){
		if(visited[i] == false){
			visited[i] = true;
			DFS(i);
		}
	}
	
}

void DFS(int next){
	visited[next] = true;
	//s.push(next);
	for(auto it : adj[next]){
		if(visited[it] == false){
			DFS(it);
		}
	}
	se.push_back(next);
}
int help(int next){
	visited1[next] = true;
	//s.push(next);
	//deb(next);
	for(auto it : adj[next]){
		if(visited1[it] == false){
			//deb(it);
			int val = help(it);
			dist[next] = max(dist[next],val+1);
		}
		else{
			int val = dist[it]+1;
			dist[next] = max(dist[next],val);
		}
	}
	return dist[next];
}
int compute(){
	visited1.resize(n+1,false);
	dist.resize(n+1,0);
	for(auto it : se){
		//int count = 0;
		if(visited1[it] == false){
			//deb(it);
			visited1[it] = true;
			for(auto ip : adj[it]){
				//count++;
				if(visited1[ip] == false){
				//deb(it);
					int val = help(ip);
					dist[it] = max(dist[it],val+1);
				}
				else{
					int val = dist[ip]+1;
					dist[it] = max(dist[it],val);
				}						
			}
		}
	}
	int ans = *max_element(dist.begin(),dist.end());	
	return ans;
}

int main(){
	fast;
	cin>>n>>m;		
	for(int i=0;i<m;i++){
		int temp1,temp2;
		cin>>temp1>>temp2;
		add(temp1,temp2);
	}
	dfs();
	/*for(auto it : se){
		cout<<it<<" ";
	}*/
	reverse(se.begin(),se.end());
	int ans = compute();
	cout<<ans;
	return 0;
}


Measured memory_bytes: 11384
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
char s[MAXN], t[MAXN];
vector<int> idx[87];

int main() {
    scanf("%s", s + 1);
    scanf("%s", t + 1);
    int ns = strlen(s + 1);
    int nt = strlen(t + 1);
    for (int i = 1; i <= ns; i++) {
        int cur = s[i] - 'a';
        idx[cur].push_back(i);
    }
    int cur_idx = 0;
    LL ans = 0;
    for (int i = 1; i <= nt; i++) {
        int cur = t[i] - 'a';
        if (idx[cur].empty()) return !printf("-1\n");
        int tmp = upper_bound(idx[cur].begin(), idx[cur].end(), cur_idx) - idx[cur].begin();
        //printf("i = %d tmp = %d\n", i, tmp);
        if (tmp == (int)idx[cur].size()) {
           ans += (ns - cur_idx);
           cur_idx = idx[cur].front();
           ans += cur_idx;
        } else {
           ans += (idx[cur][tmp] - cur_idx);
           cur_idx = idx[cur][tmp];
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1148
#include <cstdio>
using namespace std;

int max(const int a, const int b) {
  if (a > b) return a;
  else return b;
}

int max3(const int a, const int b, const int c) {
  return max(max(a, b), max(b, c));
}


int min(const int a, const int b) {
  if (a > b) return b;
  else return a;
}

int min3(const int a, const int b, const int c) {
  return min(min(a, b), min(b, c));
}

int middle(const int x, const int y, const int z) {
  int r = min3(max(x,y), max(y,z), max(x,z));
  return r;
}

int main() {
  int a,b,c = 0;
  scanf("%d %d %d", &a, &b, &c);
  printf("%d %d %d\n", min3(a,b,c), middle(a,b,c), max3(a,b,c));
  return 0;
}


Measured memory_bytes: 2676
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
//#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define complex complex228
#define count count228
#define sin sin228
#define list list228


ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int a;
	cin >> a;
	string s;
	cin >> s;
	if (a < 3200) cout << "red\n";
	else cout << s << endl;
    return 0;
} // kek ;
// Ого! Кажетсья это $#@!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


Measured memory_bytes: 256
use proconio::input;

fn main() {
	input!(k: usize);
	input!(s: usize);

	let mut ans = 0;
	for x in 0..k+1 {
		for y in 0..k+1 {
			if x + y <= s && s - x - y <= k {
				ans += 1;
			}
		}
	}
	println!("{}", ans);
}



Measured memory_bytes: 2116
a, b = list(map(int, input().split(' ')))

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


print(a // gcd(a, b) * b)


Measured memory_bytes: 38384
#include <stdio.h>

int main (){
	
	int a,b,c;
	scanf ("%d %d %d", &a, &b, &c);
	if ( a == b && b == c || a!= b && b != c && a != c){
		printf ("No\n");
	}
	else if (a == b != c|| a != b == c || a == c != b){
		printf ("Yes\n");
	} 
	
	return 0;
}

Measured memory_bytes: 1660
"use strict";
    
var maxProfit = function(prices) {
    let profit = 0;
    for (let i = 0; i < prices.length - 1; i++) {
        const possibleProfit = prices[i + 1] - prices[i];
        //console.log("possible:" + possibleProfit)
        profit = Math.max(profit + possibleProfit, profit);
    }
    return profit;
};

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    let profit = 0;
    let money = 1000;
    
    let answer = 1000;
    
    for (let i = 0; i<N; i++) {
        const possibleProfit = A[i + 1] - A[i];
        profit = Math.max(profit + possibleProfit, profit);
        
        // console.log("possibleProfit:" + possibleProfit)
        
        if(possibleProfit > 0) {
            let cnt = Math.floor(money / A[i]);
            // console.log("cnt:" + cnt);
            
            answer += (possibleProfit * cnt);
            money = answer;
            // console.log("answer:" + answer)
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n,y;
    cin>>n>>y;
    y/=1000;
    
    rep(i,n+1){
        rep(j,n+1){
            int t = n-(i+j);
            if(t<0)continue;
            if(i*10+j*5+t==y){
                cout<<i<<" "<<j<<" "<<t<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


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

typedef long long ll;
typedef pair<double,int> P;

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

    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    int l=0,r=1000000000;
    while(r-l>1){
        int m=(l+r)/2;
        int cnt=0;
        for(int i=0; i<N; i++){
            cnt+=(A[i]/m)-1;
            if(A[i]%m!=0) cnt++;
        }
        if(cnt<=K) r=m;
        else l=m;
    }

    cout << r << endl;

    

    return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
int n,k,a[105][2],s;
long long f[105][100005];
int main(){
    cin >> n >> k;
    for(int i=1;i<=n;++i){
        cin >> a[i][0] >> a[i][1];
        s+=a[i][1];
    }
    for(int i=1;i<=s;++i){
        f[0][i]=1e10;
    }
    for(int i=1;i<=n;++i){
        for(int j=1;j<=s;++j){
            if (j>=a[i][1]){
                f[i][j]=min(f[i-1][j],f[i-1][j-a[i][1]]+a[i][0]);
            }
            else{
                f[i][j]=f[i-1][j];
            }
        }
    }
    for(int i=s;i>=0;--i){
        if(f[n][i]<=k&&f[n][i]!=0){
            cout << i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int digit(ll n){
  int dig=0;
  while(n>0){
    n/=10;
    dig++;
  }
  return dig;
}
int main(void){
  ll n;
  cin>>n;
  int ans=digit(n);
  for(ll i=1;i*i<=n;i++){
    if(n%i!=0){
      continue;
    }
    ll a=n/i;
    int m=max(digit(i),digit(a));
    if(ans>m){
      ans=m;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.split(" ").map(&:to_i) 
ary = n[0].times.map{gets.split.map(&:to_i)}
standard = n[1]
count = 0
ary.each do |a|
  a_zizyou = a[0]**2
  b_zizyou = a[1]**2
  sum = a_zizyou + b_zizyou
  distance = Math.sqrt(sum)
  if standard >= distance
    count += 1
  end
end  
print("#{count}\n")

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

#define rep(i,n)  for (int i = 0; i < (int)(n); i++)
#define INF 9999999999

using namespace std;
int main()
{
	string s,ans="hon";
	cin >>s;
	if (s[s.size()-1]=='0' || s[s.size()-1]=='1' || s[s.size()-1]=='6' || s[s.size()-1]=='8') ans="pon";
	if (s[s.size()-1]=='3') ans="bon";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3068
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var m = int.Parse(spl[1]);

        var hh = ToIntArray(input.ReadLine(), n);
        
        var blocks = new long[n];

        for(int i=0; i<m; i++) {
            spl = input.ReadLine().Split(' ');
            var a = int.Parse(spl[0]);
            var b = int.Parse(spl[1]);

            var ah = hh[a - 1];
            var bh = hh[b - 1];

            if(ah <= bh) {
                blocks[a - 1]++; 
            }
            if(ah >= bh) {
                blocks[b - 1]++;
            }
        }

        return blocks.Count(x => x == 0);
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 53192
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def tri_gcd(a,b,c):
  return gcd(gcd(a,b),c)

def main():
  K = int(input())
  S = 0
  # a = b = c
  S_0 = 0
  for a in range(1,K+1):
    S_0 = S_0 + tri_gcd(a,a,a)
  S = S_0
  # a = b > c   
  S_1 = 0
  for a in range(1,K+1):
      for c in range(a+1,K+1):
          S_1 = S_1 + tri_gcd(a,a,c)
  S += 6*S_1

  # a > b > c   
  S_3 = 0
  for a in range(1,K+1):
      for b in range(a+1,K+1):
        for c in range(b+1,K+1):
            S_3 = S_3 + tri_gcd(a,b,c)
  S += S_3 * 6
  
  print(S)

  return 0
 
if __name__ == "__main__":
  main()

Measured memory_bytes: 68528
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef long double ld;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll exp(ll x,ll y){if(y==0) return 1;if(y%2 == 1) return x*exp(x,y/2)*exp(x,y/2);return exp(x,y/2) * exp(x,y/2);}
ll exp(ll x,ll y,ll modd) {if(y==0) return 1;ll t=exp(x,y/2,modd);t = t%modd;t=t*t;t=t%modd;if(y % 2 == 1) return (x*t)%modd ;return t%modd;}
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target ("sse4")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0ll, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define revn(i,a,b) for(ll i=a;i>=b;--i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vs vector<string>
#define vsi vector<pair<string,int>>
#define vll vector<pair<ll,ll> >
#define vlll vector<pair<ll,pair<ll,ll>>>
#define vlvl vector<pair<pair<ll,ll>,ll>>>
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    int n;
	cin>>n;
	
	vector<int> swim(n+1), bug(n+1), homework(n+1);
	
	for(int i=0;i<n;i++)
	{
		cin>>swim[i]>>bug[i]>>homework[i];
	}
	
	vector<vector<int>> dp(n+1, vector<int>(3,0)); 
	
	int A=0, B=1, C=2;
	
	for(int i=1;i<=n;i++)
	{
		dp[i][A] = swim[i-1] +  max(dp[i-1][B], dp[i-1][C]);
		dp[i][B] = bug[i-1] +  max(dp[i-1][A], dp[i-1][C]);
		dp[i][C] = homework[i-1] +  max(dp[i-1][A], dp[i-1][B]);		
	}
	
	cout<<max(dp[n][A], max(dp[n][B], dp[n][C]));
	return 0;
}

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

int main() {
	int n;
  	cin>>n;
  
  	int p[55];
  	rep(i,n)cin>>p[i];
  
  	int cnt=0;//次に格納されている数が+1になってない回数
  
  for(int i=0;i<n;i++){
  	if(p[i]-i!=1){
    	cnt++;
    }
  }
  
  if(cnt==2||cnt==0){
  	cout<<"YES"<<endl;
  }
  
  else{
  	cout<<"NO"<<endl;
  }
    

}

Measured memory_bytes: 256
n = int(input())
t = ["AC", "WA", "TLE", "RE"]
cnt = [0] * 4
for _ in range(n):
    s = input()
    for i in range(4):
        if s == t[i]:
            cnt[i] += 1
            break
for i in range(4):
    print(t[i] + " x " + str(cnt[i]))

Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
vector<int> lps;
void lpsComp(vi pat) 
{ 
    int len = 0; 
  
    lps.resize(pat.size());
    lps[0] = 0; 
  
    int i = 1; 
    int matcher = -1;
    while (i < pat.size()) { 
        if(len == 0){
           //setting the offset here
           matcher = pat[len]^pat[i]; 
           lps[i] = ++len;
           i++;
        }else if (pat[i] == (pat[len] ^ matcher)) { 
            lps[i] = ++len;
            i++; 
        } 
        else // (pat[i] != pat[len]) 
        { 
            len = lps[len - 1]; 
        } 
    } 
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;cin >> n;
    vi a(n), b(n);
    FOR(i, n)cin >> a[i];
    FOR(i, n)cin >> b[i];
    lpsComp(a);
 //   debug("LPS");
  //  for(int x: lps)cout <<x << " " ;cout <<endl;
    //matching loop
    int pre = 0; //matching at pre th position
    vpii ans;
    int bLen = b.size();
    FOR(xx, 2){
        for(int i = 0; i < bLen - xx; i++){
            //    cout << pre <<endl;
//            cout << "Matching at " << pre << " with " << i << endl;
            if(a[pre] == (b[i]^(a[0]^b[(i - pre + bLen) % bLen]))){
                pre++;
            }else if(pre != 0){
                pre = lps[pre - 1];
                i--;
            }
            if(pre == a.size()){
                ans.pb(mp((n-1-i), a[0]^b[(i - (pre-1) + bLen) % bLen]));
                pre = lps[pre- 1];
            }

        }
    }
    sort(ans.begin(), ans.end());
    for(pii temp: ans)cout << temp.first  << " " << temp.second << endl;
}




Measured memory_bytes: 13792
from collections import defaultdict

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    town = defaultdict(int)
    cn = defaultdict(int)
    
    visited = set()
    visited.add(0)
    cnt = 0
    tmp = A[0]-1
    town[cnt] = 0
    ii = 0
    
    while True:
        if(tmp not in visited):
            visited.add(tmp)
            cnt += 1
            cn[tmp] = cnt
            town[cnt] = tmp
            tmp = A[tmp]-1
        else:
            ii = cn[tmp]
            break
    
    if(K >= len(town)):
        if(ii != 0):
            K -= ii
            ans = town[(K%(len(town)-ii))+ii]+1
        else:    
            ans = town[K%(len(town))]+1
        print(ans)
    else:
        ans = town[K]+1
        print(ans)
main()

Measured memory_bytes: 63984
def solve():
    H, W = tuple(map(int, input().split()))
    lines = []
    for _ in range(H):
        lines.append(tuple(input()))

    res = []
    for line in lines:
        res.append(line)
        res.append(line)

    return res


if __name__ == '__main__':
    res = solve()
    for line in res:
        print("".join(line))


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

using namespace std;

int main() {
    long a, b;
    cin >> a;
    string s;
    cin >> s;
    b = (s[0] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
    cout << (a * b) / 100 << endl;
}


Measured memory_bytes: 3612
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define step(n) rep(_, n)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define Unique(a) a.erase(unique(Range(a)), a.end())
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LONG_LONG_MAX)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr Type Square(Type x) { return x * x; }
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
void Print() { cout << endl; }
template <class Head, class... Tail> void Print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << ""; Print(forward<Tail>(tail)...); }
template <class T> void Print(vector<T> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class T> void Print(vector<vector<T>> &df) { for (auto& vec : df) { Print(vec); } }

int main()
{
    string S; cin >> S;
    map<string, string> mp;
    mp["ABC"] = "ARC";
    mp["ARC"] = "ABC";

    cout << mp[S] << endl;


    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
int main(){
  int n,m;
  long long ans=1;
  cin>>n>>m;
  if(abs(n-m)>1){
    cout << 0 << endl;
    return 0;
  }
  for(int i=1;i<=n;++i){
    ans*=i;
    ans%=MOD;
  }
  for(int i=1;i<=m;++i){
    ans*=i;
    ans%=MOD;
  }
  if(n==m)ans*=2;
  cout << ans%MOD << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline


def euler_tour(tree: list, root: int):
    """根をrootとしたときの辺に対するオイラーツアーを行う
    posの部分木が区間[begin[pos], end[pos])に対応する
    """
    n = len(tree)
    trail = []
    par = {root: -1}
    stack = [root]
 
    while stack:
        v = stack.pop()
        if v >= 0:  # 行きがけ順の処理
            trail.append(v)
            stack.append(~v)
            for nxt_v in tree[v]:
                if nxt_v not in par:
                    par[nxt_v] = v
                    stack.append(nxt_v)
 
        else:  # 帰りがけ順の処理
            if ~v == root:
                continue
            trail.append(-par[~v])
 
    return trail


n = int(input())
a = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(n - 1)]

tree = [[] for i in range(n)]
for u, v in info:
    u -= 1
    v -= 1
    tree[u].append(v)
    tree[v].append(u)

res = euler_tour(tree, 0)
array_ind = [0]
lis_array = [a[0]]
ans = [0] * n
ans[0] = 1

# (-1, -1): remove array
# (pos, val): change array
stack1 = []
stack2 = []
for ind in res[1:]:
    if ind > 0:
        val = a[ind]
        array_ind.append(ind)
        if val > lis_array[-1]:
            lis_array.append(val)
            stack1.append(-1)
            stack2.append(-1)
        else:
            pos = bisect_left(lis_array, val)
            stack1.append(pos)
            stack2.append(lis_array[pos])
            lis_array[pos] = val
        ans[ind] = len(lis_array)
    else:
        del array_ind[-1]
        pos = stack1.pop()
        val = stack2.pop()
        if pos == -1:
            del lis_array[-1]
        else:
            lis_array[pos] = val

for i in range(n):
    print(ans[i])

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

using namespace std;

using ll = long long;

constexpr ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif

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

    ll s,w;

    cin >> s >> w;

    if(s <= w){
        cout << "un";
    }
    cout << "safe\n";

    return 0;
}

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

int main(){
  int R;
  string ans;
  cin >> R;
  if(R<1200) ans = "ABC";
  else if(R<2800) ans = "ARC";
  else ans = "AGC";
  cout << ans << "\n";
  return 0;
}


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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  string n;
  cin >> n;
  rep(i,3){
    if(n[i] == '1')n[i] = '9';
    else n[i] = '1';
  }
  cout << n << endl;
}


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

using namespace std;

void saiki(vector<int> &v,int ind,int rest){
    if(ind >= v.size()){
        ind = 0;
    }
    rest -= (rest-1) % 5;
    cout << rest << endl;
    if(rest <= v[ind]){
        cout << 0 << endl;
        return;
    }
    rest -= v[ind];
    cout << rest << endl;

    ind++;
    saiki(v,ind,rest);
}
void solve(vector<int> nexts){
    saiki(nexts,0,32);
}

int main(){
    int n = 0;
    while(cin >> n && n!=0){
        vector<int> nexts;
        for(int i=0;i<n;i++){
            int x;
            cin >> x;
            nexts.push_back(x);
        }
        solve(nexts);
    }
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll a, b;

    cin >> a >> b;
    
    if (a >= 13)
        cout << b << endl;
    else if(a >= 6 && a < 13)
        cout << b/2 << endl;
    else if(a < 6)
        cout << 0 << endl;

    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	rep(i, N) cin >> a[i];

	int cnt = 0;
	for(int i = 0; i < N; i += 2) {
		if(a[i] % 2 == 1) cnt++;
	}

	cout << cnt << endl;

	return 0;
}

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


int main(){


    int n, i, j, t;


    cin >> n;


    vector<int> a(n + 1);

    vector<int> k(n + 1);


    vector<int> b;


    for( i = 1 ; i < n + 1 ; i = i + 1 ){

         cin >> a.at(i);

         }


    for( i = n ; 0 < i ; i = i - 1 ){

         t = 0;

         for( j = 2 * i ; j < n + 1 ; j = j + i ){

              if( k.at(j) == 1 ) t += 1;

              }

         if( ( t % 2 ) != a.at(i) ) k.at(i) += 1;

         }


    for( i = 1 ; i < n + 1 ; i = i + 1 ){

         if( k.at(i) == 1 ) b.push_back(i);  

         }

    
    cout << b.size() << endl;


    for( i = 0 ; i < b.size() ; i = i + 1 ){

         cout << b.at(i);

         if( i < b.size() - 1 ) cout << " ";

         else cout << endl;

         }

    
    return 0;


    }

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 10

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

#define TABLE_SIZE 8
#define min(a,b) ((a) > (b) ? (b) : (a))

struct point2d {
    int x;
    int y;
};

static char checked[TABLE_SIZE][TABLE_SIZE] = {{0}};
void update_checked(int row, int col, int size) {
    int i;
    // fill
    for(i = 0; i < TABLE_SIZE; i++) {
        checked[row][i] = 1;
        checked[i][col] = 1;
    }
    int sum = row+col;

    // "/"
    for(i = 0; i <= min(TABLE_SIZE-1, sum); i++) {
        if(sum - i >= TABLE_SIZE) continue;
        checked[i][sum-i] = checked[sum-i][i] = 1;
    }
    // "\"
    for(i = 0; i < TABLE_SIZE; i++) {
        if(row+i < TABLE_SIZE && col+i < TABLE_SIZE) {
            checked[row+i][col+i] = 1;
        }
        if(row-i >= 0 && col-i >= 0) {
            checked[row-i][col-i] = 1;
        }
    }
    checked[row][col] = 0;
    return;
}

char used[100];
int p[100];
void perm(int *arr, int pos, int size, int* in, int* ans) {
    int i;
    if(pos == size) {
        memset(checked, 0, TABLE_SIZE*TABLE_SIZE);
        int flag = 1;
        for(i = 0; i < size; i++) {
            int col = arr[p[i]];
            if(in[i] != -1 && in[i] != col) { flag = 0; break; }
            if(checked[i][col]) {
                flag = 0;
                break;
            }
            update_checked(i, col, size);
        }
        if(flag) {
            for(i = 0; i < size; i++) {
                ans[i] = arr[p[i]];
            }
        }
        return;
    }

    for(i = 0; i < size; i++) {
        if(used[i]) continue;
        used[i] = 1;
        p[pos] = i;
        perm(arr, pos+1, size, in, ans);
        used[i] = 0;
    }
    return;
}

int main(void) {
    int num = get_int();
    int dep[TABLE_SIZE];
    int i, j;
    for(i = 0; i < TABLE_SIZE; i++) dep[i] = -1;
    for(i = 0; i < num; i++) {
        int row, col;
        get_int2(&row, &col);
        dep[row] = col;
    }

    int col_idx[TABLE_SIZE] = {0,1,2,3,4,5,6,7};
    int ans[8] = {0}; // ans[col_idx] = row_idx;
    // find ans;
    perm(col_idx, 0, TABLE_SIZE, dep, ans);
    for(i = 0; i < TABLE_SIZE; i++) {
        int col = ans[i];
        for(j = 0; j < TABLE_SIZE; j++) {
            putchar(j == col ? 'Q' : '.');
        }
        putchar('\n');
    }

    return 0;
}


Measured memory_bytes: 2148
#include "bits/stdc++.h"
using namespace std;
#define ALL(x)x.begin(),x.end()
bitset<100100> poss;
int main() {
	poss[0] = 1;
	for (int i = 0; i <= 100000; ++i) {
		if (!poss[i]) continue;
		poss[i + 100] = 1;
		poss[i + 101] = 1;
		poss[i + 102] = 1;
		poss[i + 103] = 1;
		poss[i + 104] = 1;
		poss[i + 105] = 1;
	}
	int N;
	scanf("%d", &N);
	printf("%d\n", (int) poss[N]);
}


Measured memory_bytes: 256
// Created on: 22-Aug-2020 18:07:37 //

#include <bits/stdc++.h>
using namespace std;

int main() {
    char c;
    int s = 0;
    while (cin >> c) {
        s += (c - '0');
        s %= 9;
    }
    if (s % 9)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
vector<LL> make_divisors(LL n){vector<LL> divisors;for(int i = 1; i <= sqrt(n); i++) {if(n%i == 0){divisors.push_back(i);if(i != n/i){divisors.push_back(n / i);}}}return divisors;}
const LL MOD = 1e9 + 7;
const int INF = 1 << 30;
const LL LLINF = 1LL << 60;
using namespace std;

const LL MAX_V = 1010;
const LL MAX_E = 2010;

//辺の構造体
struct edge {
    LL before_node;
    LL next_node;
    LL cost;
};

LL V, E;//V = 頂点の数, E = 辺の数
vector<LL> dp(MAX_V,LLINF);
vector<edge> edges(MAX_E);//ノードではなく辺に着目

bool bellman_ford(LL start){
    dp[start] = 0;

    for(int v = 0; v < V; v++) {       
        for (int i = 0; i < E; i++) {
            edge e = edges[i];
            if(dp[e.before_node] != LLINF and dp[e.next_node] > dp[e.before_node] + e.cost){
                dp[e.next_node] =  dp[e.before_node] + e.cost;
                if(v == V - 1) return true;
            }
        }
    }

    return false;
}

int main(void){
    cin >> V >> E;
    rep(i, E) {
        LL a, b, c;
        cin >> a >> b >> c;
        a--;b--;

        edges[i] = {a, b, -c};
    }

    bellman_ford(0);

    LL ans = dp[V - 1];

    vector<bool> negative(MAX_V, false);

    for (int v = 0; v < V; v++)
    {
        for (int i = 0; i < E; i++)
        {
            edge e = edges[i];

            if(dp[e.before_node] == LLINF) continue;

            if(dp[e.next_node] > dp[e.before_node] + e.cost){
                dp[e.next_node] = dp[e.before_node] + e.cost;
                negative[e.next_node] = true;
            }

            if(negative[e.before_node]){
                negative[e.next_node] = true;
            }
        }
    }

    if(negative[V - 1]){
        cout << "inf" << endl;
    }else{
        cout << -ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	if (s == "RRR")cout << 3;
	else if (s == "RRS" || s == "SRR")cout << 2;
	else if (s == "SSS")cout << 0;
	else cout << 1;
	return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  vector<int64> a(N);
  cin >> a;
  for (int i = 0; i < N; i++) {
    if (a[i] % 2 == 1) {
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
  return 0;
}

Measured memory_bytes: 4052
#include<stdio.h>

int main()
{

 int H,W,i,j; 
   while(1){
	scanf("%d %d", &H, &W);
        if (H==0&&W==0){
          break;
        }
	for(i=0; i<H; i++){
		for(j=0; j<W; j++){
			
		printf("#");
	}
	printf("\n");
	}
	printf("\n");
}
return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ll long long
using namespace std;

const int N = 1e5 + 5;
int n,m,arr[N];
vector<int>adj[N];
int vis[N];
vector<int>pos;
vector<int>val;

void dfs(int now){
	vis[now] = 1;
	pos.pb(now);
	val.pb(arr[now]);
	for(int next : adj[now]){
		if(vis[next] == 0){
			dfs(next);
		}
	}
}

int main()
{
	cin.sync_with_stdio(0);		cin.tie(0);		cout.tie(0);

	cin >> n >> m;
	for(int x = 1; x <= n ; x++){
		cin >> arr[x];
	}
	for(int x = 1; x <= m ; x++){
		int a, b; cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	memset(vis, 0, sizeof vis);

	int ans = 0;
	for(int x = 1; x <= n ; x++){
		if(vis[x] == 0){
			pos.clear();
			val.clear();
			dfs(x);

			int p = val.size();
			for(int x = 0 ; x < p ; x++){
				if(vis[val[x]] == 1){
					ans++;
				}
			}
			for(int x = 0 ; x < p ; x++){
				vis[pos[x]] = 2;
			}
		}
	}
	printf("%d\n",ans);
}	

Measured memory_bytes: 10412
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
h = list(li())

ans = 0
tmp = 0
nex = h[-1]

for hi in h[-2::-1]:
    if hi >= nex:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0

    nex = hi

print(max(ans, tmp))

Measured memory_bytes: 14172
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,m;
const int Maxn=1e5+5;
vector<int>G[Maxn];
int memo[Maxn];
void f(int i){
	if(memo[i]!=-1)return;
	memo[i]=0;
	rep(j,SZ(G[i])){
		int to=G[i][j];
		f(to);
		chkmax(memo[i],memo[to]+1);
	}
}
int main(){
	n=in();m=in();
	rep(i,m){
		int u,v;
		u=in();v=in();
		u--;v--;
		G[u].push_back(v);
	}
	memset(memo,-1,sizeof(memo));
	rep(i,n)f(i);
	cout<<*max_element(memo,memo+n)<<endl;
	return 0;
}

Measured memory_bytes: 8832