akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};
 
struct Solver {
  long a, b, c;
  Solver() {
    S002 reader;
    reader >= a >= b >= c;
  }
  void solve() {
    puts(a <= c and b >= c ? "Yes" : "No");
  }
  ~Solver() { fprintf(stderr, "--end--\n"); }
};
 
int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i-- )
int main() {
          
         
         int n;
         cin>>n;
         string s;
         cin>>s;
         int count=0;
         REP(i,0,n-2)
         {
             if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){count++;}
         }
         cout<<count;
    return 0;
}

Measured memory_bytes: 256
N,K=map(int, input().split()) 
R,S,P=map(int, input().split()) 
T=input()
SC=0

def point(w):
    if w=='r':
        return P
    elif w=='s':
        return R
    else:
        return S
    
Flag=[True for i in range(N)]

for i in range(N):
    if Flag[i]:
        SC+=point(T[i])
        if i+K<N and T[i]==T[i+K]:
            Flag[i+K]=False
print(SC)

Measured memory_bytes: 45596
k, t = map(int, input().split())
dat = list(map(int, input().split()))
dat.sort(reverse=True)
prev = -1
res = 0
eat = 0
if len(dat) == 1:
    print(dat[0] - 1)
else:
    dat.sort(reverse=True)
    while dat[1] != 0:
        x = dat[1]
        dat[0] -= x
        dat[1] = 0
        dat.sort(reverse=True)
    if dat[0] == 0:
        print(0)
    else:
        print(dat[0] - 1)


Measured memory_bytes: 38256
// In The Name Of God
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int (a) = (b); (a) < (c); (a)++)
#define setp cout << fixed << setprecision(15)
#define endl "\n"
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define error(x) cerr << #x << " = " << (x) << endl;
#define all(x) (x).begin() , (x).end()


int cnt[300];
char s[30];

int32_t main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string t; cin >> t;
    int n = t.length();
    for2(i,0,n) s[i] = t[i];
    for2(i,0,n) cnt[s[i]-'a'] ++;
    for2(i,0,26) if(!cnt[i]){
        cout << s << char(i+'a') << endl;
        return 0;
    }
    for(int i = n-2; i >= 0; i--) if(s[i] < s[i+1]){
        for2(j,0,i){
            cout << s[j];
            cnt[s[j]-'a']++;
        }
        for2(k,s[i]+1-'a',26) if(cnt[k] != 2){
            cout << char(k+'a');
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to;ll cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

int n,k,d[10];

bool check() {
	int m=n;
	while (m>0) {
		int t=m%10;
		m/=10;
		if(d[t]) return false;
	}
	return true;
}

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

	cin>>n>>k;
	REP(i,k) {
		int m;cin>>m;
		d[m]=1;
	}
	while (true) {
		if(check()) {
			cout<<n<<endl;
			return 0;
		}
		n++;
	}

	return 0;
}


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

using namespace std;

int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3632
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val A, B = sc.nextLong
    val startA = if (A >= 4) ((A - 1) / 4) * 4 else 0
    val startB = if (B >= 4) (B / 4) * 4 else 0
    var xorA = 0L
    for (i <- startA to A - 1) {
      xorA = xorA ^ i
    }
    var xorB = 0L
    for (i <- startB to B) {
      xorB = xorB ^ i
    }
    val result = xorA ^ xorB
    println(result)
  }
}

Measured memory_bytes: 27588
N, X, M = map(int, input().split())

mods = set()
modlist = []
a = X

mods.add(a % M)
modlist.append(a % M)

S = 0
while True:
    a = (a * a) % M

    if a == 0:
        print(sum(modlist))
        exit()

    if a in mods:
        S = modlist.index(a)
        break
    else:
        mods.add(a)
        modlist.append(a)

K = len(mods)
L = K - S
R = (N - S) % L
T = (N - S) // L

if N < K:
    print(sum(modlist[:N]))
    exit()

StartSum = sum(modlist[:S])
LoopSum = sum(modlist[S:K])
RemainSum = sum(modlist[S:][:R])

