akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);

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

    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
//const ll MOD = 1000000007ll;
const ll MOD = 998244353ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう

int main(){
    ll n;
    std::cin >> n;
    rrep(i,1,3501){
        rrep(j,1,3501){
            //if((i*n+j*n-4*i*j)!=0&&(n*i*j)%(i*n+j*n-4*i*j)==0){
            if((4*i*j-i*n-j*n)>0&&(n*i*j)%(4*i*j-i*n-j*n)==0){
                pppri((n*i*j)/(4*i*j-i*n-j*n),i,j);
                exit(0);
            }
        }
    }
}


Measured memory_bytes: 256
n = int(input())
d = [0] * 100000
dat = list(map(int, input().split()))
for i in range(n):
    d[dat[i]] += 1
res = 1
for i in range(1, n - 1):
    res = max(res, d[i-1] + d[i] + d[i+1])
print(res)

Measured memory_bytes: 53676
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,x;
  cin >> n >> x;
  vi l(n+2,0);
  REP(i,n) cin >> l[i+1];
  int d = 0;
  int ans = 0;
  while(ans<n+2&&d<=x){
    d += l[ans++];
  }
  cout << ans-1 << endl;
}



Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{ 
    public static class Graph{ 
        private int V;   // No. of vertices 
        private LinkedList<Integer> adj[]; // Array  of lists for Adjacency List Representation  
        public Graph(int v){ 
            V = v; 
            adj = new LinkedList[v+1]; 
            for (int i=0; i<=v; ++i) adj[i] = new LinkedList(); 
        } 
        //Function to add an edge into the graph 
        public void addEdge(int v, int w) { 
            adj[v].add(w);  // Add w to v's list. 
            adj[w].add(v);
        } 

        public int[] BFS(int s){ 
            // Mark all the vertices as not visited
            boolean visited[] = new boolean[V+1];
            int[] parent=new int[V+1];
            // Create a queue for BFS 
            LinkedList<Integer> queue = new LinkedList<Integer>(); 
            // Mark the current node as visited and enqueue it 
            visited[s]=true; 
            parent[s]=-1;
            queue.add(s); 
            while (queue.size() != 0){ 
                // Dequeue a vertex from queue and print it 
                s = queue.poll(); 
                // Get all adjacent vertices of the dequeued vertex s 
                // If a adjacent has not been visited, then mark it 
                // visited and enqueue it 
                Iterator<Integer> i = adj[s].listIterator(); 
                while (i.hasNext()){ 
                    int n = i.next(); 
                    if (!visited[n]){ 
                        visited[n] = true; 
                        parent[n]=s;
                        queue.add(n); 
                    } 
                } 
            }
            return parent;
        } 
    }
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringBuffer sb=new StringBuffer();
        String[] str=br.readLine().split(" ");
        int n=Integer.parseInt(str[0]);
        int m=Integer.parseInt(str[1]);
        Graph g=new Graph(n);
        for(int i=0;i<m;i++){
            str=br.readLine().split(" ");
            int a=Integer.parseInt(str[0]);
            int b=Integer.parseInt(str[1]);
            g.addEdge(a,b);
        }
        int[] p=g.BFS(1);
        for(int i=2;i<=n;i++){
            if(p[i]==0){
                System.out.println("No");
                return;
            }
            else sb.append(p[i]+"\n");
        }
        System.out.print("Yes\n"+sb);
    }
}


Measured memory_bytes: 77052
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  a.erase(unique(a.begin(),a.end()),a.end());
  for(Int j=0;j<(int)a.size();j++){
    if(j) cout<<" ";
    cout<<a[j];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD 1000000007;
#define INV_10 299473306;
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	long long x, k;
	cin >> x >> k;
	x%=k;
	cout << min(x, k-x) << '\n';
}

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

int main() {
	string s;
	int k;
	cin >> k >> s;
	int n = s.length();
	if (n <= k) {
		cout << s << endl;
	}
	else {
		string ans = s.substr(0, k) + (string)"...";
		cout << ans << endl;
	}
	return 0;
}

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

