akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    cin >> n;
    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 50; j++) {
            if (4*i + 7*j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		long t = System.currentTimeMillis();
		new Main().run();
		System.err.println(System.currentTimeMillis() - t);
	}
	
	
	void run() {
		FastScanner sc = new FastScanner();
		int K=sc.nextInt();
		int N=sc.nextInt();
		int[] A=new int[N];
		long ans=K;
		for(int i=0;i<N;++i)A[i]=sc.nextInt();
		for(int i=0;i<N;++i) {
			ans=Math.min(ans, K-((i+1==N?(K+A[0]):A[i+1])-A[i]));
		}
		System.out.println(ans);
	}
	
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
	
	
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;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); 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() {
    	return (int)nextLong();
    }
}


Measured memory_bytes: 24548
import sys

s = input()
n = len(s)

if s == s[::-1]:
    m = s[0: int((n-1)/2)] 
    if m == m[::-1]:
        l = s[int((n+3)/2): n-1]
        if l == l[::-1]:
            print("Yes")
            sys.exit()

print("No")


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

#define loop(x) for(int knzk=0;knzk<x;++knzk)
int in(){int x;scanf("%d",&x);return x;}

template<class T>
ostream& operator<<(ostream& os,set<T> const& v){for(auto itr=v.begin();itr!=v.end();++itr){if(itr!=v.begin())os<<' ';os<<*itr;}return os;}


signed main(){

  int n,m;
  set<int> s,t;
  cin>>n;
  loop(n)s.insert(in());
  cin>>m;
  loop(m)t.insert(in());

  set<int> result;
  set_intersection(
    s.begin(),s.end(),
    t.begin(),t.end(),
    inserter(result,result.end())
  );

  for(auto x:result)cout<<x<<endl;


}


Measured memory_bytes: 23780
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long unsigned ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long unsigned

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

	string S;
	cin >> S;
	int len = S.length();

	ll ans = 0;
	for (int msk = 0; msk < 1<<(len-1); msk++)
	{
		ll num = S[0] - '0';
		for (int i = 0; i < len-1; i++)
		{
			if (msk & 1 << i) {
				ans += num;
				num = 0;
			}
			num = num * 10 + (S[i + 1] - '0');
		}
		ans += num;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a[200],b[200],c[200],i,count;
	i=0;
	while(cin>>a[i]>>b[i]){
		count=1;
		c[i]=a[i]+b[i];
		while(c[i]/10!=0){
			c[i]=c[i]/10;
			count++;
		}cout<<count<<endl;
	}
	return 0;
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const int MAX_N = 200000;

int main() {
  int N, A[MAX_N], first = 0, second = 0;
  std::cin >> N;
  rep(i, N) {
    std::cin >> A[i];
    if(A[i] >= first) {
      second = first;
      first = A[i];
    } else if(A[i] >= second) {
      second = A[i];
    }
  }

  rep(i, N) {
    std::cout << (A[i] == first ? second : first) << '\n';
  } std::cout << std::endl;

}


Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
	class Program
	{

		static void Main(string[] args)
		{
			var inputNum = Console.ReadLine();
			var last = inputNum.Last();

			switch (last)
			{
				case '2':
				case '4':
				case '5':
				case '7':
				case '9':
					Console.WriteLine("hon");
					break;
				case '3':
					Console.WriteLine("bon");
					break;
				default:
					Console.WriteLine("pon");
					break;
			}
		}
	}
}

Measured memory_bytes: 26164
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class key, class value, class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

template<class key, class value, class cmp = std::less_equal<key>>
using ordered_multimap = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;

ll mod = 1e9+7;

int main(){
	ll n;
	cin >> n;
	vector <vector<ll>> arr(n,vector<ll>(n,0));
	for (int z=0;z<n;z++){
		for (int x=0;x<n;x++){
			cin >> arr[z][x];
		}
	}
	vector <ll> dp(1<<n);
	dp[0] = 1;
	for (int z=1;z<(1<<n);z++){
		ll c = __builtin_popcount(z)-1;
		for (int x=0;x<n;x++){
			if (z&(1<<x) && arr[c][x]){
				dp[z] += dp[z^(1<<x)];
				dp[z] %= mod;
			}
		}
	}
	cout << dp[(1<<n)-1] << endl;
	cin >> n;
}



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



int main()
{
        int n,k;
        cin>>n>>k;
        LL a[n+2],DP[n+2];
        for(int i=1;i<=n;i++)
        {
                cin>>a[i];
                DP[i]=1e12;
        }
        DP[1]=0;
        for(int i=1;i<=n-1;i++)
        {
                for(int j=1;j<=k;j++)
                {
                        if(i+j>n) break;
                        DP[i+j] = min(DP[i+j] , DP[i] + abs(a[i+j]-a[i]));
                }
        }
        cout<<DP[n]<<endl;
  }