print(StartSum + LoopSum * T + RemainSum)

Measured memory_bytes: 13448
#include <iostream>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <string>
using namespace std;


int n;
int key[1000];
string str;

char x[60];

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



    for(int i= 0; i < n ; i++)
      cin >> key[i];

    cin >> str;

    int size = str.size();
    //  cout << size <<" ";
    for(int i = 0,j = 0; i < size; i++,j++){
      if(i % n == 0){
	j = 0;
      }      
   
      for(int k = 0; k < key[j] ; k++){
	str[i]--;
	if(str[i]  < 'a' && str[i] > 'Z') str[i] -= 6;
	if(str[i] < 'A' ) str[i] += 52 + 6;

      }
      /*
	if(str[i] - key[j] < 'A' && str[i] <= 'Z' && ){
	str[i] += 52 + 6;
	}else  if(str[i] - key[j] < 'A' && str[i] >= 'a' ){
	str[i] += 52;
	}
	if(str[i] >= 'a' && str[i] - key[j] < 'a' && str[i] - key[j] > 'Z') str[i] -= 6;
	str[i] -= key[j];
	}

      */
          }
    cout << str << endl;
    
  }
  return 0;
  
}

Measured memory_bytes: 1204
#include <iostream>                                             
using namespace std;                                            
                                                                
int main(void) {                                                
  int n, m, l;                                                  
  cin >> n >> m >> l;                                           
  long long a[n][m],b[m][l],c[n][l];                            
                                                                
  for (int i=0; i<n; i++) {                                     
    for (int j=0; j<m; j++) {                                   
      cin >> a[i][j];                                           
    }                                                           
  }                                                             
  for (int i=0; i<m; i++) {                                     
    for (int j=0; j<l; j++) {                                   
      cin>>b[i][j];                                             
    }                                                           
  }                                                             
  for (int i=0; i<n; i++) {                                     
    for (int j=0; j<l; j++) {                                   
      c[i][j]=0;                                                
      for (int k=0; k<m; k++) {                                 
        c[i][j]+=a[i][k]*b[k][j];                               
      }                                                         
    }                                                           
  }                                                             
  for (int i=0; i<n; i++) {                                     
    for (int j=0; j<l; j++) {                                   
      cout<<c[i][j];                                            
      if (j!=l-1) {                                             
        cout << " " << flush;                                   
      }                                                         
    }                                                           
    cout << endl;                                               
  }                                                             
  return 0;                                                     
}                                    

