akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll inf =1LL << 62;

int main(void){
	while(1){
		vi list,zero;
		vi used,res;
		rep(i,10){
			int tmp;
			cin >> tmp;
			list.pb(tmp);
		}
		//clock_t start,end;
		//start=clock();
		if(list[0]==-1)
			break;

		rep(i,10){
			if(list[i]==0)
				zero.pb(i);
			else
				used.pb(list[i]);
		}
		sort(used.begin(),used.end());

		rep(i,10){
			if(binary_search(used.begin(),used.end(),i+1))
				continue;
			res.pb(i+1);
		}
	//	each(it,res)
	//		cout << *it << endl;
		int ans=0;
		do{
			int n=zero.size();
			rep(i,n)
				list[zero[i]]=res[i];
			bool ok=true;
			if(list[9]==1){
				ans++;
				continue;
			}
			int m=(list[2]+list[5]+list[8])%list[9];
			rep(i,2){
				int x=list[i]+list[i+3]+list[i+6];
				if(x%list[9]!=m)
					ok=false;
			}
			if(!ok)
				continue;
			rep(i,3){
				int x=list[3*i]+list[3*i+1]+list[3*i+2];
				if(x%list[9]!=m)
					ok=false;
			}
			if(!ok)
				continue;
			rep(i,2){
				int x;
				if(i)
					x=list[0]+list[4]+list[8];
				else
					x=list[2]+list[4]+list[6];
				if(x%list[9]!=m)
					ok=false;
			}
			if(!ok)
				continue;
			ans++;
		}while(next_permutation(res.begin(),res.end() ) );
		cout << ans << endl;
		//end=clock();
		//cout << (double)(end - start) / CLOCKS_PER_SEC << endl;
	}
	return 0;
}

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


int N;
vector<ll> A;


void input() {
    cin >> N;
    A = vector<ll>(N);
    rep(i, N) cin >> A[i];
}


int main() {
    input();
    auto x = min_element(A.begin(), A.end());
    ll next_min = *x;
    int next_i = distance(A.begin(), x);
    ll min_x;
    while (next_min != INF) {
        min_x = next_min;
        int min_i = next_i;
        next_min = INF;
        rep(i, N) {
            if (i == min_i) continue;
            A[i] = A[i] % min_x;
            if ((A[i] > 0) & (A[i] < next_min)) {
                next_min = A[i];
                next_i = i;
            }
        }
    }
    cout << min_x << endl;
}


Measured memory_bytes: 1024
# encoding:utf-8
import sys

def main():
	n = int(input())
	str1 = input()
	str2 = input()

	ptrn = []
	i = 0
	while True:
		if str1[i] == str2[i]:
			ptrn.append("t")
			i += 1
		else:
			ptrn.append("y")
			i += 2
		if i >= n:
			break
	
	#print(ptrn)

	if ptrn[0] == "t":
		n_ptrn = 3
	else:
		n_ptrn = 6

	for i in range(1, len(ptrn)):
		#print(n_ptrn)
		if ptrn[i - 1] == "t" and ptrn[i] == "t":
			n_ptrn = n_ptrn * 2
		elif ptrn[i - 1] == "t" and ptrn[i] == "y":
			n_ptrn = n_ptrn * 2
		elif ptrn[i - 1] == "y" and ptrn[i] == "y":
			n_ptrn = n_ptrn * 3

	print(n_ptrn % 1000000007)



if __name__ == '__main__':
	main()

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

int main()
{
    int n;
    stack<int> st;
    
    while(cin>>n)
    {
        if(n){ 
            st.push(n);
        }else{
            cout << st.top() << endl;
            st.pop();
        }
    }

    return 0;
}

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