Measured memory_bytes: 1792
n=int(input())
a=list(map(int, input().split()))
a_gu=a[0::2]
a_ki=a[1::2]
if len(a)%2==0:
    a_ki.reverse()
    a_ki.extend(a_gu)
    print(' '.join(map(str,a_ki)))
else:
    a_gu.reverse()
    a_gu.extend(a_ki)
    print(' '.join(map(str,a_gu)))

Measured memory_bytes: 31480
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
char s[2][SIZE];
bool f(int x,int n,int len,char dec,char inc){
    int ll=1,rr=n;
    for(int i=len-1;i>=0;i--){
        if(s[1][i]==inc)ll=max(1,ll-1);
        else if(s[1][i]==dec)rr=min(n,rr+1);
        if(s[0][i]==inc)rr--;
        else if(s[0][i]==dec)ll++;
        if(ll>rr)return 0;
    }
    return x>=ll&&x<=rr;
}
int main(){
    int n,m,len;
    int x,y;
    R(n,m,len);
    R(x,y);
    REP(i,2)RS(s[i]);
    if(f(x,n,len,'U','D')&&f(y,m,len,'L','R'))W("YES");
    else W("NO");
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int arr[n + 1];
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        cin >> arr[i];
        if(i & 1 && arr[i] & 1) ans++;
    }
    cout << ans << endl;
}

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

using vb=vector<bool>;
using vi=vector<int>;
using vvi=vector<vi>;
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vl>;
using si=set<int>;
using qi=queue<int>;
using pi=pair<int,int>;

void solve() {
    string s; cin>>s;
    if(s=="ABC"){
        cout<<"ARC\n";
    }else{
        cout<<"ABC\n";
    }
}

bool boosts=false, tests=false;