////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define len(x) ((int)(x).size())
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod (ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

////////////////////////// Solution starts below. //////////////////////////////

const int N = 3010;

int n;
ll dp[N][N];
ll a[N];
ll sum;

ll solve (int l, int r) {
	if (r < l) return 0;
	ll &ret = dp[l][r];
	if (ret != -1) return ret;
	return ret = max (min (solve (l+2, r), solve (l+1, r-1)) + a[l],
					min (solve (l+1, r-1), solve (l, r-2)) + a[r]);
}

int main () {
	memset (dp, -1, sizeof dp);
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &a[i]);
		sum += a[i];
	}
	
	ll x = solve (1, n);
	ll y = sum - x;
	printf ("%lld\n", x - y);

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll N;
vector<ll> G[100100];
ll C[100100];
bool isvisit[100100];
vector<pair<ll, ll> > E;
map<pair<ll, ll>, ll> ANS;
ll color;

void dfs(int v, int c, int pv, int p){
    isvisit[v] = true;
    ANS[make_pair(v, pv)] = c;
    ANS[make_pair(pv, v)] = c;
    ll idx = 1;
    for(auto&& n : G[v]){
        if(isvisit[n]) continue;
        if(idx == c) idx++;
        chmax(color, idx);
        dfs(n, idx, v, c);
        idx++;
    }
}

int main(){
    cin >> N;
    REP(i,N-1){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
        E.emplace_back(a, b);
    }

    dfs(0, -1, -1, -1);

    cout << color << endl;
    REP(i,N-1){
        auto p = E[i];
        cout << ANS[p] << endl;
    }

    return 0;
}


Measured memory_bytes: 20720
#include <queue>
#include <utility>
#include <vector>
#include <unordered_map>
#include <map>
// #include <fstream>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
const long long mod = 1000000007;


int main() {
     cin.tie(0);
    ios_base::sync_with_stdio(false);
    char c;
    cin >> c;
    c++;
    cout << c;
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long, long>;
using pdd = pair<ld, ld>;

template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<ll>;
V(size_t) -> V<ll>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

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 (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    string S;
    cin >> S;
    ll K;
    cin >> K;
    ll N = S.size();

    ll idx = 0;
    while(idx<N and S[idx]=='1'){
        idx++;
    }

    if(idx>=K and idx != 0){
        cout << 1 << endl;
    }else{
        cout << S[idx] << endl;
    }

    return 0;
}

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

struct UnionFind {
  vector<long long int> par;
  
  UnionFind(long long int N) {
    par = vector<long long int>(N, (long long int)-1);
  }
  
  long long int root(long long int x) {
    if (par.at(x) < 0) return x;
    return par.at(x) = root(par.at(x));
  }
  
  bool unite(long long int x, long long int y) {
    long long int rx = root(x);
    long long int ry = root(y);
    if (rx == ry) return false;
    if (par.at(rx) > par.at(ry)) swap(rx, ry);
    par.at(rx) += par.at(ry);
    par.at(ry) = rx;
    return true;
  }
  
  bool same(long long int x, long long int y) {
    long long int rx = root(x);
    long long int ry = root(y);
    return rx == ry;
  }
  
  int size(int x) {
    return -par.at(root(x));
  }
};

int main() {
  long long int N, M;
  cin >> N >> M;
  vector<long long int> A(M), B(M), ans(M, N * (N - 1) / 2);
  for (long long int i = 0; i < M; i++) {
    cin >> A.at(i) >> B.at(i);
    A.at(i)--;
    B.at(i)--;
  }
  UnionFind tree(N);
  for (long long int i = M - 1; i >= 0; i--) {
    if (i > 0 && !(tree.same(A.at(i), B.at(i)))) {
      ans.at(i - 1) = ans.at(i) - tree.size(A.at(i)) * tree.size(B.at(i));
    }
    else if (i > 0) ans.at(i - 1) = ans.at(i);
    tree.unite(A.at(i), B.at(i));
  }
  for (long long int i = 0; i < M; i++) cout << ans.at(i) << endl;
}

Measured memory_bytes: 6316
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         String S=gs();
         int Q=gi();
         int[] T=new int[Q];
         int[] F=new int[Q];
         String[] C=new String[Q];

         for (int i=0; i<Q;i++) {
        	 T[i]=gi();
        	 if(T[i]==2) {
        		 F[i]=gi();
        		 C[i]=gs();
        	 }
         }
         
         StringBuilder sb= new StringBuilder(S);
         boolean rev=false;
         for (int i=0; i<Q;i++) {
        	 if(T[i]==1) {
        		 rev=!rev;
        	 } else {
        		 if((rev==false && F[i]==1) || rev==true && F[i]==2) {
        			 sb.insert(0,C[i]);
        		 } else {
        			 sb.append(C[i]);
        		 }
        	 }
         }
         StringBuffer sbf=new StringBuffer(sb);
         if(rev)sbf.reverse();

         System.out.println(sbf.toString());
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 73952
#include <iostream>
#include <vector>
#include <unordered_map> 
#include <map>
#include <algorithm>
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  if(N == M)cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 
int a,b,c[100010],d[100010],e;
   cin >> a >>b;
 
 for(int i=0;i<b;i++){
    cin >> c[i] >> d[i];
 }
   
  sort(c,c+b,greater<int>());
  sort(d,d+b);
  if(d[0] >= c[0]){
  cout << d[0]-c[0]+1 << endl;
    
    
  }
  else{
    
    cout << "0" << endl;
    
    
  }
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World" << "\n";
        return 0;
    }
    else{
        int a,b;
        cin >> a >> b;
        cout << a+b << "\n";
        return 0;
    }
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a-b&&b-c&&c-a)cout<<"No";
    else if(a==b&&b==c)cout<<"No";
    else cout<<"Yes";
	return 0;
}


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