int main(){
  int H,W;
  while(1){
    cin >> H >> W ;
    if(H == 0 && W == 0 )
      break;

    for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
        if(i==1 || i==H || j==1 || j==W){
          cout << "#" ;
        }else{
          cout << "." ;
        }
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3104
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}
int power(int x,int y)
{
	int res=1;
	while(y)
	{
		if(y&1)
			res=res*x;
		x=x*x;
		y=y>>1;
	}
	return res;
}
int main()
{      
 
  int n,m,i,j,t;
  cin>>n;
  vi coins;
  for(i=0;i<=6;i++)
  {
  	coins.pb(power(6,i));
  	if(i>0)
  		coins.pb(power(9,i));
  }
  coins.pop_back();
  
  int dp[n+1];
  for(i=0;i<=n;i++)
  	dp[i]=inf;
  dp[0]=0;
  
  for(i=0;i<=n;i++)
  {
  	for(j=0;j<coins.size();j++)
  	{
  		if(i>=coins[j] && dp[i-coins[j]]!=inf && dp[i-coins[j]]+1<dp[i])
  		{
  			dp[i]=dp[i-coins[j]]+1;
  		}
  	}
  }
  cout<<dp[n];
  return 0;
}

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


int main()
{
	typedef long l;
	l n,k,x,y;  cin>>n>>k>>x>>y;
	
	if(n<=k)   cout<<n*x<<endl;
	
	else  cout<<k*x+(n-k)*y<<endl;

}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cmath>
#include <unistd.h>
#include <vector>
#include <queue>
#include <stack>
#define PI 3.14159265358979323846

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	vector<int> vet;
	int k, aux;

	for(int i=0;i<5;i++)
	{
		cin >> aux;
		vet.push_back(aux);
	}
	cin >> k;

	sort(vet.begin(), vet.end());

	if(vet[4]-vet[0]>k)
		cout << ":(\n";
	else
		cout << "Yay!\n";


	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();

int main() {
	int n; cin >> n;
	COUT(pow(n, 3));
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}


Measured memory_bytes: 384
sx,sy,tx,ty = list(map(int, input().strip().split()))
dx = tx-sx
dy = ty-sy
result = ""
for i in range(dy):
  result += "U"
for i in range(dx):
  result += "R"
for i in range(dy):
  result += "D"
for i in range(dx):
  result += "L"
result += "L"
  
for i in range(dy+1):
  result += "U"
for i in range(dx+1):
  result += "R"
result += "DR"
for i in range(dy+1):
  result += "D"
for i in range(dx+1):
  result += "L"
result += "U"
print(result)

Measured memory_bytes: 43356
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static long H;
        static long W;
        static String[] map;
        static void Main(string[] args)
        {
            //var K = long.Parse(Console.ReadLine());
            //var S = Console.ReadLine();
            var ABHM = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
            var A = ABHM[0];
            var B = ABHM[1];
            var H = ABHM[2];
            var M = ABHM[3];

            var hourx = Cos(((60*H+M) / 720) * (2 * PI)*(-1)+(0.5*PI)) * A;
            var houry = Sin(((60 * H + M) / 720) * (2 * PI) * (-1) + (0.5 * PI)) * A;
            var minux = Cos((M / 60) * (2 * PI) * (-1) + (0.5 * PI)) * B;
            var minuy = Sin((M / 60) * (2 * PI) * (-1) + (0.5 * PI)) * B;


            Console.WriteLine(getDistance(hourx, houry, minux, minuy));
        }

        static public double getDistance(double x, double y, double x2, double y2)
        {
            double distance = Math.Sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));

            return distance;
        }


    }

}


Measured memory_bytes: 19744
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
#include <atcoder/segtree>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
#define rreps(i, s, n) for (int i = (int)n - 1; (int)(s) <= i; --i)
// reps(s,n)[::-1]
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;
class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* _sep, const char* _term) : sep(_sep), term(_term) {}
        template <class... Args> void operator()(const Args&... args) const { print(args...); }
        template <typename T> void pvec(const T& vec, size_t sz) const {
            for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
        }
        template <typename T> void pmat(const T& mat, size_t h, size_t w) {
            for (size_t i = 0; i < h; i++)
                for (size_t j = 0; j < w; j++) std::cout << mat[i][j] << (j == w - 1 ? term : sep);
        }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail> void print(const T& head, const Tail&... tail) const {
            std::cout << head, print_rest(tail...);
        }
        template <class T, class... Tail> void print_rest(const T& head, const Tail&... tail) const {
            std::cout << sep << head, print_rest(tail...);
        }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints print;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return 0;
}