int main() {
    if(boosts) {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    int tcases=1;
    if(tests) {
        cin>>tcases;
    }
    for(int tcase=1; tcase<=tcases; tcase++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
const int MAX = 1e5 + 10;

inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }

int main() {
    string str;
    cin >> str;
    if (str.find('A') != str.npos && str.find('B') != str.npos) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
const double PI = acos(-1);
typedef long long ll;


int main(void){
    int N,T;
    cin>>N>>T;
    VI t(N);
    REP(i,N)cin>>t[i];

    int cnt=T;
    REP(i,N-1){
        cnt+=min(T,t[i+1]-t[i]);
    }
    cout<<cnt<<endl;

}




Measured memory_bytes: 1024
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
  long long a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  if (a + b > c * 2) {
    long long ans = min(x, y) * 2 * c;
    if (x > y) {
      if (a > c * 2) {
        ans += c * 2 * (x - y);
      } else {
        ans += a * (x - y);
      }
    } else {
      if (b > c * 2) {
        ans += c * 2 * (y - x);
      } else {

        ans += b * (y - x);
      }
    }
    cout << ans << endl;
  } else {
    cout << x * a + y * b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;   
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    double a,b,d=0,n,m,k,ans=0;
    string s,s2;
    cin >> n;
    VI p(n);
    rep(i,n){
        cin >> p[i];    
    }
    sort(ALL(p));
    p[n-1] = p[n-1]/2;
    rep(i,n){
        d += p[i];    
    }
    cout << d <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;


main(){
  
  int map[10][10];
  int x,y,size;
  //initialize
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      map[i][j]=0;
    }
  }
  int white=0,Max=0;
  while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
    
    if(size==1){
      if(y>=0&&y<10&&(x-1)>=0&&(x-1)<10)map[y][x-1]++;    
      if((y-1)>=0&&(y-1)<10&&x>=0&&x<10)map[y-1][x]++;
	 if(y>=0&&y<10&&x>=0&&x<10)map[y][x]++;
	    if((y+1)>=0 &&(y+1)<10&&x>=0&&x<10)map[y+1][x]++;
	       if(y>=0&&y<10&&(x+1)>=0&&(x+1)<10)map[y][x+1]++;
		  
    }
    if(size==2){
      
      if(y-1>=0&&y-1<10&&(x-1)>=0&&(x-1)<10)map[y-1][x-1]++;
      if(y+1>=0&&y+1<10&&(x-1)>=0&&(x-1)<10)map[y+1][x-1]++;
      
      if(y-1>=0&&y-1<10&&(x+1)>=0&&(x+1)<10)map[y-1][x+1]++;
      if(y+1>=0&&y+1<10&&(x+1)>=0&&(x+1)<10)map[y+1][x+1]++;
       if(y>=0&&y<10&&(x-1)>=0&&(x-1)<10)map[y][x-1]++;    
      if((y-1)>=0&&(y-1)<10&&x>=0&&x<10)map[y-1][x]++;
	 if(y>=0&&y<10&&x>=0&&x<10)map[y][x]++;
	    if((y+1)>=0 &&(y+1)<10&&x>=0&&x<10)map[y+1][x]++;
	       if(y>=0&&y<10&&(x+1)>=0&&(x+1)<10)map[y][x+1]++;


    }
    if(size==3){                     if(y>=0&&y<10&&(x-2)>=0&&(x-2)<10) map[y][x-2]++;
                     
       if(y-2>=0&&y-2<10&&(x)>=0&&(x)<10)map[y-2][x]++; if(y+2>=0&&y+2<10&&(x)>=0&&(x)<10)  map[y+2][x]++;
                      
                                     if(y>=0&&y<10&&(x+2)>=0&&(x+2)<10)  map[y][x+2]++;
					  if(y-1>=0&&y-1<10&&(x-1)>=0&&(x-1)<10)map[y-1][x-1]++;
      if(y+1>=0&&y+1<10&&(x-1)>=0&&(x-1)<10)map[y+1][x-1]++;
      
      if(y-1>=0&&y-1<10&&(x+1)>=0&&(x+1)<10)map[y-1][x+1]++;
      if(y+1>=0&&y+1<10&&(x+1)>=0&&(x+1)<10)map[y+1][x+1]++;
       if(y>=0&&y<10&&(x-1)>=0&&(x-1)<10)map[y][x-1]++;    
      if((y-1)>=0&&(y-1)<10&&x>=0&&x<10)map[y-1][x]++;
	 if(y>=0&&y<10&&x>=0&&x<10)map[y][x]++;
	    if((y+1)>=0 &&(y+1)<10&&x>=0&&x<10)map[y+1][x]++;
	       if(y>=0&&y<10&&(x+1)>=0&&(x+1)<10)map[y][x+1]++;
					
    }
    
    
  }

    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
	if(map[i][j]==0)white++;
	if(map[i][j]>=Max)Max=map[i][j];
      }
      
    }
  cout << white<<endl<< Max << endl;

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
ll cef[110][110][110][2],f[110][110][110][2],n,m,K,mod,C[110][110];
ll fp(ll a,ll k){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
void upd(ll&a,ll b){a=(a+b)%mod;}
int main(){
	read(n);read(m);read(K);read(mod);
	for(int i=0;i<=100;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for(int p=0;p<=n;p++)
		for(int k=1;k<=K;k++)
			for(int i=0;i<=m;i++)
				cef[p][k][i][0]=fp((fp(k,m-i)-fp(k-1,m-i))*fp(K-k+1,i)%mod,p);
	for(int p=0;p<=m;p++)
		for(int k=1;k<=K;k++)
			for(int i=0;i<=n;i++)
				cef[p][k][i][1]=fp(fp(k,n-i)*(fp(K-k+1,i)-fp(K-k,i))%mod,p);
	f[0][0][0][0]=1;
	for(int k=0;k<K;k++)
		for(int i=0;i<=n;i++)
			for(int j=0;j<=m;j++){
				for(int p=0;p+i<=n;p++)
					upd(f[k][i+p][j][1],f[k][i][j][0]*cef[p][k+1][j][0]%mod*C[n-i][p]);
				for(int p=0;p+j<=m;p++)
					upd(f[k+1][i][j+p][0],f[k][i][j][1]*cef[p][k+1][i][1]%mod*C[m-j][p]);
			}
	cout<<(f[K][n][m][0]+mod)%mod<<'\n';
	return 0;
}


Measured memory_bytes: 41088
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


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

	ll n;
	cin >> n;

	set<ll> d;
	REP(i, n) {
		ll dd;
		cin >> dd;
		d.insert(dd);
	}
	cout << d.size() << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;

const int N=50005;
int n,m,T,x[N*2],y[N*2];
namespace solver1{
	uint B[N][N/32+5],fu[N/32+5];
	char ans[N*2];
	int vis[N];
	void solve(){
		For(i,1,m) x[i]--,y[i]--;
		For(i,0,n-1) B[i][i>>5]|=(1u<<(i&31));
		For(i,0,n-1) fu[i>>5]|=(1u<<(i&31));
		For(i,1,m) For(j,0,n/32)
			B[x[i]][j]=B[y[i]][j]=B[x[i]][j]|B[y[i]][j];
		int sp=-1;
		For(i,0,n-1){
			bool fl=0;
			For(j,0,n/32)
				if (fu[j]!=B[i][j])
					fl=1;
			if (!fl) sp=i;
		}
		if (sp==-1) return puts("-1"),void(0);
		vis[sp]=1;
		Rep(i,m,1){
			if (vis[x[i]]==vis[y[i]]) ans[i]='^';
			else if (vis[x[i]]) ans[i]='^';
			else ans[i]='v';
			vis[x[i]]=vis[y[i]]=vis[x[i]]|vis[y[i]];
		}
		printf("%s\n",ans+1);
	}
}
namespace solver2{
	char ans[N*2];
	int be[N*2],cnt[N*2];
	void solve(){
		if (n==2) return puts("-1"),void(0);
		For(i,1,n) be[i]=i,cnt[i]=1;
		Rep(i,m,1){
			int X=be[x[i]],Y=be[y[i]];
			if (cnt[X]<cnt[Y]){
				ans[i]='^';
				cnt[X]++;
				cnt[Y]--;
				be[y[i]]=be[x[i]];
			}
			else{
				ans[i]='v';
				cnt[X]--;
				cnt[Y]++;
				be[x[i]]=be[y[i]];
			}
		}
		printf("%s\n",ans+1);
	}
}
int main(){
	scanf("%d%d%d",&n,&m,&T);
	For(i,1,m) scanf("%d%d",&x[i],&y[i]);
	if (T==1) solver1::solve();
	else solver2::solve(); 
}


Measured memory_bytes: 307456
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 1<<30;
typedef pair<int, int> P;


int main() {
  int h, w; cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  vector<vector<int>> cnt(h, vector<int>(w));
  rep(i, h) {
    vector<int> done(w);
    rep(j, w) {
      if(s[i][j] == '#') continue;
      if(done[j]) continue;
      int l = 0;
      while(j + l < w) {
        if(s[i][j+l] == '#') break;
        ++l;
      }
      rep(k, l) {
        cnt[i][j+k] += l;
        done[j+k] = 1;
      }
    }
  }

  rep(j, w) {
    vector<int> done(h);
    rep(i, h) {
      if(s[i][j] == '#') continue;
      if(done[i]) continue;
      int l = 0;
      while(i + l < h) {
        if(s[i+l][j] == '#') break;
        ++l;
      }
      rep(k, l) {
        cnt[i+k][j] += l;
        done[i+k] = 1;
      }
    }
  }
  int ans = 0;
  rep(i, h) rep(j, w) ans = max(ans, cnt[i][j] - 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 20096
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define pb push_back
#define vl vector<ll>
#define pll pair<ll,ll>
#define mp make_pair
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    ll n;
    cin>>n;
    ll x[n];
    double avg=0;
    for (ll i = 0; i < n; ++i)
    {
        cin>>x[i];
        avg+=(double)x[i];
    }
    avg/=(double)n;
    ll p1 = floor(avg);
    ll p2 = ceil(avg);
    ll st1=0,st2=0;
    for (ll i = 0; i < n; ++i)
    {
        st1+=(p1-x[i])*(p1-x[i]);
        st2+=(p2-x[i])*(p2-x[i]);
    }    
    if(st1>=st2)
        cout<<st2<<endl;
    else
        cout<<st1<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		int R = sc.nextInt();
		int mod = 2019;
		int L_mod = L%2019;
		int R_mod = R%2019;
		if (R-L>=2018 || L_mod>=R_mod) {
			System.out.println(0);
		} else {
			int min = Integer.MAX_VALUE;
			for (int i=L_mod;i<R_mod;i++) {
				for (int j=i+1;j<=R_mod;j++) {
					min = Math.min(min, i*j%mod);
				}
			}
			System.out.println(min);
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long

using namespace std;

const int N = 2e5 + 10;

inline ll num(int x) {
	return 1ll * x * (x - 1) >> 1;
}

int n, a[N], h[N], t = 0;
ll r = 0;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i], h[a[i]]++;
	for (int i = 1; i <= n; i++) if (h[i]) r += num(h[i]);
	for (int i = 1; i <= n; i++) cout << r - num(h[a[i]]) + num(h[a[i]] - 1) << endl;
	
	return 0;
}

Measured memory_bytes: 3712
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 S          PIC X(30).

PROCEDURE DIVISION.
  ACCEPT S.
  IF S(1:1) = S(2:1) AND S(2:1) <> S(3:1) AND S(3:1) = S(4:1)
    DISPLAY "Yes"
  ELSE
    IF S(1:1) = S(3:1) AND S(2:1) <> S(3:1) AND S(2:1) = S(4:1)
      DISPLAY "Yes"
    ELSE
      IF S(1:1) = S(4:1) AND S(1:1) <> S(2:1) AND S(2:1) = S(3:1)
        DISPLAY "Yes"
      ELSE
        DISPLAY "No"
      END-IF
    END-IF
  END-IF.
  STOP RUN.


Measured memory_bytes: 3668
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000

int main(){
  char buf[1024];
  int *a=(int *)malloc(sizeof(int)*5);
  int k;

  rep(i,5){
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf, "%d", &a[i]);
  }
  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &k);

  if(a[4]-a[0]<=k){
    printf("Yay!\n");
  }
  else{
    printf(":(\n");
  }

  return 0;


}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

int dp[2005][2005];

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

    int n; cin >> n;

    int cnt = 0;

    rep(i,n){
        string x = to_string(i+1);
        if(x.length()%2==1) cnt++;
    }

    cout << cnt << endl;
    
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> id(n+1, -1);
    vector<int> s;
    int len = 0;
    int x = 1;
    while (id[x] == -1) {
        s.push_back(x);
        id[x] = len;
        len++;
        x = a[x-1];
    }

    int c = len - id[x];
    if (k < len) {
        cout << s[k] << endl;
        return 0;
    }
    else {
        k -= len;
        k %= c;
        cout << s[id[x]+k] << endl;
    }
    return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, Q; cin >> N >> Q;
    string s; cin >> s;
    vector<char> t(Q), d(Q);
    vec D(Q);
    REP(i, Q){
        cin >> t[i] >> d[i];
        if(d[i] == 'L') D[i] = -1;
        else D[i] = 1;
    }

    int i1 = -1, i2 = N;
    while(i2 - i1 > 1){
        int i0 = (i1 + i2) / 2;
        int now = i0;
        bool fall = false;
        REP(i, Q) if(t[i] == s[now]){
            now += D[i];
            if(now >= N) break;
            if(now < 0){
                fall = true;
                break;
            }
        }
        if(fall) i1 = i0;
        else i2 = i0;
    }

    int j1 = -1, j2 = N;
    while(j2 - j1 > 1){
        int j0 = (j1 + j2) / 2;
        int now = j0;
        bool fall = false;
        REP(i, Q) if(t[i] == s[now]){
            now += D[i];
            if(now < 0) break;
            if(now >= N){
                fall = true;
                break;
            }
        }
        if(fall) j2 = j0;
        else j1 = j0;
    }
    //debug(i1);
    //debug(j1);
    int ans = j1 - i1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2580
n = int(input())
p = []
for i in range(n):
    p.append([int(num) for num in input().split()])

flag = []
for i in range(n):
    flag.append(False)
count = 0

for i in range(n):
    p[i].sort()

for i in range(n):
    if flag[i]:
        continue

    flag[i] = True
    for j in range(i + 1, n):
        if flag[j]:
            continue
        if (p[i][0] == p[j][0]) & (p[i][1] == p[j][1]) & (p[i][2] == p[j][2]):
            flag[j] = True
            count += 1

print(count)

Measured memory_bytes: 7904
n, m = map(int, input().split())
h = list(map(int, input().split()))
paths = []
for _ in range(m):
    a, b = map(int, input().split())
    if a>b:
        paths.append([b, a])
    else :
        paths.append([a, b])


ans = [True] * n
# for i in range(n):
#     ans.append(i+1)
    
for j in range(m):
    path = paths[j]
    if h[path[0]-1] > h[path[1]-1]:
        ans[path[1]-1] = False
    elif h[path[0]-1] < h[path[1]-1]:
        ans[path[0]-1] = False
    else :
        ans[path[1]-1] = False
        ans[path[0]-1] = False
        

print(ans.count(True))

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 2e5+1;
int n, k, psum[N];

int main()
{
  fastio;
  cin >> n >> k;
  for (int i = 1; i <= n; i++){
    int x; cin >> x;
    psum[i] = psum[i - 1] + x;
  }
  int res = 0;
  for (int i = 0; i <= n - k; i++){
    res = max(res, psum[i + k] - psum[i]);    
  }
  cout << fixed << setprecision(6) <<  1.00 * (res + k) / 2;
  return 0;
}

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

typedef int Capacity;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, Capacity cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

struct Dinic {
    int n, t;
    vector<int> level;
    vector<char> vis;
    vector<vector<Capacity>> cap, flow;
    vector<vector<int>> g;
    Capacity inf;
    Dinic(int n)
        : n(n), cap(n, vector<Capacity>(n)), flow(n, vector<Capacity>(n)),
          g(n, vector<int>()), inf(numeric_limits<Capacity>::max()/8){}
    Dinic(const Graph &graph){
        *this = Dinic(graph.size());
        rep(i,n) for(auto &e : graph[i]) addEdge(e.src, e.dst, e.cap);
    }
    void addEdge(int u, int v, Capacity c){
        cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
        g[u].push_back(v); g[v].push_back(u);
    }
    Capacity solve(int s, int t){
        Capacity res = 0, aug = 1;
        this->t = t;
        while(aug > 0){
            aug = 0;
            levelize(s);
            vis.assign(n, false);
            Capacity tmp = 1;
            while(tmp > 0) aug += (tmp = augment(s, inf));
            res += aug;
        }
        return res;
    }
    Capacity augment(int v, const Capacity &lim){
        vis[v] = true;
        if(v == t) return lim;
        for(const int &d : g[v]){
            if(vis[d] || flow[v][d] == cap[v][d] || level[v] >= level[d]) continue;
            Capacity aug = augment(d, min(lim, cap[v][d] - flow[v][d]));
            flow[v][d] += aug;
            flow[d][v] -= aug;
            if(aug > 0) return aug;
        }
        return 0;
    }
    void levelize(int s){
        level.assign(n, inf);
        level[s] = 0;
        queue<int> q;
        q.push(s);
        while(q.size()){
            int v = q.front(); q.pop();
            for(const int &d : g[v]){
                if(level[d] <= level[v] + 1 || cap[v][d] - flow[v][d] == 0) continue;
                level[d] = level[v] + 1;
                q.push(d);
            }
        }
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    Graph g(N);
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        g[a].emplace_back(a,b,c);
    }
    Dinic ek(g);
    cout << ek.solve(0,N-1) << endl;
}

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

int A[2000];
int m[2000];
int i;
int n, q;

bool dfs(int j, int sum) {
  if (j == n) {
    return sum == m[i];
  }
  else {
    if (dfs(j+1, sum+A[j]))
      return true;
    if (dfs(j+1, sum))
      return true;
  }
  return false;
}

int main(){
  int j;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> A[i];
  }
  cin >> q;
  for (i = 0; i < q; i++) {
    cin >> m[i];
  }
  for (i = 0; i < q; i++) {
    if (dfs(0, 0))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
}




Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define FastRead                      \
                                    ios_base::sync_with_stdio(false); \
                                    cin.tie(0);
#define ll long long
#define endl "\n"
#define f for
using namespace std;
int main()

{
    FastRead
    ll int n,i,last,num,first,sum=0,j,c[10][10]= {0};
    cin>>n;
    f(i=1; i<=n; i++)
    {
        last=i%10;
        num=i;
        while(num!=0)
        {
            first=num%10;
            num=num/10;
        }

        c[first][last]++;

    }
    f(i=0; i<10; i++)
    {
        f(j=0; j<10; j++)
        {
            sum=sum+(c[i][j]*c[j][i]);
        }
    }
    cout<<sum;
    return 0;

}

Measured memory_bytes: 3616
a,b = map(int,input().split())

def bina(x):
    if x % 2 == 1:
        if (x+1) % 4 == 2:
            return 1
        else:
            return 0
    else:
        return x ^ bina(x-1)
    
ans = bina(a-1) ^ bina(b)

print(ans)

Measured memory_bytes: 38384
n = int(input())
ans = "Yes"
tp = 0
xyp = [0,0]
for i in range(n):
    t,x,y = map(int,input().split())
    d = abs(x-xyp[0])+abs(y-xyp[1])
    if d <= t-tp:
        if ((t-tp)-d)%2 == 1:
            ans = "No"
    else:
        ans = "No"
        
    tp = t
    xyp = [x,y]
print(ans)

Measured memory_bytes: 46884
import sys
input = sys.stdin.readline

n,m=map(int,input().split())
d={i+1:[] for i in range(n)}
for i in range(m):
    x,y=map(int,input().split())
    d[x].append(y)
    d[y].append(x)

visit=set()
ans= 0 
for i in range(1,n+1):
    if i not in visit:
        ans+=1
        stack = [i]
        while stack:
            c=stack.pop()
            visit.add(c)
            for j in d[c]:
                if j not in visit:
                    stack.append(j)
print(ans-1)





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

bool judge(string x){
  reverse(x.begin(),x.end());
  string tmp = x;
  reverse(x.begin(),x.end());
  if(x == tmp){
    return true;
  }
  else{
    return false;
  }
}

int main(){
  string S;
  cin >> S;
  
  bool jdg = false;
  int N = S.size();
  
  string s1,s2;
  s1 = S.substr(0,(N - 1)/2);
  s2 = S.substr((N + 3) / 2 - 1);
  
  if(judge(S) == true){
    if(judge(s1) == true){
      if(judge(s2) == true){
        jdg = true;
      }
    }
  }
  
  if(jdg)  cout << "Yes" << endl;
  else  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] A = new int[2][N];
		for(int i = 0; i < 2; i++) {
			for(int j = 0; j < N; j++)
				A[i][j] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0; i < N; i++) {
			int num = 0;
			for(int j = 0; j <= i; j++)
				num += A[0][j];
			for(int j = i; j < N; j++)
				num += A[1][j];
			ans = Math.max(ans, num);
		}
		System.out.println(ans);

	}

}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

