akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N,M,K;

vector<P> G[3003];
ll dist[3003];

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

    cin >> N >> M >> K;

    for (int i = 0;i < M;i++){
        ll a,b,l; cin >> a >> b >> l;
        G[a].push_back(P(b,l));
        G[b].push_back(P(a,l));
    }

    priority_queue<P,vector<P>,greater<P>> que;
    fill(dist,dist+N+1,LLONG_MAX);

    for (int i = 0;i < K;i++){
        ll a; cin >> a;
        dist[a] = 0;
        que.push(P(0,a));
    }

    while(que.size()){
        P p = que.top(); que.pop();
        ll from = p.second;
        ll sum = p.first;
        if(dist[from] > sum) continue;
        for (int i = 0;i < G[from].size();i++){
            ll to = G[from][i].first;
            ll cost = G[from][i].second;
            if(sum+cost < dist[to]){
                dist[to] = sum+cost;
                que.push(P(dist[to],to));
            }
        }
    }

    ll ans = 0;

    for (int i = 1;i <= N;i++){
        for (int j = 0;j < G[i].size();j++){
            ll a = i; ll b = G[i][j].first;
            ll cost = G[i][j].second;
            if(dist[b]+cost <= dist[a]) ans = max(ans,dist[a]);
            else if(dist[a]+cost <= dist[b]) ans = max(ans,dist[b]);
            else{
                cost -= abs(dist[a]-dist[b]);
                if(cost%2 == 0) ans = max(max(dist[a],dist[b])+cost/2,ans);
                else ans = max(max(dist[a],dist[b])+cost/2 +1,ans);
            }
        }
    }
    
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 8876
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {

        //入力
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */
        FastScanner sc = new FastScanner();
        int R = sc.nextInt();
        int G = sc.nextInt();

        //出力
        System.out.println(2 * G - R);
    }

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22612
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <iostream>
//#include <fstream>
//#include <algorithm>
//#include <bitset>
//#include <cassert>
//#include <cctype>
//#include <cstdlib>
//#include <cmath>
//#include <complex>
//#include <cstdio>
//#include <cstring>
//#include <ctime>
//#include <deque>
//#include <iomanip>
//#include <map>
//#include <numeric>
//#include <queue>
//#include <set>
//#include <stack>
//#include <sstream>
//#include <string>
//#include <vector>
//#include <list>

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
int n,a[100001],k=1,maxf=-1,h;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	while(k<=n){
//		cout<<k<<' ';
		h=0;
		while(k+1<=n&&a[k+1]<=a[k]){
			k++;
			h++;
		}
		k++;
		maxf=max(maxf,h);
	}
	cout<<maxf;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  int M=min(X,Y);
  int T=min(A*M+B*M,C*2*M);
  if(M==X){
    int s=Y-M;
    cout<<T+min(B*s,C*2*s)<<endl;
  }
  else{
    int s=X-M;
    cout<<T+min(A*s,C*2*s)<<endl;
  }
  return 0;  
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<stack>
using namespace std;

bool isPalindrome(string s){
    int n = s.length();
    for(int i = 0; i < n/2; i++){
        if(s[i] != s[n-1-i])    return false;
    }
    return true;
}