void solve() {
    int n, k, a, v, le, ri;
    cin >> n >> k;
    atcoder::segtree<int, op, e> seg(300005);
    rep(i, n) {
        cin >> a;
        le = max(0, a - k);
        ri = min(300000, a + k) + 1;
        v = seg.prod(le, ri);
        seg.set(a, v + 1);
        // print()(a, seg.all_prod());
    }
    print()(seg.all_prod());
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 8464
#include <bits/stdc++.h>
using namespace std;
const int maxn=3005;
long long c[maxn][maxn],s2[maxn][maxn];
int read(){
    int x=0,y=1;
    char ch=getchar();
    while(ch<48||ch>57){if(ch==45)y=-1;ch=getchar();}
    while(ch>=48&&ch<=57)x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*y;
}
long long power(long long x,long long b,long long mod){
	long long ans=1;
	while(b){
		if(b&1)ans=ans*x%mod;
		x=x*x%mod;
		b>>=1;
	}
	return ans;
}
int main(){
//    freopen("AT4119.in","r",stdin);
//    freopen("AT4119.out","w",stdout);
   	int n,m;
	n=read();m=read();
	c[0][0]=1;
	for(int i=1;i<=n;i++){
		c[i][0]=1;
		for(int j=1;j<=i;j++)
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%m;
	}
	s2[0][0]=1;
	for(int i=1;i<=n+1;i++){
		s2[i][0]=0;
		for(int j=1;j<=i;j++)
			s2[i][j]=(s2[i-1][j]*j%m+s2[i-1][j-1])%m;
	}
	long long ans=0,op=1;
	for(int i=0;i<=n;i++){
		long long cur=c[n][i]*power(2,power(2,n-i,m-1),m)%m;
		long long sum=0;
		for(int j=0;j<=i;j++)
			sum=(sum+s2[i+1][j+1]*power(2,j*(n-i),m)%m)%m;
		ans=(ans+op*cur*sum%m+m)%m;
		op=-op;
	}
	printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 95976
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int result = 0;
		
		int j = 0;
		
		
		
		for (int waku = 1; waku < 28 && result == 0; waku++){
			j = 0;
			for (int i = waku; i >= 0 && result == 0; i--){
				
				if (n == i * 4 + j * 7){
					result = 1;
				}
				
				j++;
			}
		}
		
		
		
		if (result == 1){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
typedef unsigned long long int ull;

using namespace std;

int main(void){
  ull N,size=0,count=0;
  cin >> N;
  ull ans=N;
  ull A[N];
  rep(i,N) cin >> A[i];
  sort(A,A+N);
  rep(i,N-1){
    size+=A[i];
    if(size*2<A[i+1]) count=i+1;
  }
  cout << ans-count << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef long long ll;
const int maxn = 200200;
char s[maxn];
int n;
bool no = true;
int main(){
    scanf("%s", s + 1); n = strlen(s + 1);
    if(s[n] != '0') {puts("-1"); return 0;}
    for(int i = 1, j = n - 1; i < j; ++i, --j){
        if(s[i] != s[j]) {puts("-1"); return 0;}
    }
    rep(i, n) no &= (s[i] == '0');
    if(no) {puts("-1"); return 0;}
    int cur = 1;
    for(int i = 2; i <= n; ++i){
        printf("%d %d\n", cur, i);
        if(s[i-1] == '1') cur = i;
    }
    return 0;
}

Measured memory_bytes: 1536
import sys
sys.setrecursionlimit(10**6)

#a = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
s = input()
t = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

s = [ch for ch in s]
t = [ch for ch in t]

ans = len(t)
if len(s) == len(t):
    tmp = 0
    for i in range(len(t)):
        if s[i] != t[i]:
            tmp += 1
    ans = min(ans, tmp)
else:
    for j in range(len(s)-len(t)):
        tmp = 0
        for i in range(len(t)):
            if s[i+j] != t[i]:
                tmp += 1
        ans = min(ans, tmp)
print(ans)


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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	ll N, A, B; cin >> N >> A >> B;

	ll smin = A * (N - 1) + B;
	ll ssum = A + B * (N - 1);
	cout << max((ll)0, ssum - smin + 1) << endl;

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  long long n,m;
  cin>>n>>m;
  long long rest;
  long long ans;
  if(2*n>=m){//cがやたら少ない時
    cout<<m/2<<endl;
  }else{
    rest = m-2*n;
    ans = n + rest/4;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=10000;

int main(){
	int N;
	cin>>N;
	int ans=0;
	rep(i,N){
		int x;
		cin>>x;
		while(x%2==0){
			ans++;
			x=x/2;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,m,d,a,ans=0;
    cin >> n >> m;
    ll c[n+1]={0};
    while(m--)
    {
        cin >> d;
        while(d--)
        {
            cin >> a;
            c[a]++;
        }
    }
    for(ll i=1;i<=n;i++)
            if(c[i]==0)
               ans++;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  int plan1;
  plan1= A*N;
  if (plan1 >= B) {
    cout << B;
  }
  else {
    cout << plan1;
  }
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

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

int main() {
    int s;
    ll a[2001] = {};
    cin >> s;
    a[0] = 1;
    for (int i = 0; i < s; ++i) {
        for (int j = 3; j <= s - i; ++j) {
            a[i + j] += a[i];
            a[i + j] %= MOD;
        }
    }
    cout << a[s] << endl;

    return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    lint ans = 0;
    for_(k,1,N+1) {
        lint d = N / k;
        ans += d * (d + 1) / 2 * k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
#define INF (1<<20)
#define RESIDUE(s,t) (capacity[s][t]-flow[s][t])
Edges es;
Weight maximumFlow(const Graph &g, int s, int t) {
  int n = g.size();
  Matrix flow(n, Array(n)), capacity(n, Array(n));
  REP(u,n) FOR(e,g[u]) capacity[e->src][e->dst] += e->weight;

  Weight total = 0;
  while (1) {
    queue<int> Q; Q.push(s);
    vector<int> prev(n, -1); prev[s] = s;
    while (!Q.empty() && prev[t] < 0) {
      int u = Q.front(); Q.pop();
      FOR(e,g[u]) if (prev[e->dst] < 0 && RESIDUE(u, e->dst) > 0) {
        prev[e->dst] = u;
        Q.push(e->dst);
      }
    }
    if (prev[t] < 0){
		break;
	}
    Weight inc = INF;
    for (int j = t; prev[j] != j; j = prev[j])
      inc = min(inc, RESIDUE(prev[j], j));
    for (int j = t; prev[j] != j; j = prev[j])
      flow[prev[j]][j] += inc, flow[j][prev[j]] -= inc;
    total += inc;
  }
  vector<int> res;
	for(int i = 0 ; i < es.size() ; i++){
		int x = es[i].src;
		int y = es[i].dst;
		if( flow[x][y] < 0 ){
			res.push_back(i);
		}
	}
	cout << total << endl;
	cout << res.size() << endl;
	for(int i = 0 ; i < res.size() ; i++)
		cout << res[i]+1 << endl;
}


int main(){
	int n,m;
	cin >> n >> m;
	Graph g(n);
	for(int i = 0 ; i < m ; i++){
		int a,b;
		cin >> a >> b;
		a--,b--;
		g[a].push_back(Edge(a,b,1));
		g[b].push_back(Edge(b,a,1));
		es.push_back(Edge(a,b,1));
	}
	int s,t;
	cin >> s >> t;
	s--,t--;
	maximumFlow(g,s,t);
	
}

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

X, Y = map(int, input().split())

for i in range(101):
    n = i
    k = X - i
    if 0 > k or k > 100:
        continue
    if Y == n * 2 + k * 4:
        print('Yes')
        exit()
print('No')
        


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

int main(){
    int h,w;
    cin>>h>>w;
    int arr[h][w];
    int row = 0, col = 0;
    bool right = true;
    int n,k;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>k;
        for(int j=0; j<k;j++){
            arr[row][col] = i;
            if(right==true){
                if(col==w-1){
                    row++;
                    right = false;
                }
                else{
                    col++;
                }
            }
            else{
                if(col==0){
                    row++;
                    right = true;
                }
                else{
                    col--;
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<arr[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int f(int a, int b, int	c) {
  if(b > a && b <= c) return 1;
  if(b > c && b <= a) return 1;
  return 0;
}

int main() {
  int n; cin>>n;
  vector<int> p(n);
  REP(i,n) cin>>p[i];
  int ans = 0;
  for(int i = 2; i < n; i++) {
    ans += f(p[i-2], p[i-1], p[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<string>
#include<algorithm>
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin>>n;
  double a,aInv=0;
    for(int i=0;i<n;i++){
        cin>>a;
        aInv+= 1/a;
    }
    cout<< (1/aInv)<<'\n';
    
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(int i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
int main()
{
       string s;
       cin>>s;
       bool ff = true;
       fri(i,0,s.size()){
              if(i%2){
                     if(s[i]=='R'){
                            ff = false;
                     }
              }
              else{
                     if(s[i]=='L'){
                            ff = false;
                     }
              }
       }
       if(ff){
              cout<<"Yes"<<endl;
       }
       else{
              cout<<"No"<<endl;
       }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	long long int max1= max((a*c),(a*d));
	long long int max2 = max((b*c),(b*d));
	cout<<max(max1,max2)<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n,m;
	lint x;
	cin>>n>>m>>x;
	vector<lint> c(n);
	vector<vector<lint>> a(n, vector<lint>(m));
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(lint &k:a[i])cin>>k;
	}
	
	lint ans = INF;
	
	for(int mas = 0; mas <(1<<n) ;mas++){
		int aux = mas;
		vector<bool> b(n);
		int cont = 0;
		
		while(aux){
			if(aux%2) b[cont] = 1;
			aux /= 2;
			cont++;
		}
		vector<lint> le(m,0);
		lint pre=0;
		for(int i=0;i<n;i++){
			if(b[i]){
				pre += c[i];
				for(int j=0;j<m;j++)
					le[j] += a[i][j];
			}
		}
		bool pos = 1;
		for(int j=0;j<m;j++)
			if(le[j] < x){
				pos = 0; break;
			}
		if(pos) ans = min(ans, pre);

	}
	if(ans == INF)cout<<"-1\n";
	else cout<<ans<<"\n";

	return 0;	
}



Measured memory_bytes: 3608
import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


class UnionFind:
    def __init__(self, size=None, nodes=None):
        """
        size か nodes どっちか指定。
        nodes は set、size は list を使う。
        set の最悪計算量は O(N) なので size 指定のほうが若干速い
        :param int size:
        :param collections.Iterable nodes:
        """
        assert size is not None or nodes is not None
        if size is not None:
            self._parents = [i for i in range(size)]
            self._ranks = [0 for _ in range(size)]
            self._sizes = [1 for _ in range(size)]
        else:
            self._parents = {k: k for k in nodes}
            self._ranks = {k: 0 for k in nodes}
            self._sizes = {k: 1 for k in nodes}

    def unite(self, x, y):
        """
        x が属する木と y が属する木を併合
        :param x:
        :param y:
        :return:
        """
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return

        # rank が小さい方が下
        if self._ranks[x] > self._ranks[y]:
            # x が root
            self._parents[y] = x
            self._sizes[x] += self._sizes[y]
        else:
            # y が root
            self._parents[x] = y
            self._sizes[y] += self._sizes[x]
            if self._ranks[x] == self._ranks[y]:
                self._ranks[y] += 1

    def root(self, x):
        """
        x が属する木の root
        :param x:
        :return:
        """
        if self._parents[x] == x:
            return x
        self._parents[x] = self.root(self._parents[x])
        return self._parents[x]

    def size(self, x):
        """
        x が属する木のノード数
        :param x:
        :return:
        """
        return self._sizes[self.root(x)]


W, H = list(map(int, sys.stdin.readline().split()))
P = [int(sys.stdin.readline()) for _ in range(W)]
Q = [int(sys.stdin.readline()) for _ in range(H)]


def test():
    edges = []
    vs = []
    for h, w in itertools.product(range(H + 1), range(W + 1)):
        if w < W:
            edges.append((P[w], (w, h), (w + 1, h)))
        if h < H:
            edges.append((Q[h], (w, h), (w, h + 1)))
    for h, w in itertools.product(range(H + 1), range(W + 1)):
        vs.append((w, h))
    edges.sort()

    # kruskal
    uf = UnionFind(nodes=vs)
    ret = 0
    for s, v, u in edges:
        if uf.root(v) != uf.root(u):
            uf.unite(v, u)
            ret += s
    return ret


# 横棒
hs = P.copy()
# 縦棒
vs = Q.copy()

hs.sort(reverse=True)
vs.sort(reverse=True)

ans = 0
v_nodes = W + 1
h_nodes = H + 1
while hs or vs:
    if not vs or (hs and hs[-1] < vs[-1]):
        # 横棒を使う
        # まだくっつけてない横軸の数だけ辺を張る
        ans += hs.pop() * h_nodes
        v_nodes -= 1
    else:
        # 縦棒のが短い
        ans += vs.pop() * v_nodes
        h_nodes -= 1
print(ans)

# print(test())


Measured memory_bytes: 13080
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};
ll n, a, b, c, d;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> a >> b >> c >> d;
    rep(t, 0, n) {
      if (c * (n - 1 - t) - d * t <= b - a && b - a <= -c * t + (n - 1 - t) * d)  {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
    return 0;
}



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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
int A, B, C;
ll ret = 0;

void input() {
  IN(A);
  IN(B);
}

void solve() {
  ll ret = max(A+B, max(A-B, A*B));
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define out(i) cout << #i << ' ' << i
#else 
#define out(i)
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
using db = double;
#define int ul
const int maxn = 200001;
int n;
int a[maxn];
map<int,int> cnt;
bool valid(){
	if(cnt.count(0) and cnt.size() == 1)return true;
	if(cnt.size() > 3 || n % 3)return false;
	if(cnt.count(0)){
		if(cnt.size() != 2)return false;
		return cnt[0] == n/3 and cnt.rbegin()->second == n/3*2;
	}
	else{
		vector<int> v;
		for(auto & i : cnt)
			if(i.second != n/3)return false;
			else v.push_back(i.first);
		return ((v[0]^v[1]) == v[2]) || ((v[1]^v[2]) == v[0]) || ((v[0]^v[2]) == v[1]);
	}
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(int i = 0;i < n;++i)cin >> a[i];
	for(int i = 0;i < n;++i)++cnt[a[i]];
	if(valid())cout << "Yes\n";
	else cout << "No\n";
}

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

int main()
{
	unsigned long l, r;
	cin >> l;
	cin >> r;

	unsigned long mi = 2018;
	unsigned long n = r - l + 1;
	unsigned long c = 0;
	unsigned long start = 0;
	for (unsigned long k = 0; k < (n - 1); k++) {
		unsigned long t = n - 1 - start;
		for (unsigned long i = 0; i < t; i++) {
			unsigned long a = (l + start);
			unsigned long b = (l + start + i + 1);
			if (a % 2019 == 0 || b % 2019 == 0) {
				mi = 0;
				goto END;
			}
			mi = min(mi, ((a * b) % 2019));
		}
		start++;
	}
	END:
	cout << mi;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}
func main() {
	var N, An int
	N = nextInt()
	for i := 0; i < N; i++ {
		An = nextInt()
		if An%2 == 1 {
			continue
		}
		if An%3 != 0 && An%5 != 0 {
			fmt.Println("DENIED")
			return
		}
	}
	fmt.Println("APPROVED")
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 32128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
c = input()

n = c.count("R")
ans = 0
for i in range(n):
	if c[i] != "R":
		ans += 1

print(ans)

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

int main() {
  string S;
  cin >> S;
  bool isKaibun = true;
  rep(i, S.size()/2){
    if(S.at(i)!=S.at(S.size()-1-i)) {
      isKaibun = false;
      break;
    }
  }
  if(!isKaibun) {
    cout << "No" << endl;
    return 0;
  }
  rep(i, S.size()/4){
    if(S.at(i)!=S.at(S.size()/2-1-i)) {
      isKaibun = false;
      break;
    }
    if(S.at((S.size()+1)/2+i)!=S.at(S.size()-1-i)) {
      isKaibun = false;
      break;
    }
  }
  if(!isKaibun) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
def f(n):
    d = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            d.append(i)
            if i != n // i:
                d.append(n//i)
    return d

a=[1 for i in range(1,int(input())+1,2) if len(f(i))==8]
print(len(a))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main (int argc, char * const argv[]) {
    // insert code here...
    int w, n, a, b, t;
	char c;
	cin >> w >> n;
	
	vector<int> tate;
	
	for(int i=1;i<=w;i++){
		tate.push_back(i);
	}
	
	for(int i=0;i<n;i++){
		cin >> a >> c >> b;
		t = tate[a-1];
		tate[a-1]=tate[b-1];
		tate[b-1]=t;
	}
	
	for(int i=0;i<w;i++){
		cout << tate[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

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

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

int A=10,B=11,C=12,D=13,E=14,F=15;

int main()
{
	char x,y;
	scanf("%c %c",&x,&y);
	if(x > y) printf(">");
	if(x == y) printf("=");
	if(x < y) printf("<");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    vector<int> x(3);
    rep(i,3) cin >> x[i];
    sort(x.begin(),x.end(),greater<int>());
    cout << x[0]*10+x[1]+x[2];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#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 int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

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



signed main(){

    int N, i;
    cin >> N >> i;
    cout << N - i + 1;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a[][];
		int b[];
		int index;
		String st;
		
		a = new int[8][8];
		b = new int[4];
		while (sc.hasNext()) {
			index = 0;
			for (int i = 0; i < 8; i++) {
				st = sc.next();
				for (int j = 0; j < 8; j++) {
					a[i][j] = st.charAt(j) - '0';
				}
			}
			for (int i = 0; i < 8; i++) {
				for (int j = 0; j < 8; j++) {
					if (a[i][j] == 1) {
						b[index++] = i * 8 + j;
					}
				}
			}
			if (b[1] - b[0] == 1) {
				if (b[2] - b[1] == 1) {
					System.out.println("C");
				} else if (b[2] - b[1] == 6) {
					System.out.println("G");
				} else if (b[2] - b[1] == 7){
					System.out.println("A");
				} else {
					System.out.println("E");
				}
			} else if (b[1] - b[0] == 8) {
				if (b[2] - b[1] == 1) {
					System.out.println("F");
				} else {
					System.out.println("B");
				}
			} else {
				System.out.println("D");
			}
		}
	}
}

Measured memory_bytes: 12000
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    a, b, c, d = map(int, input().split())
    while True:
        c -= b
        if c <= 0:
            print('Yes')
            break
        a -= d
        if a <= 0:
            print('No')
            break


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 61900
// g++ -Wall -Wextra -pedantic -std=c++17 -O3 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -fsanitize=address -fno-sanitize-recover -fstack-protector contest.cpp

#include <bits/stdc++.h>

// #define _GLIBCXX_DEBUG 1
// #define _GLIBCXX_DEBUG_PEDANTIC 1
// #define _FORTIFY_SOURCE 2

using namespace std;
#define int long long
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
int invmod(int a, int md){return powmod(a,md-2,md);}
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii;
typedef vector<ll> vl; typedef pair<ll,ll> pll; typedef vector< pair<ll,ll> > vll;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
const int MX = 400010;

int f[MX];
int rf[MX];

int C(int l,int k, int md) 
{
    if (k<0||k>l){
        return 0;
    }
    return f[l]*rf[k]%md*rf[l-k]%md;
}

void precfac() {
    f[0]=1;
    for (int i=1;i<MX;i++){
        f[i]=f[i-1]*i%MOD;
    }
    rf[MX-1]=powmod(f[MX-1],MOD-2, MOD);
    for (int i=MX-2;i>=0;i--){
        rf[i]=rf[i+1]*(i+1)%MOD;
    }
}

int fac(int x) {
	int ret=1;
	for(int i = 1; i <= x; i++) {
		ret*=i;
		ret%=MOD;
	}
	return ret;
}
signed main(void)
{
	IOS;
	precfac();
	int n,a,b; cin>>n>>a>>b;
	int afac,bfac;
	afac=fac(a);
	bfac=fac(b);
	// cout<<afac<<" "<<bfac<<endl;
	int ans=(powmod(2,n,MOD)-1+MOD)%MOD;
	int ta=1,tb=1;
	for(int i = 0; i < a; i++) {
		ta*=(n-i);
		ta%=MOD;
	}
	for(int i = 0; i < b; i++) {
		tb*=(n-i);
		tb%=MOD;
	}
	// cout<<ta<<" "<<tb<<endl;
	int term1=ta*invmod(afac,MOD),term2=tb*invmod(bfac,MOD);
	term2%=MOD;
	term1%=MOD;
	ans=((ans-term1+MOD)%MOD-term2+MOD)%MOD;
	cout<<ans<<endl;
	// int ans=0;
	// for(int i = 0; i <= n; i++) {
	// 	int tp=0;
	// 	if(n-i-1<0 || n+k-2*i-1<0) break;
	// 	tp=C(n,i,MOD)*powmod(2,i,MOD);
	// 	tp%=MOD;
	// 	tp*=C(n+k-2*i-1,n-i-1,MOD);
	// 	tp%=MOD;
	// 	ans += tp;
	// 	tp%=MOD; 
	// }
	// cout<<ans<<endl;
	time();
	return 0;
}

Measured memory_bytes: 6656
s = gets.chomp.split('')
s.each.with_index(1) do |char, i|
  if (i.odd?)
    if (char == 'L')
      puts 'No'
      exit
    end
  else
    if (char == 'R')
      puts 'No'
      exit
    end
  end
end
puts 'Yes'


Measured memory_bytes: 14324
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define rall(n) std::rbegin(n), std::rend(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	Int N, K; std::cin >> N >> K;
	std::vector<Int> A(N);
	rep(i, N) {
		std::cin >> A[i];
		A[i]--;
	}
	std::set<Int> s;
	std::vector<Int> order;

	Int cur = 0;
	Int begin = 0;
	Int cycle = 0;

	rep(i, N) {
		order.push_back(cur);
		if (i == K) {
			std::cout << cur + 1;
			return;
		}
		if (!s.insert(cur).second) {
			rep(j, order.size()) {
				if (order[j] == cur) {
					begin = j;
					break;
				}
			}
			cycle = i - begin;
			break;
		}
		else {
			cur = A[cur];
		}
	}

	if (cycle != 0)std::cout << order[(K - begin) % cycle + begin] + 1;
	else std::cout << order[begin] + 1;

}


int main() {

	init();
	calc();

	return 0;
}

Measured memory_bytes: 13604