class Dice {
private:
	int number[6];
	int state[6];
public:
	Dice();
	~Dice();
	void initialize();
	void setNumber(int index, int num);
	void roll(char d);
	void move(string d);
	int getTop();
	int getSide(int t, int f);
};

Dice::Dice() {
	initialize();
}

Dice::~Dice() {
}

void Dice::initialize() {
	for (int i = 0; i < 6; i++)
		state[i] = i+1;
}

void Dice::setNumber(int index, int num) {
	number[index] = num;
}

void Dice::roll(char d) {
	int nextIndex[4][6] = {
		{1, 5, 2, 3, 0, 4},
		{3, 1, 0, 5, 4, 2},
		{2, 1, 5, 0, 4, 3},
		{4, 0, 2, 3, 5, 1},
	};
	int *idx, nextState[6];
	switch (d) {
		case 'N': idx = nextIndex[0]; break;
		case 'E': idx = nextIndex[1]; break;
		case 'W': idx = nextIndex[2]; break;
		case 'S': idx = nextIndex[3]; break;
		default: return;
	}
	for (int i = 0; i < 6; i++)
		nextState[i] = state[idx[i]];
	for (int i = 0; i < 6; i++)
		state[i] = nextState[i];
}

void Dice::move(string d) {
	int oldIndex[4][6] = {
		{1, 5, 2, 3, 0, 4},
		{3, 1, 0, 5, 4, 2},
		{2, 1, 5, 0, 4, 3},
		{4, 0, 2, 3, 5, 1},
	};
	for (int i = 0; i < d.size(); i++) {
		int newNumber[6] = {0};
		int *idx;
		char c = d[i];
		switch (c) {
			case 'N': idx = oldIndex[0]; break;
			case 'E': idx = oldIndex[1]; break;
			case 'W': idx = oldIndex[2]; break;
			case 'S': idx = oldIndex[3]; break;
			default: return;
		}
		for (int i = 0; i < 6; i++)
			newNumber[i] = number[idx[i]];
		for (int i = 0; i < 6; i++)
			number[i] = newNumber[i];
	}
}