Measured memory_bytes: 3328
import java.io.*;
import java.util.*;
public class Main
{
	private void solve()throws IOException
	{
		int n=nextInt();
		int k=nextInt();
		long ans=0;
		//dp[i] is the number of ways in which sequence gcd is multiple of i
		long dp[]=new long[k+1];
		for(int i=k;i>=1;i--)
		{
			long curr=(modpow(k/i,n)-dp[i]+mod)%mod;
			for(int j=2;j*j<=i;j++)
				if(i%j==0)
				{
					dp[j]=(dp[j]+curr)%mod;
					if(j*j!=i)
						dp[i/j]=(dp[i/j]+curr)%mod;
				}
			if(i!=1)
				dp[1]=(dp[1]+curr)%mod;
			ans=(ans+(i*curr)%mod)%mod;
		}
		out.println(ans);
	}
	final long mod=(long)(1e9+7);
	long modpow(long a,long b){
	    long ret=1;
	    while(b!=0)
	    {
	        if(b%2==1)
	            ret=(ret*a)%mod;
	        a=(a*a)%mod;
	        b=b/2;
	    }
	    return ret;
	} 

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

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

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 IN cin >>
#define OUT cout <<
long long int N,K,ans;
long long int com = 99999999999999;
int main() {
	
	IN N >> K;
	long long int high[1000000]
		; REP(i, N)IN high[i];
	sort(high, high + N, greater<>());
	REP(i, N - K) {
if (com > high[i] - high[i + K - 1]){
ans = high[i] - high[i + K - 1];
com = high[i] - high[i + K - 1];
}
	}
sort(high, high + N);
	REP(i, N - K) {
if (com > abs(high[i] - high[i + K - 1])){
ans = abs(high[i] - high[i + K - 1]);
com = high[i] - high[i + K - 1];
}
}

OUT ans;
	return 0;
}

Measured memory_bytes: 3072
// written at 13:52 on 8 Feb 2017 
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <complex>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector> 
#include <utility>
#include <bitset>

#define IOS std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr);
// #define __DEBUG__
#ifdef __DEBUG__
	#define DEBUG(...) printf(__VA_ARGS__)
#else
	#define DEBUG(...)
#endif
#define filename ""
#define setfile() freopen(filename".in", "r", stdin); freopen(filename".ans", "w", stdout);
#define resetfile() freopen("/dev/tty", "r", stdin); freopen("/dev/tty", "w", stdout); system("more " filename".ans");
#define rep(i, j, k) for (int i = j; i < k; ++i)
#define irep(i, j, k) for (int i = j - 1; i >= k; --i)

using namespace std;

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

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

const double pi = acos(-1.0);
const int INF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = 1e2;
const double g = 9.8;
const double EPS = 1e-10;

int N, V, X, Y;
int L[MAX_N], B[MAX_N], R[MAX_N], T[MAX_N];

double calc(double vy, double t) {
	return vy * t - g * sqr(t) / 2;
}
int cmp(double lb, double ub, double a) {
	return a < lb + EPS ? -1 : a > ub - EPS ? 1 : 0;
}

bool check(double qx, double qy) {
	double a = sqr(g) / 4, b = g * qy - sqr(V), c = sqr(qx) + sqr(qy);
	double D = sqr(b) - 4 * a * c;
	if (D < 0 && D > -EPS) D = 0;
	if (D < 0) return false;
	for (int d = -1; d <= 1; d += 2) {
		double t2 = (-b + d * sqrt(D)) / (2 * a);
		if (t2 <= 0) continue;
		double t = sqrt(t2);
		double vx = qx / t, vy = (qy + g * sqr(t) / 2) / t;

		double yt = calc(vy, X / vx);
		if (yt < Y - EPS) continue;

		bool ok = true;
		rep(i, 0, N) {
			if (L[i] >= X) continue;
			if (R[i] == X && Y <= T[i] && B[i] <= yt) ok = false;
			int yL = cmp(B[i], T[i], calc(vy, L[i] / vx));
			int yR = cmp(B[i], T[i], calc(vy, R[i] / vx));
			int xH = cmp(L[i], R[i], vx * (vy / g));
			int yH = cmp(B[i], T[i], calc(vy, vy / g));
			if (xH == 0 && yH >= 0 && yL < 0) ok = false;
			if (yL * yR <= 0) ok = false;
		}
		if (ok) return true;
	}
	return false;
}

void solve() {
	rep(i, 0, N) R[i] = min(R[i], X);
	bool ok = check(X, Y);
	rep(i, 0, N) {
		ok |= check(L[i], T[i]);
		ok |= check(R[i], T[i]);
	}
	puts(ok ? "Yes" : "No");
}
int main(int argc, char const *argv[])
{
	scanf("%d%d%d%d", &N, &V, &X, &Y);
	rep(i, 0, N) scanf("%d%d%d%d", L + i, B + i, R + i, T + i);
	solve();
	return 0;
}

Measured memory_bytes: 3160
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;

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

const ll INF = 1e9;
/////////////////////////////////////////////////////////////////////////////////////////

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

    vector<ll> dp(n+1);
    fill(dp.begin(),dp.end(),INF);
    dp[0] = 0;
    for (int i = 0;i < n;i++){
        if (i+1 < n){
            dp[i+1] = min(dp[i+1],dp[i] + abs(h[i]-h[i+1]));
        }
        
        if (i+2 < n){
            dp[i+2] = min(dp[i+2],dp[i] + abs(h[i]-h[i+2]));
        }
    }

    cout << dp[n-1] << endl;
}

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