int main()
{
    int n;
    cin>>n;
    vector<int >v(n);
    for(int i=0;i<v.size();i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=1;i<v.size();i++)
    {
        if(v[i]==v[i-1])
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
import queue

NINF = -1000000000

def reachable(n, vtxs):
    visited = [0 for i in range(n)]
    visited[0] = 1

    qu = queue.Queue()
    qu.put(0)
    while(not qu.empty()):
        curr = qu.get()
        for next in vtxs[curr]:
            if visited[next] == 0:
                visited[next] = 1
                qu.put(next)

    return visited

def reachable_rev(n, revs):
    visited = [0 for i in range(n)]
    visited[n-1] = 1
    qu = queue.Queue()
    qu.put(n - 1)
    while(not qu.empty()):
        curr = qu.get()
        for next in revs[curr]:
            if visited[next] == 0:
                visited[next] = 1
                qu.put(next)

    return visited



def bellman(n, m, edges, vtxs, revs):
    cost = [NINF for i in range(n)]
    cost[0] = 0
    tgts = [0]
    loop = 0
    final = False
    reach = reachable(n, vtxs)
    revreach = reachable_rev(n, revs)
    while(True):
        flag = False
        if loop > n:
            final = True
            break
        for e in edges:
            # print(e, cost)
            if cost[e[1]] < cost[e[0]] + e[2]:
                point = e[1]
                ppoint = e[0]
                # print("point", point)
                if reach[point] and revreach[point]:
                    if reach[ppoint] and revreach[ppoint]:
                        cost[e[1]] = cost[e[0]] + e[2]
                        flag = True
                        # print("update")
        if not flag:
            break
        loop += 1
        # print("loop", loop, cost)


    # print("judge", reach, revreach)
    if final:
        for e in edges:
            # print(e, cost)
            if cost[e[1]] < cost[e[0]] + e[2]:
                point = e[1]
                ppoint = e[0]
                # print("point", point)
                if reach[point] and revreach[point]:
                    if reach[ppoint] and revreach[ppoint]:
                        return -1

    if reach[-1] == 0:
        return -1

    return max(0, cost[-1])

n, m , p= getList()
vtxs = [[] for i in range(n)]
revs = [[] for i in range(n)]
edges = []

for i in range(m):
    a, b, c = getList()
    vtxs[a-1].append(b-1)
    revs[b-1].append(a-1)
    edges.append((a-1, b-1, c - p))

# print(edges)
print(bellman(n, m, edges, vtxs, revs))



Measured memory_bytes: 56552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

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

int main() {
    ll n; cin >> n;
    ll res;
    rep(i, n) {
        ll t; cin >> t;
        if (i) res = lcm(res, t);
        else res = t;
    }
    cout << res << endl;
}

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

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(c-a) <=d || (abs(c-b) <=d && abs(b-a) <= d)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 110000
#define LL long long
using namespace std;
struct node{int y,nex,o;}a[2*N];
int n,m,len,fir[N],c[N];
LL ans,d[5],cnt,tmp;
bool v[N],bo;
void ins(int x,int y)
{
	a[++len].y=y;a[len].o=1;a[len].nex=fir[x];fir[x]=len;
	a[++len].y=x;a[len].o=-1;a[len].nex=fir[y];fir[y]=len;
}
void dfs(int x)
{
	cnt++;
	v[x]=1;
	d[c[x]]++;
	for(int k=fir[x];k;k=a[k].nex)
	{
		tmp++;
		int y=a[k].y,t=(c[x]+a[k].o+3)%3;
		if(v[y]) {if(c[y]!=t) bo=1;}
		else {c[y]=t;dfs(y);}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		ins(x,y);
	}
	for(int i=1;i<=n;i++)
	{
		if(v[i]) continue;
		bo=d[0]=d[1]=d[2]=cnt=tmp=0;
		dfs(i);
		if(bo==0)
		{
			if(d[0]*d[1]*d[2]==0) ans+=tmp/2;
			else ans+=d[0]*d[1]+d[1]*d[2]+d[2]*d[0];
		}
		else ans+=cnt*cnt;
	}
	printf("%lld\n",ans);
	return 0;
}

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

const int MAXN = 1e5 + 10;

vector<int> grafo[MAXN];
int dp[MAXN],vis[MAXN],N,M;

int solve(int v){

	if(vis[v]) return dp[v];

	vis[v] = 1;
	int best = 0;

	for(int u : grafo[v]){
		best = max(best, solve(u) + 1 );
	}

	return dp[v] = best;

}

int main(){

	scanf("%d %d",&N,&M);
	for(int i = 1;i<=M;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		grafo[u].push_back(v);
	}

	int best = 0;
	for(int i = 1;i<=N;i++) best = max(best, solve(i) );
	printf("%d\n",best);

	return 0;

}

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

using namespace std;

int main() {
    int n;
    while(cin>>n, n) {
        int loop = n / 4;
        int cnt = 0;
        for (int i = 0; i < loop; ++i) {
            int tmp;
            cin>>tmp;
            cnt += tmp;
        }
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 2976
/*
Web:AtCoder
User:sunyx
Prob:A-Subscribers
Method:小学Math 
*/
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int main() {
	cin>>n>>a>>b;
	cout<<min(a,b)<<' ';
	int p=a+b;
	if (p<=n) cout<<0;
	else cout<<p-n;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main () {
    // input
    int a, b, C;
    cin >> a >> b >> C;

    // solve
    // caution! cos, sin takes radian
    double rad;
    double PI = acos(-1);
    rad = (C * PI) / 180;

    long double S, L, h;
    S = ( a * b * sin(rad) ) / 2;
    L = a + b + sqrt( pow(a, 2) + pow(b, 2) - 2 * a * b * cos(rad) );
    h = b * sin(rad);

    // output
    cout << fixed;
    cout << setprecision(6) << S << endl
         << setprecision(6) << L << endl
         << setprecision(6) << h << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
Int mod = 1e9+7;

vector<pair<Int, Int>> G[100001];
Int color[100001];

void dfs(Int x) {
    // if (color[x] >= 0) return;
    for (Int i = 0; i < (Int)G[x].size(); i++) {
        pair<Int, Int> p = G[x][i];
        if (color[p.first] < 0) {
            if (p.second % 2 == 0) {
                color[p.first] = color[x];
                dfs(p.first);
            }
            else {
                color[p.first] = (color[x] + 1) % 2;
                dfs(p.first);
            }
        }
    }
}

int main() {
    Int n;
    cin >> n;
    for (Int i = 0; i < n - 1; i++) {
        Int u, v, w;
        cin >> u >> v >> w;
        G[u].emplace_back(v, w);
        G[v].emplace_back(u, w);
    }
    for (Int i = 1; i <= n; i++) color[i] = -1;
    color[1] = 0;
    dfs(1);
    for (Int i = 1; i <= n; i++) dump(color[i]);
    return 0;
}

Measured memory_bytes: 10240
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

//        int n = 9;
        int[] arr = new int[9];
        for (int i=0; i<9; i++) arr[i] = sc.nextInt();

        int n = sc.nextInt();

        int[] bingo = new int[9];

        for (int i=0; i<n; i++){
            int b = sc.nextInt();
            for (int j=0; j<9; j++){
                if (arr[j]==b) {
                    bingo[j] = 1;
                }
            }
        }

        if (bingo[0]==1 && bingo[3]==1 && bingo[6]==1){
            System.out.println("Yes");
            return;
        }else if (bingo[1]==1 && bingo[4]==1 && bingo[7]==1){
            System.out.println("Yes");
            return;
        }else if (bingo[2]==1 && bingo[5]==1 && bingo[8]==1){
            System.out.println("Yes");
            return;
        }else if (bingo[0]==1 && bingo[1]==1 && bingo[2]==1){
            System.out.println("Yes");
            return;
        }else if (bingo[3]==1 && bingo[4]==1 && bingo[5]==1){
            System.out.println("Yes");
            return;
        }else if (bingo[6]==1 && bingo[7]==1 && bingo[8]==1){
            System.out.println("Yes");
            return;
        }else if (bingo[0]==1 && bingo[4]==1 && bingo[8]==1){
            System.out.println("Yes");
            return;
        }else if (bingo[2]==1 && bingo[4]==1 && bingo[6]==1){
            System.out.println("Yes");
            return;
        }



        System.out.println("No");

    }
}


Measured memory_bytes: 22996
N = int(input()) + 1

Answer = 0

def getGCD(a,b,c):
    if a == b == c:
        d = 1
    elif a == b or b == c:
        d = 3
    else:
        d = 6
        
    surplus = a % c
    while surplus != 0:
        a,c = c,surplus
        surplus = a % c
    surplus = b % c
    while surplus != 0:
        b,c = c,surplus
        surplus = b % c
    return c * d


for i in range(1,N):
    for j in range(i,N):
        for k in range(j,N):
            Answer += getGCD(k,j,i)
            
print(Answer)


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

int main(){
    int n;
    scanf("%d",&n);
    int a[200000];
    int result[200000];
    for(int i = 0;i < 200000;i++){
        result[i] = 0;
    }
    for(int i = 1;i < n;i++){
        scanf("%d",&a[i]);
    }

    for(int i = 1;i < n;i++){
        result[a[i] - 1]++;
    }

    for(int i = 0;i < n;i++){
        printf("%d\n",result[i]);
    }
    return 0;
}


Measured memory_bytes: 3296
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

int check(int n) {
  string s = to_string(n);
  char c = s[0];
  for (auto &i : s) if (i != c) return 0;
  return 1;
}

void MAIN() {
  int n; cin >> n;
  while (!check(n)) n++;
  cout << n << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>

using namespace std;

void showArray(int a[], int n) {
    for (int i=0; i<n; i++) {
        cout << a[i] << ' ';
    } cout << endl;
}

void op(int &A, int &B) {
    if (A % 2 == 1) {
            A--;
        }
        A /= 2;
        B += A;
}

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    for (int i=0; i<K; i++) {
        if (i%2 == 0) {
            op(A, B);
        } else {
            op(B, A);
        }
    }
    cout << A << " " << B << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string sa, sb;
	cin >> sa >> sb;

	string s = sa + sb;
	int n = stoi(s);
	int a = (int)sqrt((double)n);
	if (a * a == n) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a,b,c;

main() {
    cin >> a >> b >> c;
    ct(min(min(a+b,a+c),b+c))
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;

int N, K;
int A[100010];

template<class T>
T gcd(const T a, const T b, T* const px = NULL, T* const py = NULL){
	if(py == NULL){
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	T d = a;
	if(b != 0){
		d = gcd(b, a % b, py, px);
		*py -= (a / b) * *px;
	}else{
		*px = 1; *py = 0;
	}
	return d;
}

int main(void){
	cin >> N >> K;
	for(int i = 0; i < N; i++) cin >> A[i];

	int a = A[0];
	for(int i = 1; i < N; i++){
		a = gcd(a, A[i]);
	}

	// debug(a);

	if(*max_element(A, A+N) >= K and K%a == 0) cout << "POSSIBLE" << '\n';
	else cout << "IMPOSSIBLE" << '\n';

	return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		int[] t = new int[n];
		for(int i=0; i<n; i++) {
			t[i] = sc.nextInt(); x[i] = sc.nextInt(); y[i] = sc.nextInt();
		}
		int nowx = 0; int nowy = 0; int nowt = 0;
		for(int i=0; i<n; i++) {
			int d = Math.abs(nowx-x[i])+Math.abs(nowy-y[i]);
			int dt = t[i]-nowt;
			if(d<=dt && (d-dt)%2==0) {
				nowx = x[i]; nowy = y[i]; nowt = t[i];
			} else {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
	
	static int binarySearch(int[] A, int x) {
		int l = 0;
		int r = A.length;
		while(l<r) {
			int mid = (l+r)/2;
			if(A[mid] == x) return mid;
			else if(x<A[mid]) r = mid;
			else l = mid+1;
		}
		return -1;
	}
	
	static long upper_bound(int[] A, int b) {
		// bよりおおきい値がはじめて出てくるindexを返す
		return lower_bound(A, b+1);
	}

	static long lower_bound(int[] A, int b) {
		// b以上の値がはじめて出てくるindexを返す
		int lb=0;
		int ub=A.length;
		while(ub>lb) {
			int mid = (lb+ub)/2;
			if(A[mid]>=b) ub = mid;
			else lb = mid+1;
		}
		return lb;
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}


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

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define pi pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define vl vector<ll>
#define vii vector<pair<int,int> >
#define vll vector<pair<long long,long long> >
#define pb push_back
#define mp make_pair3

const ll mod=1e9+7;
#define MAX 100000

int modulo = 420047;

ll binexpo(ll a,ll b,ll c){

    if(b==0) return 1;
    else if(b%2==0) return binexpo(((a%c)*(a%c))%c,b/2,c)%c;
    else return ((a%c)*(binexpo(((a%c)*(a%c))%c,b/2,c)%c))%c;
}

ll inf = (ll)1e12;

int main(){

    int n,w;
    cin>>n>>w;

    ll wt[n],val[n];
    int sum = 0;
    FOR(i,0,n){
        cin>>wt[i]>>val[i];
        sum+= val[i];
    }

    ll dp[n+1][sum+1];
    FOR(i,0,n+1){
        FOR(j,0,sum+1){
            dp[i][j] = (ll)(1e12);
        }
        dp[i][0] = 0;
    }

    FOR(i,1,n+1){
        FOR(j,1,sum+1){
            dp[i][j] = dp[i-1][j];
            if(j>=val[i-1]){
                dp[i][j] = min(dp[i][j],dp[i-1][j-val[i-1]] + wt[i-1]);
            }
        }
    }

    ll ans = 0;
    for(int j = sum;j>=0;j--){
        if(dp[n][j] <= w){
            ans = j;
            break;
        }
    }

    cout<<ans;
    return 0;
}

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

ll i;
ll num;
ll ans;
//float
ll A,B,N;	
string S,T;

int main()
{
	cin>>S;
	if(S[5]=='0'&&S[6]<='4') cout<<"Heisei"<<endl;
	else cout<<"TBD"<<endl;
	
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#define sz(x) ((int)(x).size())
#define mp make_pair
#define full(a) a.begin(), a.end()
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 1e5;

void solve()
{
    string s; cin >> s;
    if (s.back() == 's') s += "es";
    else s += "s";
    cout << s;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); //cout.tie(NULL);
    /*int tc; cin >> tc;
    while (tc--)*/
        solve();

    return 0;
}


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

int main(){
    int d,n;
    cin >> d >> n;
    if(d==0){
        if(n==100)
        cout << 101 << endl;
        else
        cout << n << endl;
    }
    else if(d==1){
        if(n==100)
        cout << 10100 << endl;
        else
        cout << 100*n << endl;
    }
    else if(d==2){
        if(n==100)
        cout << 1010000 << endl;
        else
        cout << 10000*n << endl;
    }
}

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

using namespace std;


int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (i == 4) cout << " ";
        cout << s[i];
    }
    cout << endl;
    return 0;
}

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

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

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

    vector<int> dp(N + 1, 0);

    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i + A[i] <= N)
            dp[i + A[i]]++;
        int j = i + 1;
        if (j - A[j] >= 1 && j - A[j] <= N)
            ans += dp[j - A[j]];
    }

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

Measured memory_bytes: 4784
# 一番左はX
# X,2X,4X,8X...とつづく
# a0=X,a1=2**1*X,a2=2**2*X...ai=2**i*X
# ai<=Yをみたす最大のiがしりたい
# 答えはi+1?
x,y=map(int,input().split())
for i in range(100):
  if pow(2,i)*x>y:
    break
print(i)

Measured memory_bytes: 9076
#include "bits/stdc++.h"

using namespace std;

using i64 = long long;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


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

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


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;
    vector<string> a(n);
    int ans = 0;
    for(auto &x : a){
        cin >> x;
        if(x == "E869120")
            ++ans;
    }
    cout << ans << endl;
}




Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  string S;
  bool a=false, b=false, c=false;
  cin >> S;
  for(int i=0; i<3; i++) {
    if(S.at(i)=='a') {
      a=true;
    }
    if(S.at(i)=='b') {
      b=true;
    }
    if(S.at(i)=='c') {
      c=true;
    }
  }
  if(a==true&&b==true&&c==true) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define YOU setprecision
using namespace std;
int i[11111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e,f;
  string s;
  cin >>a>>b>>c;
  if(b/a>c) cout <<c<<'\n';
  else cout <<b/a<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string A;
  cin >> A;
  if ("a" <= A && A <= "z")
    cout << 'a' << endl;
  else
    cout << "A" << endl;
  return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include <fstream>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int n;
vector<int> b;

vector<int> rec(vector<int> d) {
    for (int i = d.size()-1;i >= 0;i--) {
        if (d[i] == i+1) {
            d.erase(d.begin()+i);
            auto k = rec(d);
            d.insert(d.begin()+i, i+1);
            if (k.size() == d.size() - 1) {
                k.push_back(i+1);
                return k;
            } else {
                return vector<int>();
            }
        }
    }
    return vector<int>();
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int c;
        cin >> c;
        b.push_back(c);
    }
    auto k = rec(b);
    for (auto e:k) cout << e << endl;
    if (k.size() == 0) cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
M = {}

q = int(input())


for _ in range(q):
    
    command, *list_num = input().split()

    if   command == "0":
        # insert(key, x)
        key = list_num[0]
        x = int(list_num[1])
        M[key] = x            
    elif command == "1":
        # get(key)
        key = list_num[0]
        print(M[key])
    else:
        raise



Measured memory_bytes: 37512
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    N=str(input())
    if N[-1] in ['2','4','5','7','9']:
        print('hon')
    elif N[-1] in ['0','1','6','8']:
        print('pon')
    else: print('bon')

    
resolve()

Measured memory_bytes: 61688
void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <math.h>
#include <iomanip>
#include <string>
using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;

string S;
vector<vector<long long>> dp;
int MOD = 1e9 + 7;

void solve() {
	cin >> S;
	int  N = S.size();
	dp.resize(N);
	for (int n = 0; n < N; n++)dp[n].resize(13,0);
	if (S[0] != '?') {
		int d = S[0] - '0';
		dp[0][d] = 1;
	}
	else {
		for (int k = 0; k < 10; k++)dp[0][k] = 1;
	}
	for (int n = 1; n < N; n++) {
		if (S[n] != '?') {
			int d = S[n] - '0';
			for (int m = 0; m <= 12; m++) {
				dp[n][(10 * m + d) % 13] += dp[n - 1][m];
				dp[n][(10 * m + d) % 13] %= MOD;
			}
		}
		else {
			for (int d = 0; d < 10; d++) {
				for (int m = 0; m < 13; m++) {
					dp[n][(10 * m + d) % 13] += dp[n-1][m];
					dp[n][(10 * m + d) % 13] %= MOD;
				}
			}
		}
	}
	cout << dp[N - 1][5] << endl;
	return;
}

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

using namespace std;



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

	int n;
	cin >> n;

	int lastDigit = n % 10;
	int cnt = 1;
	n /= 10;

	bool isGood = false;

	while (n > 0) {
		if (n % 10 == lastDigit) ++cnt;
		else lastDigit = n % 10, cnt = 1;

		n /= 10;
		if (cnt >= 3) isGood = true;
	}

	if (isGood) cout << "Yes";
	else cout << "No";
	
	//system("pause");

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a<c&&c<b){
		puts("Yes");
	}else if(b<c&&c<a){
		puts("Yes");
	}else puts("No");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){

 int n, i;

 scanf("%d\n", &n);
 i = 1;
 while(1)
 {
     if((i / 10) % 10 == 3 || (i / 100) % 10 == 3 || (i / 1000) % 10 == 3)
     {
         printf(" %d", i);
     }
     else if((i - 3) % 10 == 0)
     {
         printf(" %d", i);
     }
     else if(i % 3 == 0)
     {
         printf(" %d", i);
     }
     
     if(i == n) 
     {
         printf("\n");
         break;
     }
     
     i++;
 }

 return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	ios::sync_with_stdio(0);
  	cin.tie(0);
	int n;
	cin>>n;
	if(n%1000 == 0)
		cout<<"0";
	else
	{
		int c = ((n/1000)+1)*1000 - n;
		cout<<c;
	}
}


Measured memory_bytes: 3636
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    a,b,m=MI()
    aa=LI()
    bb=LI()
    ans=min(aa)+min(bb)
    for _ in range(m):
        x,y,c=MI()
        x,y=x-1,y-1
        ans=min(ans,aa[x]+bb[y]-c)
    print(ans)

main()

Measured memory_bytes: 18616
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static void Main(string[] args)
    {
        //入力を受け取る
        //var N = long.Parse(Console.ReadLine());
        //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var S = Console.ReadLine();
        
        var count = 0;
        for(int i = 0;i < (S.Length/2);i++){
          if(S[i] != S[S.Length-1-i]){
            count++;
          }
        }
      
        Console.WriteLine(count);
        
    }
}


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

using ll = long long;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        A[i]--;
    }

    set<int> used;     // 探索済みの町を保存
    vector<int> path;  // 探索の順番を格納
    int now = 0;
    while (used.count(now) == 0) {  // 探索済みの町に到達するまで
        path.push_back(now);
        used.insert(now);
        now = A[now];
    }

    int s = find(path.begin(), path.end(), now) - path.begin();  // s: ループする最初の部分に到達するまで

    if (K < s) {  // ループ部分に到達しない時
        cout << path[K] + 1 << endl;
        return 0;
    } else {  // ループ部分に到達する時
        K -= s;
        K %= (int)path.size() - s;
        cout << path[s + K] + 1 << endl;
        return 0;
    }
}


Measured memory_bytes: 13776
#include <stdio.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

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

  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  vector<int> dp(n, 1e9);
  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j <= min(k, i); ++j) {
      dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
  }
  cout << dp[n - 1];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define s second
#define f first
long long const mod = 1000000007; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll h,n;
    cin>>h>>n;
    
    ll a[n];
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    
    if(sum>=h)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<float.h>
using namespace std;
# define ll long long int
#define mm 1000000007
#define pb push_back
int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0); cout.tie(0);
  	int t,n,i,ans=0,count=0;
    cin>>t>>n>>i;
	int temp = t-n;
	cout<<max(0,i-temp);
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-

def main():
	S = input()
	integer = 0
	
	for i in range(4):
		if S[i] == '+':
			integer += 1
		elif S[i] == '-':
			integer -= 1
	
	print(integer)


if __name__ == '__main__':
	main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll x;
	cin >> x;
	ll p = 100 , step = 0;
	while (p < x) {
		p += p / 100;
		step++;
	}
	cout << step << endl;
	return 0;
}

Measured memory_bytes: 3664