int Dice::getTop() {
	return number[state[0]-1];
}

int Dice::getSide(int t, int f) {
	int flag = 0;
	string s = "NNNNENNNN";
	for (int i = 0; i < s.size(); i++) {
		if (number[state[1]-1] == f) {
			flag = 1;
			break;
		}
		char c = s[i];
		roll(c);
	}
	if (flag != 1) {
		cout << "not match" << endl;
	}
	s = "EEEEE";
	for (int i = 0; i < s.size(); i++) {
		if (number[state[0]-1] == t)
			break;
		char c = s[i];
		roll(c);
	}
	return number[state[2] - 1];
}

int main() {
	Dice dice;
	int n;
	for (int i = 0; i < 6; i++) {
		cin >> n;
		dice.setNumber(i, n);
	}
	int t, f;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t >> f;
		cout << dice.getSide(t, f) << endl;
		dice.initialize();
	}
	return 0;
}

Measured memory_bytes: 1208
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
float sug[3005];

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    float a,b,c,d,e,f; cin >> a >> b >> c >> d >> e >> f;
    float noudo = 0;

    float ans_wat;
    float ans_sug;
    
    FOR(i,1,3000) {
        sug[i] = sug[i-1];
        if(i-c>=0) chmax(sug[i], sug[i-(int)c]+c);
        if(i-d>=0) chmax(sug[i], sug[i-(int)d]+d);
    }
    FOR(i,0,30) {
        FOR(j,0,30) {
            float wat = i*a*100 + j*b*100;
            if(wat >= f) continue;
            float can = sug[(int)(wat/100 * e)]; 
            if(can > f - wat) can = f-wat;
            if(noudo <= can/(wat+can)) {
                // cout << wat << " " << can << endl;
                noudo = can/(wat+can);
                ans_wat = wat;
                ans_sug = can;
            }
        }
    }
    cout << (int)(ans_wat+ans_sug) << " " << (int)ans_sug << endl;
    return 0;
}