int main()
{
    ll K; cin >> K;

    ll x = 7 % K;

    for (int i = 1; i <= K; ++i) {
        if (x == 0) {
            cout << i << endl;
            exit(0);
        }

        x = (x * 10 + 7) % K;
    }
    cout << -1 << endl;
    




}


Measured memory_bytes: 3632
TMP=input().split()
N=int(TMP[0])
K=int(TMP[1])
Q=int(TMP[2])

sanka=[0] * N

for i in range(0, Q):
  A=int(input())
  sanka[A-1]+=1

for i in range(0, N):
  if (K-Q+sanka[i])>0:
    print ('Yes')
  else:
    print ('No')
  

Measured memory_bytes: 4680
#include <iostream>
using namespace std;
int A[3] = {};
void conf(char a){
  if(a == 'a') A[0]++;
  else if(a == 'b') A[1]++;
  else A[2]++;
}

int main(){
  char c[3];
  for(int i = 0; i < 3; i++){
    cin >> c[i];
    conf(c[i]);
  }
  if(A[0] == 1 && A[1] == 1 && A[2] == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
  


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

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

use std::cmp::{min, max};

fn main() {
    let a = read::<i32>();
    let b = read::<i32>();
    let c = read::<i32>();
    let op = a+b+c;
    let mut m = max(a, max(b, c));

    if op%2 != (3*m)%2 {
        m+=1;
    }

    println!("{}", (3*m - (op))/2);
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

int N;
int A[555][555];
int S[555][555];

int neg[555][555];

int sum(int a,int b,int c,int d){
    return S[b][d]-S[b][c]-S[a][d]+S[a][c];
}

const int INF=1001001001001001001;
int dp[555][555];
signed main(){
    scanf("%lld",&N);
    rep(i,N){
        rep(j,i)scanf("%lld",&A[i][j]);
        for(int j=i+1;j<N;j++)scanf("%lld",&A[i][j]);
    }

    rep(i,N)rep(j,N){
        S[i+1][j+1]=A[i][j]+S[i+1][j]+S[i][j+1]-S[i][j];
    }

    for(int i=N-1;i>=0;i--){
        for(int j=i+1;j<=N;j++){
            neg[i][j]=neg[i+1][j]+sum(i,i+1,i+1,j);
        }
    }

    fill_n(*dp,555*555,INF);
    for(int i=1;i<=N;i++)dp[0][i]=neg[0][i];
    for(int i=0;i<N;i++){
        for(int j=i+1;j<=N;j++){
            for(int k=j+1;k<=N;k++){
                chmin(dp[j][k],dp[i][j]+neg[j][k]+sum(j,k,0,i));
            }
        }
    }

    int ans=INF;
    for(int i=0;i<N;i++)chmin(ans,dp[i][N]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    std::string s;
    std::cin >> s;
    std::sort(s.begin(), s.end());
    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long int n,i,sum=0;
	cin>>n;
	i=n;
	while(n)
	{
		sum+=(n%10);
		n/=10;
	}
	if(i%sum==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>

int isSame(const int *A,const int *B)
{
	int p1, p2, t1, t2, f1, f2, e, h;

	h = 0;
	for (p1 = 0; p1 < 6; p1++)
	{
		if (A[0] == B[p1] && A[5] == B[5 - p1])
		{
			h = 1;
			break;
		}
	}
	if (!h) return 0;

	h = 0;
	for (p2 = 0; p2 < 6; p2++)
	{
		if (p2 == p1 || p2 == 5 - p1) continue;
		if (A[1] == B[p2] && A[4] == B[5 - p2])
		{
			h = 1;
			break;
		}
	}
	if (!h) return 0;

	t1 = p1 / 3;
	t2 = t1 > 0 ? 3 - (t1 + p1 % 3) : p1 % 3;
	f1 = p2 / 3;
	f2 = f1 > 0 ? 3 - (f1 + p2 % 3) : p2 % 3;

	e = t1 ^ f1;
	e = f2 - (t2 + 1) % 3 != 0 ? !e * 3 : e * 3;
	e += e > 0 ? (t2 + f2) - 1 : 3 - (t2 + f2);
		
	if (A[2] != B[e] || A[3] != B[5 - e]) return 0;

	return 1;	
}

int main()
{
	int n, i, j, f;
	int **p;

	scanf("%d", &n);

	p = (int**)malloc(sizeof(int*) * n);
	for (i = 0; i < n; i++)
	{
		p[i] = (int*)malloc(sizeof(int) * 6);
		for (j = 0; j < 6; j++) scanf("%d", &p[i][j]);
	}

	f = 1;
	for (i = 0; i < n - 1; i++)
	{
		for (j = i + 1; j < n; j++)
		{
			if (isSame(p[i], p[j]))
			{
				f = 0;
				break;
			}
		}
		if (!f) break;
	}

	if (f) printf("Yes\n");
	else printf("No\n");
	
	for (i = 0; i < n; i++) free(p[i]);
	free(p);

	return 0;

}

Measured memory_bytes: 1820
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    int n;cin >>n;
    map<string,int> mp;
    int ans = 0;
    rep(i,n){
        string s;cin >> s;
        sort(s.begin(),s.end());
        ans += mp[s];
        mp[s]++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
S = input()
chars = list(map(lambda c: ord(c)-97, S))
if len(chars)!=26:
    chars = sorted(chars)
    i = 0
    while i==chars[i]:
        i += 1
        if i==len(chars):
            break
    ans = S + chr(i+97)
else:
    prev = -1
    i = 0
    for c in reversed(chars):
        if prev < c:
            i += 1
            prev = c
        else:
            break
    if i==26:
        ans = -1
    else:
        max_s = chars[-i-1]
        min_c = 27
        for c in chars[-i:]:
            if c>max_s and c<min_c:
                min_c = c
        ans = S[:-i-1] + chr(min_c+97)

print(ans)



Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

int main() {
    int X;
    cin >> X;
    cout << 8 - (X - 400) / 200 << endl;
    return 0;
}

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

int slide(vector<vector<int>>& v, int retu) {
    int rc = 0;
    vector<int> remove;
    for (int i = 0; i < 3; i++) {
        int right = i;
        while (v[retu][i] == v[retu][right + 1] && v[retu][i] != 0 && right < 4) {
            right++;
        }
        if (right - i + 1 >= 3) {
            rc += (right - i + 1) * v[retu][i];
            for (int rRetu = retu; rRetu >= 0; rRetu--) {
                for (int j = i; j <= right; j++) {
                    if (rRetu == 0) {
                        v[0][j] = 0;
                    } else {
                        v[rRetu][j] = v[rRetu - 1][j];
                    }
                }
            }
            return rc;
        }
    }
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (1) {
        int H;
        cin >> H;
        if (!H) break;
        vector<vector<int>> field(H, vector<int>(5, 0));
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < 5; j++) {
                int res;
                cin >> res;
                field[i][j] = res;
            }
        }
        int ans = 0;
        for (int i = 0; i < H * 3 * 3; i++) {
            for (int i = 0; i < H; i++) {
                int res = slide(field, i);
                ans += res;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
ll f[4000001], invf[4000001];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(x<y) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    int n, k; cin>>n>>k;
    if(k==1){
        cout<<1<<endl;
        return 0;
    }
    fac(n*k);
    ll dp[2003][2003]={};
    dp[1][0]=1;
    for(int i=1; i<=n; i++){
        for(int j=i-1; j<=n; j++){
            if(j<n){
                dp[i][j+1]+=dp[i][j]*comb(j*(k-1)+i-1+k-2, k-2);
                dp[i][j+1]%=MOD;
            }
            if(j>=i){
                dp[i+1][j]+=dp[i][j];
                dp[i+1][j]%=MOD;
            }
        }
    }
    cout<<dp[n][n]*f[n]%MOD<<endl;
    return 0;
}

Measured memory_bytes: 94080
n, x, y, z = map(int,input().split())
mod = 10 ** 9 + 7
forbit = (1<<(x + y + z -1)) + (1<<(y + z -1 )) + (1<<(z -1))
mask = ((1<<(x+y+z)) -1)
l1 = set()
for i in range(mask + 1):
    if i & forbit:
        l1.add(i)
d = [[0] * (mask + 1) for i in range(n + 1)]
d[0][0] = 1
for j in range(n):
    for i in range(mask + 1):
        for k in range(10):
            t = ((i <<(k + 1)) | 1<<k) & mask
            if (t & forbit) == forbit:
                continue
            d[j + 1][t] += d[j][i]
            d[j + 1][t] %= mod
answer = (10 ** n) % mod
for i in range(mask + 1):
    answer -= d[n][i]
    answer %= mod
print(answer)


Measured memory_bytes: 89064
#include <iostream>
#include <string>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main(){
    string s;
    int n = 0, m = 0;
    cin >> s;
    rep(i,3){
        if(s[i] == 'A') n++;
        else if (s[i] == 'B') m++;
    }   
    if(n > 0 && m > 0){
        cout << "Yes" << endl;
    } else if (n == 0 || m == 0){
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
a,b,d = [int(x) for x in input().split()] 
f = []
sum = 0

for i in range(a,(a+d)):
    sum = i
    if sum >b:
        break
    #print(sum)

    f.append(sum)

for j in range(b,(b-d),-1):
    sum=j
    if sum<a:
        break
    if sum not in f:
        f.append(sum)

f.sort()
for x in range(len(f)):
    print(f[x])         




Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
#include <cmath>
#include <iomanip> //setprecision(2)
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
        ll k,a,b;
        cin >> k >> a >> b;
        ll ans=1;
        if(a>=b-2) {
                cout << ans+k <<endl;
        }else{
                while(k>0) {
                        if(a<=ans&&k>=2) {
                                ans-=a;
                                ans+=b;
                                k-=2;
                        }else{
                                ans++;
                                k--;
                        }
                }
                cout << ans << endl;
        }



}


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

#define db(x) if(debug) cout << x << endl

long long N;

bool debug = false;



using namespace std;

set < long long > possible;

int simulate(long long x, long long k){

	while(x >= k){
		if(x % k == 0){
			x = x / k;
		}	
		else{
			x = x % k;
		}

	}
	if(x == 1)	return 1;
	return 0;
}


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

	cin >> N;

	long long ans = 0;

	if(N == 2){
		cout << 1 << endl;
		return 0;
	}


	for(long long i = 1; i <= sqrt(N); i++){
		possible.insert(i);
		if(N % i == 0){
			possible.insert(N / i);
		}
		if((N-1) % i == 0){
			possible.insert((N-1) / i);
		}
	}



	for(long long i : possible){
		if(i == 1)	continue;
		if(simulate(N, i) == 1){
			db(i);
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    map<string, int> m;
    int n;
    cin >> n;
    int mx = 0;
    rep(i, n) {
        string s;
        cin >> s;
        m[s]++;
        mx = max(m[s], mx);
    }
    for (auto p: m) {
        if (p.second == mx)
            cout << p.first << endl;
    }
    return 0;
}


Measured memory_bytes: 25216
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>

using namespace std;

int main(){
	int n,m,c=1;
	vector<int> key[31];
	map<int,int> data;
	while(scanf("%d,%d",&n,&m),n||m)key[m].push_back(n);
	for(int i=30;i>=0;i--){
		if(key[i].size()){
			for(int j=0;j<key[i].size();j++)data[key[i][j]]=c;
			c++;
		}
	}
    int l;
	while(cin>>l)cout<<data[l]<<endl;
    
    return(0);
}

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


using namespace std;


int main() {
    string S, T;
    cin >> S >> T;
    int ans = 1001;
    for (int i = 0; i <= S.size() - T.size(); i++) {
        int dis = 0;
        for (int p = 0; p < T.size(); p++) {
            if (S[p + i] != T[p]) {
                dis++;
            }
        }
        ans = min(dis, ans);
    }
    cout << ans << endl;
}


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

int main(){
    int a;
    int b;
    
    cin>>a>>b;
    if (1<=a && a<=9 && 1<=b && b<=9){
        cout<<a*b<<endl;
    }else{
        cout<<"-1"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 310000;
vi e[maxn];
int d[maxn][2], dup[maxn];
int rad[maxn];
int dth[maxn];
string s;

void add(int *m, int x) {
    forn(i, 2) if (x > m[i]) swap(x, m[i]);
}

int max_exc(int *m, int x) {
    forn(i, 2) {
        if (m[i] == x) x = -1;
        else return m[i];
    }
    return -1;
}

void dfs_d(int v, int p) {
    for (int u: e[v]) {
        if (u == p) continue;
        dfs_d(u, v);
        add(d[v], max_exc(d[u], -1) + 1);
    }
}

void dfs_up(int v, int p, int D) {
    dup[v] = D;
    for (int u: e[v]) {
        if (u == p) continue;
        dfs_up(u, v, max(D, max_exc(d[v], d[u][0] + 1) + 1) + 1);
    }
}

i64 ans;

int dfs_C(int v, int p) {
    dth[v] = 0;
    int minq = s[v] == '1' ? 0 : 1e9;
    for (int u: e[v]) {
        if (u == p) continue;
        uin(minq, dfs_C(u, v) - 1);
        uax(dth[v], dth[u] + 1);
    }
    int sk = max(0, min(rad[v] - 1, dth[v] + 1) - minq + 1);
    //uin(sk, rad[v] - 1);
    ans += sk;
    minq += sk;
    if (minq == rad[v]) minq = 1e9;
    return minq;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    forn(i, n - 1) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        e[x].pb(y);
        e[y].pb(x);
    }
    cin >> s;
    forn(i, n) forn(j, 2) d[i][j] = -1;
    dfs_d(0, -1);
    dfs_up(0, -1, -1e9);
    forn(i, n) rad[i] = max(dup[i], max_exc(d[i], -1) + 1);
    int C = 0;
    forn(i, n) if (rad[i] < rad[C]) C = i;
    ans = 1;
    dfs_C(C, -1);
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 27536
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner read = new Scanner(System.in);
        int[] x = new int[5];
        for(int i=0; i<5; i++){
            x[i] = read.nextInt();
            if(x[i] == 0){
                System.out.println(i+1);
                break;
            }
        }
    }
}


Measured memory_bytes: 35704
#include <bits/stdc++.h>
#include <iostream>
#include <vector>

#define FOR(i, a, b) for (int i = a; (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<int>;
using vvi = vc<vi>;

using ll = long long;


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

    int count = 0;
    while (true) {
        string s;
        cin >> s;
        if (s == "END_OF_TEXT") break;
        REP(i, int(s.size())) s[i] = tolower(s[i]);
        if (s ==  W) ++count;
    }

    cout << count << "\n";

    return 0;
}



Measured memory_bytes: 3200
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    s = str(input().rstrip('\n'))
    s = list(map(str, s.replace("><", ">_<").split("_")))
    cnt = 0
    for v in s:
        a = 0
        b = 0
        for i in range(len(v)):
            if v[i] == "<":
                a += 1
            else:
                b += 1
        if a != 0 and b != 0:
            cnt += (a - 1) * (1 + a - 1) // 2 + (b - 1) * (1 + b - 1) // 2
            cnt += max(a, b)
        elif b != 0:
            cnt += b * (1 + b) // 2
        elif a != 0:
            cnt += a * (1 + a) // 2
    print(cnt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 58464
#include<stdio.h>
#include<stdlib.h>
#define SENTINEL 1000000000

int count=0;

void merge(int A[],int left,int mid,int right){
  int a,b,i,j,k;
  int *L,*R;
  a=mid-left;
  b=right-mid;
  L=(int *)malloc(sizeof(int)*(a+1));
  R=(int *)malloc(sizeof(int)*(b+1));

  for(i=0;i<=a-1;i++){
    L[i]=A[left+i];
  }

  for(j=0;j<=b-1;j++){
    R[j]=A[mid+j];
  }

  L[a]=SENTINEL;
  R[b]=SENTINEL;
  i=0;
  j=0;

  for(k=left;k<=right-1;k++){
   if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      count++;
    }
    else{
      A[k]=R[j];
      j++;
      count++;
    }
  }

  free(L);
  free(R);
}

void mergeSort(int A[],int left,int right){
  int i,mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
  int A[500000];
  int n,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  mergeSort(A,0,n);

  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1)printf(" ");
  }
  
  printf("\n");
  printf("%d\n",count);
  return 0;
}


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

int search(vector<int>& S, int T)
{
	int i = 0;
	S.push_back(T);
	while (S.at(i) != T) i++;
	S.pop_back();

	return i != S.size();
}

int main(void) {

	int N, Q, T;
	cin >> N;
	vector<int> S(N);
	for (int i = 0; i < N; i++) cin >> S.at(i);

	int ans = 0;
	cin >> Q;
	for (int i = 0; i < Q; i++)
	{
		cin >> T;
		if (search(S, T)) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3144
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String word = input.readLine();
        int largest = 0;
        for (int i = word.length() - 1; i > 1; i--) {
            if (i % 2 == 0) {
                int midle = i / 2;
                boolean state = true;
                for (int j = 0; j < i / 2; j++, midle++) {
                    if (word.charAt(j) != word.charAt(midle)){
                        state = false;
                        break;
                    }
                }
                if (state)
                    largest = Math.max(largest, i);
            }
        }
        System.out.println(largest);
    }
}


Measured memory_bytes: 22356
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;

ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}


// verified
//   https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_B
void AOJ_NTL_1_B() {
    ll m, n;
    cin >> m >> n;
    cout << pow_mod(m, n, MOD) << "\n";
}

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


Measured memory_bytes: 3088
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    n: usize,
    }
    let ans =  n * (n + 1) / 2 - n;
    println!("{}", ans);
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val x = sc.nextLong()

        // 5,6,
        val d = x / 11
        val m = x % 11
        var ans = d * 2
        ans += when {
            m == 0L -> 0
            m <= 6 -> 1
            else -> 2
        }
        println(ans)
    }
}


class MyScanner() {
    private var index = 0
    private var line = listOf<String>()

    fun next(): String {
        while (line.size <= index) {
            line = readLine()!!.split(' ')
            index = 0
        }
        return line[index++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun strList(): List<String> {
        index = line.size
        return readLine()!!.split(' ')
    }

    fun intList() = strList().map { it.toInt() }
    fun longList() = strList().map { it.toLong() }
    fun doubleList() = strList().map { it.toDouble() }
}

Measured memory_bytes: 36344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = int;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

vector<bool> seen;

vector<ll> ans(200010);
vector<set<int>> child(200010);
void dfs(const Graph &G, int v)
{
    seen[v] = true;
    for (auto &&next_v : G[v])
    {
        if (seen[next_v])
            continue;
        ans[next_v] += ans[v];
        dfs(G, next_v);
    }
}
int main()
{

    long long N;
    scanf("%lld", &N);
    long long Q;
    scanf("%lld", &Q);
    Graph G(N);
    std::vector<long long> a(N - 1);
    std::vector<long long> b(N - 1);
    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
    }
    for (int i = 0; i < Q; i++)
    {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    seen.assign(N,false);
    dfs(G, 0);

    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 36736
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long int lli;
const lli mod = 1e9+7;
const lli inf = 1e18;
typedef pair<int ,int> pii;
typedef pair<lli, lli> pll;

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


Measured memory_bytes: 3620
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
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    flag = True
    s = input()
    c = Counter(s)
    values, counts = zip(*c.most_common())
    for i in counts:
        if (i != 2):
            flag = False
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

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

int main(void) {
    string s;
    cin >> s;
    
    int a;
    int z;
    for(int i=0;;i++){
        if(s[i] == 'A') {
            a = i;
            break;
        }
    }

    
    for(int i=s.size()-1;;i--){
        if(s[i] == 'Z') {
            z = i;
            break;
        }
    }

    cout << z - a + 1 << "\n";

    return 0;
}


Measured memory_bytes: 640