int main(){
    int n, l;
    cin >> n >> l;
    multiset<string> m;
    for(int i = 0; i < n; i++){
        string s;   cin >> s;
        m.insert(s);
    }
    multiset<string> twin, solo;
    while(!m.empty()){
        string s = *m.begin();  m.erase(m.begin());
        string t = s;
        reverse(t.begin(), t.end());
        if(m.count(t)){
            twin.insert(min(s, t));
            m.erase(m.find(t));
        }else if(isPalindrome(s)){
            solo.insert(s);
        }
    }
    stack<string> rev;
    for(auto it = twin.begin(); it != twin.end(); it++){
        rev.push(*it);
        cout << *it;
    }
    if(!solo.empty())   cout << *solo.begin();
    while(!rev.empty()){
        string s = rev.top();   rev.pop();
        reverse(s.begin(), s.end());
        cout << s;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3308
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

int p[200000];

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

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

	int max_sum = 0;
	int max_idx = 0;
	int prev_sum;
	int sum = 0;

	for (int i=0; i<K; i++) {
		sum += p[i];
	}

	prev_sum = sum;

	for (int i=1; i<=N-K; i++) {
		sum = prev_sum - p[i-1] + p[i+K-1];

		if (sum > max_sum) {
			max_sum = sum;
			max_idx = i;
		}
		prev_sum = sum;
	}

	//cout << "max_idx:" << max_idx << " max_sum:" << max_sum << endl; // **** debug ****

	double ans = 0;

	for (int i = max_idx; i < max_idx + K; i++) {
		double a = p[i];
		ans += a * (1.0 + a) / 2.0 / a;
	}

	cout << fixed << setprecision(10);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
using namespace std;
int n,m,s[10001],key,sum=0;
bool search(int a[],int n,int key)
{
	for(int i=0;i<n;i++)
		if(a[i]==key)
			return true;
	return false;	
}
int main()
{

	int i,t;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>s[i];
	cin>>m;
	for(i=0;i<m;i++)
	{
		cin>>t;
		if(search(s,n,t))
			sum++;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, m;
struct edge{
   int to, cost;
};
vector<edge> G[100010];
int dist[100010];

void dfs(int now, int pre){
    rep(i, 0, G[now].size()){
        int nxt = G[now][i].to;
        if(nxt == pre) continue;
        if(dist[nxt] != INF) continue;
        int cost = dist[now] + G[now][i].cost;
        dist[nxt] = cost;
        dfs(nxt, now);
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    vector<int> l(m), r(m), d(m);
    rep(i, 0, m){
        cin >> l[i] >> r[i] >> d[i];
        l[i]--; r[i]--;
        G[l[i]].push_back({r[i], d[i]});
        G[r[i]].push_back({l[i], -d[i]});
    }
    rep(i, 0, n) dist[i] = INF;
    rep(i, 0, n){
        if(dist[i] != INF) continue;
        dist[i] = 0;
        dfs(i, -1);
    }
    bool ans = true;
    rep(i, 0, m){
        if(dist[r[i]] - dist[l[i]] != d[i]) ans = false;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 22144
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] x = new double[n];
        String[] u = new String[n];
        for(int i=0; i<n; i++){
            x[i] = sc.nextDouble();
            u[i] = sc.next();
        }
        double sum = 0;
        for(int i=0; i<n; i++){
            if(u[i].equals("JPY")){
                sum += x[i];
            }
            else{
                sum += 380000 * x[i];
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 25172
#include <iostream>
using namespace std;
int main(void){
    
    int a;
    cin>>a;
    for(int i=1;i<=9;i++){
    if(a%i==0&&a/i<=9){
        cout<<"Yes"<<endl;
        break;
    }
    if(i==9){
        cout<<"No"<<endl;
        break;
    }
    }
  
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  double x1,x2,x3,y1,y2,y3,x,y;
  double a,b,c,d,ans;
  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x,&y)!=EOF){
    a=x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2);
    b=x*(y1-y2)+x1*(y2-y)+x2*(y-y1);
    c=x*(y2-y3)+x2*(y3-y)+x3*(y-y2);
    d=x*(y3-y1)+x3*(y1-y)+x1*(y-y3);
    if((a<0 && b<0 && c<0 && d<0) || (a>0 && b>0 && c>0 && d>0)){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define ll long long int
#define l(i,a,b) for(ll i =a;i<b;i++)
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n%10==2 || n%10==4 ||n%10==5||n%10==7||n%10==9) cout<<"hon\n";
	else if(n%10==0||n%10==1||n%10==6||n%10==8) cout<<"pon\n";
	else cout<<"bon\n";
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		while((line = br.readLine())!= null){
			int n = Integer.parseInt(line);
			int count = 0;
			for(int a = 0;a < 10;a++){
				for(int b = 0;b < 10;b++){
					for(int c = 0;c < 10;c++){
						for(int d = 0;d < 10;d++){
							if(a+b+c+d == n){
								count++;
							}
						}	
					}	
				}	
			}
			System.out.println(count);
		}
	}

}

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

int main() {
  map<string, int> mp;
  int n;
  cin >> n;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int m;
  cin >> m;
  rep(i, m) {
    string t;
    cin >> t;
    mp[t]--;
  }
  int ans = 0;
  for (auto a : mp) {
    ans = max(ans, a.second);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(LL i=(l);i<(r);i+=(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009 
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,int m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
typedef struct fac { LL n, exp; }F;
LL fact(LL n,F*a){LL x,i,j,c=0;x=n;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
//snippet

#define N 500009

int main() {
	char s[N];
	scanf("%s", s);
	LL i = 0, u, d, sum = 0;
	while (s[i]) {
		u = 0;
		d = 0;
		while (s[i] == '<') {
			u++;
			i++;
		}
		while (s[i] == '>') {
			d++;
			i++;
		}

		sum += u * (u - 1) / 2 + d * (d - 1) / 2 + Ma(u, d);
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define M 1000000007
using namespace std;
typedef long long int ll;


int main()
{
 int n;
 cin>>n;
 int arr[n];
 for(int i=0;i<n;i++)
    cin>>arr[i];
    ll ans = INT_MAX;
 for(int i=1;i<=100;i++)
 {
        ll sum=0;
     for(int j=0;j<n;j++)
        {
            sum = sum + abs(arr[j]-i)*abs(arr[j]-i);
        }
     if(sum<ans)
        ans=sum;
 }
 cout<<ans<<endl;
}


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

int main(){
    string s;
    cin >> s;
    int ans=0;
    int tmp=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
            tmp++;
        }else{
            tmp=0;
        }
        if(ans<tmp)ans=tmp;
    }
    cout << ans;
}

Measured memory_bytes: 256
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
    x,k,d = map(int, input().split())

    if abs(x) <= d*k:
        s = x//d
        a = x%d
        if (k-s) % 2 == 0:
            print(a)
        else:
            if abs(a + d) <= abs(a - d):
                print(abs(a+d))
            else:
                print(abs(a - d))
    else:
        print(abs(x) - d*k)

if __name__ == '__main__':
	main()


Measured memory_bytes: 9636
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    string s;
    cin >> s;
    int cc1 = 0;
    rep(i, s.size())
    {
        if ((i % 2) == 0 && s[i] == '1')
        {
            cc1++;
        }
        if ((i % 2) == 1 && s[i] == '0')
        {
            cc1++;
        }
    }
    int cc2 = 0;
    rep(i, s.size())
    {
        if ((i % 2) == 0 && s[i] == '0')
        {
            cc2++;
        }
        if ((i % 2) == 1 && s[i] == '1')
        {
            cc2++;
        }
    }
    cout << min(cc1, cc2) << endl;
    return 0;
}

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

const int mod = 1e9 + 7;
const int three = 333333336;

void add(int &x,int y) {
	x += y; if (x >= mod) x -= mod;
}

int mul(int x,int y) {
	return (long long) x * y % mod;
}

int pr(char c, char d) {
	if (c == '?') return three;
	if (c == d) return 1;
	return 0;
}

int n;
string s;
int prfA[100005], sufC[100005];
int res;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> s; n = s.size(); s = '~' + s;
	for (int i = 1; i <= n; ++i) prfA[i] = prfA[i - 1], add(prfA[i], pr(s[i], 'A'));
	for (int i = n; i >= 1; --i) sufC[i] = sufC[i + 1], add(sufC[i], pr(s[i], 'C'));
	for (int i = 1; i <= n; ++i) {
		add(res, mul(pr(s[i], 'B'), mul(prfA[i - 1], sufC[i + 1])));
	}
	for (int i = 1; i <= n; ++i) if (s[i] == '?') res = mul(res, 3);
	cout << res << '\n'; 
}

Measured memory_bytes: 1132
import sys
input = sys.stdin.readline
from collections import Counter


def read():
    S = int(input().strip())
    return S,


def solve(S, MOD=10**9+7):
    dp = [0 for i in range(S+1)]
    
    for i in range(3, S+1):
        dp[i] = (1 + sum(dp[3:i-2])) % MOD
    return dp[S]


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int fac[100010];

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

	int N;
	cin >> N;

	fac[0] = fac[1] = 1;
	rep(i, 2, 100005)
	{
		fac[i] = i * fac[i - 1];
		fac[i] %= MOD;
	}

	cout << fac[N] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>

const std::array<int32_t, 4> dx({-1, 0, 1, 0});
const std::array<int32_t, 4> dy({0, -1, 0, 1});

inline uint32_t id(const std::vector<int32_t>& coord, int32_t target) {
  return std::lower_bound(coord.begin(), coord.end(), target) - coord.begin();
}

int main() {
  uint32_t N = 0, M = 0;
  std::cin >> N >> M;
  std::vector<int32_t> A(N), B(N), C(N);
  for (size_t n = 0; n < N; n++) std::cin >> A[n] >> B[n] >> C[n];
  std::vector<int32_t> D(M), E(M), F(M);
  for (size_t m = 0; m < M; m++) std::cin >> D[m] >> E[m] >> F[m];

  // coordinate compression
  std::vector<int32_t> x_mesh(A);
  x_mesh.insert(x_mesh.end(), B.begin(), B.end());
  x_mesh.insert(x_mesh.end(), D.begin(), D.end());
  x_mesh.push_back(0);
  std::vector<int32_t> y_mesh(C);
  y_mesh.insert(y_mesh.end(), E.begin(), E.end());
  y_mesh.insert(y_mesh.end(), F.begin(), F.end());
  y_mesh.push_back(0);

  std::sort(x_mesh.begin(), x_mesh.end());
  std::sort(y_mesh.begin(), y_mesh.end());

  x_mesh.erase(std::unique(x_mesh.begin(), x_mesh.end()), x_mesh.end());
  y_mesh.erase(std::unique(y_mesh.begin(), y_mesh.end()), y_mesh.end());

  // gen grid
  std::vector<std::vector<int32_t>> grid(
      x_mesh.size() * 2, std::vector<int32_t>(y_mesh.size() * 2, 0));
  for (size_t n = 0; n < N; n++) {
    uint32_t A_id = id(x_mesh, A[n]), B_id = id(x_mesh, B[n]),
             C_id = id(y_mesh, C[n]);
    for (size_t i = A_id * 2; i <= B_id * 2; i++) grid[i][C_id * 2] = -1;
  }
  for (size_t m = 0; m < M; m++) {
    uint32_t D_id = id(x_mesh, D[m]), E_id = id(y_mesh, E[m]),
             F_id = id(y_mesh, F[m]);
    for (size_t i = E_id * 2; i <= F_id * 2; i++) grid[D_id * 2][i] = -1;
  }

  // bfs
  bool INF = false;
  uint64_t sum = 0;
  std::queue<std::pair<int32_t, int32_t>> Q;
  Q.emplace(id(x_mesh, 0) * 2, id(y_mesh, 0) * 2);
  grid[Q.front().first][Q.front().second] = 1;
  while (!Q.empty()) {
    int32_t x = Q.front().first, y = Q.front().second;
    Q.pop();

    // grid edge
    if (x == 0 || x == static_cast<int32_t>(grid.size()) - 1 || y == 0 ||
        y == static_cast<int32_t>(grid[0].size()) - 1) {
      INF = true;
      break;
    }

    // current area
    if (x % 2 && y % 2)
      sum += static_cast<uint64_t>(x_mesh[x / 2 + 1] - x_mesh[x / 2]) *
             static_cast<uint64_t>(y_mesh[y / 2 + 1] - y_mesh[y / 2]);

    // next area
    for (size_t i = 0; i < dx.size(); i++) {
      if (grid[x + dx[i]][y + dy[i]] != 0) continue;
      grid[x + dx[i]][y + dy[i]] = 1;
      Q.emplace(x + dx[i], y + dy[i]);
    }
  }

  if (INF)
    std::cout << "INF" << std::endl;
  else
    std::cout << sum << std::endl;

  return 0;
}

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

int n;
int x[25],y[25],r[25],c[25];
int cover[25];
bool check[1<<25];
int cnt,comb,a,b;
int m,ans;
int u;

double dis(int i,int j){
  return sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j]) * (y[i]-y[j]) );
}

void cov(int a){
  cover[a] = -1;
  for(int j=a-1;j>=0;j--){
    if(dis(a,j)<r[a]+r[j] && u>>j & 1){
      cover[a] = j;
      break;
    }
  }
} 

  
void rec(void){
  int cnt;
  for(int i=1;i<=4;i++){
    cnt = 0;
    for(int j=0;j<n;j++){
      if( (u>>j & 1) && cover[j]<0 && c[j] == i)cnt++;
    }
    if(cnt==6){
      for(int j=0;j<n;j++){
	if(c[j] == i)u -= 1<<j;
      }
      for(int j=0;j<n;j++)cov(j);

      ans += 6;
      m = max(m,ans);
      rec();
      ans -= 6;

      for(int j=0;j<n;j++){
	if(c[j] == i)u += 1<<j;
      }
      for(int j=0;j<n;j++)cov(j);
    }else{
      for(int j=0;j<n;j++){
	if( (u>>j & 1) && cover[j]<0 && c[j] == i){
	  for(int k=j+1;k<n;k++){
	    if( (u>>k & 1) && cover[k]<0 && c[k] == i){
	      u -= 1<<j;
	      u -= 1<<k;
	      for(int l=0;l<n;l++)cov(l);

	      ans += 2;
	      m = max(m,ans);
	      //if(!check[u]){
		rec();
		//check[u] = true;
		//}
	      ans -= 2;

	      u += 1<<j;
	      u += 1<<k;
	      for(int l=0;l<n;l++)cov(l);
	    }
	  }
	}
      }
    }
  }
}



int main(){
  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++)cin >> x[i] >> y[i] >> r[i] >> c[i];

    u = (1<<n) - 1;
    //for(int i=0;i<(1<<n);i++)check[i] = false;
    for(int i=0;i<n;i++)cov(i);

    
    m = 0;
    ans = 0;
    rec();

    cout << m << endl;
  }
}

Measured memory_bytes: 872
#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 < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

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

  if (b % a == 0) {
    cout << a+ b << endl;
  } else {
    cout << b-a << endl;
  }
}


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

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

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string S; cin >> S;
  const int N = S.size();
  vector<vector<int>> next(N * 2, vector<int>(26, -1));
  repr(i, N * 2 - 1) {
    rep(j, 26) {
      if (S[(i + 1) % N] - 'a' == j) {
        next[i][j] = i + 1;
      } else {
        next[i][j] = next[i + 1][j];
      }
    }
  }
  ll ans = 0;
  string T; cin >> T;
  int i = 0;
  if (S[0] == T[0]) T.erase(0, 1);
  for (char c : T) {
    if (next[i][c - 'a'] == -1) {
      cout << -1 << endl;
      return 0;
    }
    ans += next[i][c - 'a'] - i;
    i = next[i][c - 'a'] % N;
  }
  cout << ans+1 << endl;
}

Measured memory_bytes: 27088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B;
    cin >> A >> B;
    //string strA = to_string(A);
    //string strB = to_string(B);
    int count;
    string str;
    for(int i=A; i<=B; i++){
        str = to_string(i);
        if(str[0] == str[4] && str[1] == str [3]){
            count++;
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 3656
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, k) = get!(usize, usize);
    let v = get!([i64]);
    let mut dp = vec![0; n + 10];
    for i in 1..n {
        let mut step = 1 << 60;
        for j in 1..k + 1 {
            if i < j {
                break;
            }
            step = std::cmp::min(step, dp[i - j] + (v[i - j] - v[i]).abs());
        }
        dp[i] += step;
    }
    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 6396
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let m: usize = read();

    let mut v = vec![0; n];

    for _ in 0..m {
        let a: usize = read();
        v[a - 1] += 1;
        let b: usize = read();
        v[b - 1] += 1;
    }
    for x in v {
        println!("{}", x);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(int i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>dp(3);
  auto tdp=dp;
  ll a,b,c;cin>>a>>b>>c;
  dp[0]=a;
  dp[1]=b;
  dp[2]=c;
  rep(i,n-1){
    tdp.assign(3,0);
    vector<ll>f(3);
    rep(i,3)cin>>f[i];
    rep(j,3)rep(k,3){
      if(j!=k)chmax(tdp[k],dp[j]+f[k]);
    }
    swap(tdp,dp);
  }
  cout<<max({dp[0],dp[1],dp[2]})<<endl;



  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct UnionFind{
  vector<int> parent;
  UnionFind(int x=1){
    parent.clear();
    parent.resize(x,-1);
  }
  int find(int x){
    if(parent[x]<0)return x;
    return parent[x]=find(parent[x]);
  }
  bool same(int x,int y){
    return (find(x)==find(y));
  }
  int size(int x){
    return -parent[find(x)];
  }
  void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(size(x)<size(y))swap(x,y);
    parent[x]+=parent[y];
    parent[y]=x;
  }
};




int main(){
  int n,q;
  scanf("%d %d",&n,&q);
  UnionFind T(n);
  for(int i=0;i<q;i++){
    int type,x,y;
    scanf("%d %d %d",&type,&x,&y);
    if(type==0){
      T.unite(x,y);
    }else{
      printf("%d\n",T.same(x,y));
    }
  }
  return 0;
}


Measured memory_bytes: 3232
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int h = Integer.parseInt(in.next());
            int w = Integer.parseInt(in.next());
            int ans = (n - h + 1) * (n - w + 1);

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string S;
  cin >> S;
  
  int ans;
  
  for (int i = 0; i < 4; i++)
  {
    if (S.at(i) == '+') ans++;
    else ans--;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int n, max=0, min=0;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  
  max = *max_element(A.begin(), A.end());
  min = *min_element(A.begin(), A.end());
  
  cout << max-min << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	ll h;
	cin >> h;
	ll n = 1LL;
	ll ans = 0;
	while(h > 0) {
		ans += n;
		h /= 2;
		n *= 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

struct UnionFind{
  VI par;
  UnionFind(int N):par(N){
    rep(i,N) par[i]=i;
  }
  int root(int x){
    if(par[x]==x) return x;
    return par[x]=root(par[x]);
  }
  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry) return;
    par[rx]=ry;
  }
  bool same(int x, int y){
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }
};

int main(){
  int N,M;
  cin>>N>>M;
  VI P(N);
  rep(i,N) cin>>P[i];
  VI Z(N);
  rep(i,N) Z[P[i]-1]=i;
  VI X(M),Y(M);
  rep(i,M) cin>>X[i]>>Y[i];
  UnionFind tree(N+1);
  rep(i,M) tree.unite(Z[X[i]-1],Z[Y[i]-1]);
  int ans=0;
  rep(i,N) if(tree.same(i,Z[i])) ans++;
  cout<<ans<<endl;
}

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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           M                           200009
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           bug(i)                      cout<<"akhane bug nai  "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;


 main()
{  fast
    int k,n;
    cin>>k>>n;
    vector<int>vec;
    int sum=0;
    f(i,1,n)
    {
        int x;
        cin>>x;
        sum+=x;
        vec.pb(x);
    }
    sort(vec.begin(),vec.end());
    int gap=0;
    f(i,1,n-1)
    {
       int tmp=vec[i]-vec[i-1];
       gap=max(gap,tmp);
    }
    int tmp=vec[0]+(k-vec[n-1]);
    gap=max(gap,tmp);
    int ses=k-gap;
    cout<<ses<<endl;










































return 0;

}





Measured memory_bytes: 2420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
  //値の受け取り
  int n,k;
  cin >> n >> k;
  long long a[100010];
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  //for(int i = 0; i < n;i++){
  //cout << a[i] << endl;
  //}
  //実装

  long long dp[100010];
  for(int t = 1;t < n;t++){
    dp[t] = INF;
  }
  dp[0] = 0;



  for(int i = 1;i < n; i++){
    for(int j = 1;j < min(i+1,k+1); j++){
      //cout << dp[4] << endl;
      //if(i == 4){
      //cout << "i = " << i << " "<< "j = "<< j << endl;
      //cout << "a[i] = " << a[i] << " "<< "a[i-j] = "<< a[i-j] << endl;
      //cout <<dp[i] <<" "<<dp[i-j] << " " << abs(a[i] - a[i-j]) << " " << endl;
    //}
      chmin(dp[i],dp[i-j] + abs(a[i] - a[i-j]));

    }
  }

  //for(int i = 0; i < n;i++){
  //cout << a[i] << endl;
  //}


  //出力
  //for(int i = 0; i < n;i++){
  cout << dp[n-1] << endl;
  //}

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int dp[1000000];
int a[1000000];
int getans(int i,int n)
{
    if(i==n)
    {
        return dp[i]=0;
    }
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    int cost=abs(a[i]-a[i+1])+getans(i+1,n);
    if(i+2<=n)
    {
         cost=min(cost,abs(a[i]-a[i+2])+getans(i+2,n));
        //return cost;
    }
    return dp[i]=cost;
 // return dp[i];
}
int main()
{
    int n;
    cin>>n;
   // int a[n];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    memset(dp,-1,sizeof(dp));
    int ans=getans(1,n);
    cout<<ans<<endl;
}


Measured memory_bytes: 14144
/* Author : Harshit Jain a.k.a. iharshit009 */
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define int              long long
#define endl 			 "\n";
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define all(x)           x.begin(), x.end()
#define deb(x)         cout << '>' << #x << ':' << x << endl;
const int mod = 1e9 + 7;
using namespace std;
const int N = 1e5 + 5; 
int n;
int a[N];

void fuck(){

string s;
cin >> s;
n = s.size();
if(s[n-1] != 's'){
	cout << s + 's';
}else{
	cout << s + "es";
}
return;

}

int32_t main(){
IOS;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int t = 1;
// cin >>t;
while(t--){
	fuck();
// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)
 
// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting min to 0 instead of -INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)
}
return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main{
  public static void main(String args[]){
    try (Scanner sc = new Scanner(System.in)) { while (true) {
      int n = sc.nextInt();
      if (n == 0) { break; }
      double average = 0, variance = 0;
      int[] scores = new int[n];
      for (int i = 0; i < scores.length; i++) {
      scores[i] = sc.nextInt();
        average += scores[i];
       }

       average = average/ (double)scores.length;
      
      for(int i = 0;i<scores.length;i++){
        variance += (average - (double)scores[i])*(average - (double)scores[i]);
      }
      variance  = variance/ (double)scores.length;
      System.out.println(Math.sqrt(variance));
        }
      }
  }
}


Measured memory_bytes: 31952
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin>>s;
	for(int i = 0; i+1 < s.size(); ++i) {
		if(s[i] == 'A' && s[i+1] == 'C') {
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <sstream>
#include <cctype>
#include <cmath>
#include <cstdio>
using namespace std;
#define MPI  3.14159265358979323846

struct Dice{
	int d[6];
	void input();
	void rotation(int&,int&,int&,int&);
	void roll(char);
	string c1 = "WWWWSWW",c2="RRRR";
	int iden(int,int);
};

void Dice::rotation(int& a, int& b, int& c, int& d){
	int p = a; a = b; b = c; c = d; d = p;
}

void Dice::roll(char c){
	if (c == 'W')rotation(d[0], d[2], d[5], d[3]);
	if (c == 'S')rotation(d[0], d[4], d[5], d[1]);
	if (c == 'E')rotation(d[0], d[3], d[5], d[2]);
	if (c == 'N')rotation(d[0], d[1], d[5], d[4]);
	if (c == 'R')rotation(d[1], d[2], d[4], d[3]);
}

void Dice::input(){
	for (int i = 0; i < 6; i++){
		cin >> d[i];
	}
}

int Dice::iden(int a, int b){
	for (int i = 0; i < c1.size(); i++){
		if (a == d[0])break;
		roll(c1[i]);
	}
	for (int i = 0; i < c2.size(); i++){
		if (b == d[1])break;
		roll(c2[i]);
	}
	return d[2];
}

int main(){

	Dice Dice1, Dice2;
	Dice1.input();
	Dice2.input();

	if (Dice2.d[2] == Dice1.iden(Dice2.d[0], Dice2.d[1]))cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3092
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] c = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                c[i][j] = sc.nextInt();
            }
        }
        int a = c[0][0] + c[1][1] + c[2][2];
        int b = c[0][1] + c[1][2] + c[2][0];
        int d = c[0][2] + c[1][0] + c[2][1];
        if (a == b && b == d)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	if(t.size() == s.size() + 1){
		rep(i, s.size()){
			if(s[i] != t[i]){
				cout << "No";
				return 0;
			}
		}

		cout << "Yes";
	}
	else{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;

ll A[100010],used[100010];

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

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

	int ans = 0;
	for (int i = 1; i < N; i++) {
		if (A[i] > A[i - 1]) {
			while (A[i] >= A[i - 1] && i < N) {
				used[i] = used[i - 1] = 1;
				i++;
			}
			ans++;
		}
		else if (A[i] < A[i - 1]) {
			while (A[i] <= A[i - 1] && i < N) {
				used[i] = used[i - 1] = 1;
				i++;
			}
			ans++;
		}
	}
	if (used[N - 1] != 1)ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Short Functions ---------- */

template <typename T>
T square(T a) {
    return a * a;
}


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p) cout << GET_VAR_NAME(p) << " = (" << (p).fst << ", " << (p).snd << ")" << endl;


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */


/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

  string A, B, C;
  cin >> A >> B >> C;
  if (A.back() == B.front() && B.back() == C.front()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if((a+b)%2==0)ou((a+b)/2);
  else ou("IMPOSSIBLE");
  
}

Measured memory_bytes: 256