Measured memory_bytes: 3736
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

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

# 入力値を文字列で返却する
def gets_s()
  gets.chomp
end
# S = gets_s

n = gets_i

total = 0

ac, wa, tle, re = 0, 0, 0, 0, 0

n.times do
  s = gets_s
  if s == "AC"
    ac += 1
  elsif s == "WA"
    wa += 1
  elsif s == "TLE"
    tle += 1
  elsif s == "RE"
    re += 1
  end
end

puts "AC x " + ac.to_s
puts "WA x " + wa.to_s
puts "TLE x " + tle.to_s
puts "RE x " + re.to_s


Measured memory_bytes: 14600
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
using P = pair<int, int>;

int n, m;
int dp[101][101];
int a[1001], b[1001], c[1001];


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

    vector<int> a(m), b(m), c(m);
    rep(i, m){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
    }

    const int INF = 1e9;
    rep(i, n){
        rep(j, n) if(i != j) dp[i][j] = INF;
    }

    rep(i, m){
        dp[a[i]][b[i]] = min(dp[a[i]][b[i]], c[i]);
        dp[b[i]][a[i]] = min(dp[b[i]][a[i]], c[i]);
    }

    rep(k, n){
        rep(i, n){
            rep(j, n){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }

    int ans = m;
    rep(i, m){
        bool flag = false;
        rep(j, n){
            if(dp[j][a[i]] + c[i] == dp[j][b[i]]) flag = true;
        }
        if(flag) ans--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
S = sorted(list(map(int, input().split())))
stk = []
tmp = 0
res = 0
passed = 0
for e in S:
    if e <= passed:
        res += 1
        continue
    if tmp == 0:
        tmp = e
    if e == tmp:
        stk.append(e)
    else:
        res += len(stk)
        stk = [e]
        tmp = e
    if tmp == len(stk):
        stk = []
        passed = tmp
res += len(stk)
print(res)

Measured memory_bytes: 15260
# 幅優先探索
# YouTube解説を見てから (https://www.youtube.com/watch?v=1oLDDdWRu6Y&feature=youtu.be)

# queue.Queueよりも、collections.dequeの方が高速だった
# 前者を使うとTLEになっちゃった。。。

from queue import Queue
from collections import deque
from itertools import product
import numpy as np

H, W = map(int, input().split())
S = np.zeros((H, W), dtype='U1')
for hi in range(H):
    raw = input()
    S[hi, :] = list(raw)

maxmove = np.zeros_like(S, dtype='int')

for hi, wi in product(range(H), range(W)):
    # hi, wiをスタート位置とする場合
    if S[hi, wi] == '#': continue

    # 必要な諸々を定義
    # flag = np.zeros_like(S, dtype='int')
    # flag[:] = NOT_VISITED
    # flag[hi, wi] = VISITED
    VisitOrScheduled = np.zeros_like(S, dtype='bool')
    VisitOrScheduled[hi, wi] = True
    nummove = np.zeros_like(S, dtype='int')
    # queue = Queue()
    deq = deque()

    # queue.put((hi, wi))
    deq.append((hi, wi))
    # while queue.empty() == False:
    while True:
        try:
            # hj, wj = queue.get()
            hj, wj = deq.popleft()
        except IndexError:
            break
        # flag[hj, wj] = VISITED
        VisitOrScheduled[hj, wj] = True
        for neighbour in [(hj, wj-1), (hj, wj+1), (hj+1, wj), (hj-1, wj)]:
            if not (0 <= neighbour[0] < H and 0 <= neighbour[1] < W): continue
            if S[neighbour] == '#':
                continue
            # if flag[neighbour] == NOT_VISITED:
            if not VisitOrScheduled[neighbour]:
                nummove[neighbour] = nummove[hj, wj] + 1
                # queue.put(neighbour)
                deq.append(neighbour)
                # flag[neighbour] = SCHEDULED
                VisitOrScheduled[neighbour] = True
    
    maxmove[hi, wi] = np.max(nummove)

print(np.max(maxmove))


Measured memory_bytes: 14488
#include <stdio.h>
#include <stdlib.h>
#define ll long long int
int main(void){
	ll a,b,c,k,ans;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	if(k%2==0)ans=a-b;
	else ans=b-a;
	
	printf("%lld",ans);
	if(ans>1e18) printf("Unfair");
	return 0;
}

Measured memory_bytes: 128
k = int(input())
nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(nums[k-1])

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

#define ll long long int
#define pii pair<int, int>
#define PII pair<ll, ll>
#define llu long long unsigned
#define ld long double

const ll MAX = 1e18 + 100;
const ll Max = 1e9 + 500;

map<ll,ll> mp;


int main()
{
   ll t, i, j, k, p, q, a, b, c, mx, n, m, x, y;
   
   cin>>n>>m;

   ll sum=0;
   mp[0]=1;
   ll ans=0;

   for(i=1;i<=n;i++){
      cin>>x;
      sum=(sum  + x) % m;
      ans+= mp[sum];
      ++mp[sum];
   }

   cout<<ans<<'\n';
   
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    string S; cin>>S;
    if(S=="SRR"||S=="RRS")cout<<2<<endl;
    else if(S=="RRR")cout<<3<<endl;
    else if(S=="SSS")cout<<0<<endl;
    else cout<<1<<endl;
}

Measured memory_bytes: 3596