akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+5;
int x,m,n,cnt,blag,t;
int ans,res;
bool flag;
int a[N],wzl[N];
signed main()
{
	cin>>n>>x>>m;
	memset(a,0,sizeof a);
	res=x;ans=res;wzl[1]=res;a[res]=1;
	for (register int i=2;i<=n;i++) 
	{
		res=res*res;
		if (res>=m) res%=m;
		if (a[res]!=0) {cnt=i-a[res];blag=a[res];wzl[i]=wzl[i-1]+res;t=i;flag=1;break;}
		else {a[res]=i;wzl[i]=wzl[i-1]+res;ans+=res;}
	}
	if (flag) 
	{
		ans+=(n-t)/cnt*(wzl[t]-wzl[blag]); 
		for (register int i=1;i<a[res];i++) x=x*x%m;
		for (register int i=a[res];i<a[res]+(n-t)%cnt;i++) ans+=x,x=x*x%m;
		if (t!=n) ans+=x;
	}  
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 4700
#include <iostream>

using namespace std;

int main(void){
  int n,t;
  cin >> n >> t;
 
  int min = 1001;
  for(int i = 0; i < n ; i++){
    int a,b;
    cin >> a >> b;
    if(b <= t && a < min){
      min = a;
    }
  }
  if(min != 1001){
    cout << min << endl;
  }else{
    cout << "TLE" << endl;
  }
}

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

using namespace std;


int n , as;
string t , s , s1, t1;

int main()
{
    cin >> n >> s >> t;
    s1 = "!";
    for (int i = 0; i <= n; i++)
    {
        if (s1 != t1)
        {
            s1 = "";
            t1 = "";
            t1.append(t , 0 , n - i);
            s1.append(s , i , n);   
        }
        else
        {
            as = s1.size();
            break;
        }
    }
    cout << n * 2 - as << endl;
    return 0;
}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class AFavoriteSound {
public:
	void solve(std::istream& in, std::ostream& out) {
        int A, B, C;
        in >> A >> B >> C;
        out << min(C, B / A) << '\n';
	}
};


int main() {
	AFavoriteSound solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

void CountingSort( unsigned short *A,unsigned short *B, int n);

int n;

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int  i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);


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

  CountingSort(A,B,VMAX);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for(j = 1 ; j <= n ; j++) C[A[j]]++;

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for(j = n ; j >= 1 ; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}


void CountingSort(unsigned short *A,unsigned short *B, int n){
  int i,j;
  unsigned short C[VMAX+1];

  /*  for(i = 0 ; i <= VMAX ; i++)  C[i] = 0;

  for(j = 1 ; j <= n ; j++) C[A[j]]++;

  for(i = 1 ; i <= VMAX ; i++) C[i] = C[i] + C[i-1];

   for(j = n ; j >= 1 ; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
    }
  }
  */
}

Measured memory_bytes: 8460
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ll n,m;cin>>n>>m;
    ll a[n];
    f(i,0,n)cin>>a[i];
    ll adj[n+1]={0};
    while(m--){
        ll x,y;cin>>x>>y;
        x--;y--;
        adj[x]=max(adj[x],a[y]);
        adj[y]=max(adj[y],a[x]);
    }
    ll c=0;
    f(i,0,n){
        if(a[i]>adj[i])c++;
    }
    cout<<c;
    return 0;  
} 





Measured memory_bytes: 5208
def main():
    n = int(input())
    if n%2 != 0:
        print(0)
        return

    if n <= 8:
        print(0)
        return

    ans = 0
    i = 0
    while True:
        x = 10*(5**i)
        if n//x > 0:
            ans += n//x
        else:
            break

        i += 1

    print(ans)

main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;
typedef long long ll;
const int N=100009;
int main()
{
  ll n,a,b,s=0;
  cin>>n;
  a=n/500;
  s+=(1000*a);
  n=n%500;
  a=n/5;
  s+=(5*a);
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
p=[0]*m
s=[0]*m
for i in range(m):
  p[i],s[i]=map(str,input().split())
cor=[0]*n
fal=[0]*n
for i in range(m):
  x=int(p[i])
  if cor[x-1]==0:
    if s[i]=='AC':
      cor[x-1]=1
    else:
      fal[x-1]+=1
ans_cor=0
ans_fal=0
for i in range(n):
  if cor[i]==1:
    ans_cor+=1
    ans_fal+=fal[i]
print(ans_cor,ans_fal) 

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

//UnionFind
//0-indexed
//#include <vector>
struct union_find {
  std::vector<long long> parent;
  std::vector<long long> sizes;

  //コンストラクタ
  union_find(long long n) {
    for (long long i = 0; i < n; i++) {
      parent.push_back(i);
      sizes.push_back(1);
    }
  }

  //頂点nの根
  long long root_of(long long n) {
    if (parent[n] == n) return n;
    return parent[n] = root_of(parent[n]); //パス圧縮
  }

  //頂点nと間接的に繋がっている頂点の数(自身含む)
  long long size_of(long long n) {return sizes[root_of(n)];}

  //頂点a, bが間接的に繋がっているか判定
  bool is_united(long long a, long long b) {return (root_of(a) == root_of(b));}

  //頂点aを含むグラフに頂点bを含むグラフを結合
  void unite(long long a, long long b) {
    if (is_united(a, b)) return;
    if (size_of(a) < size_of(b)) std::swap(a, b); //マージテク
    sizes[root_of(a)] += size_of(b);
    parent[root_of(b)] = root_of(a);
  }
};

int main() {
  long long n, m, k;
  std::cin >> n >> m >> k;

  union_find uf(n);

  std::vector<std::vector<long long>> nx(n, std::vector<long long>(0));
  for (long long i = 0; i < m; i++) {
    long long a, b;
    std::cin >> a >> b;
    nx[a - 1].push_back(b - 1);
    nx[b - 1].push_back(a - 1);
    uf.unite(a - 1, b - 1);
  }

  std::vector<long long> bl(n, 0);
  for (long long i = 0; i < k; i++) {
    long long c, d;
    std::cin >> c >> d;
    if (uf.is_united(c - 1, d - 1)) {
      bl[c - 1]++;
      bl[d - 1]++;
    }
  }

  for (long long i = 0; i < n - 1; i++) std::cout << uf.size_of(i) - 1 - nx[i].size() - bl[i] << " ";
  std::cout << uf.size_of(n - 1) - 1 - nx[n - 1].size() - bl[n - 1] << std::endl;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    string s;
    cin >> s;
    int left = stoi(s.substr(0, 2));
    int right = stoi(s.substr(2, 2));
    if (left >= 1 && left <= 12) {
        if (right >= 1 && right <= 12) {
            puts("AMBIGUOUS");
            return;
        }
        else {
            puts("MMYY");
            return;
        }
    }
    else {
        if (right >= 1 && right <= 12) {
            puts("YYMM");
            return;
        }
        else {
            puts("NA");
            return;
        }
    }

}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main()
{
	string s;
	cin >> s;
    
    int count = 0;
    int max = 0;
    for (auto& c : s)
    {
        if (c == 'R')
        {
            count++;
            if (count > max)
                max = count;
        }
        else
        {
            if (count > max)
                max = count;
            count = 0;
        }
    }
    
    cout << max;
    
    return 0;
}

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

int main() {
    int a, b, n, p1, p2;
    cin >> n >> a >> b;
    p1 = a*n;
    p2 = b;
    if (p1 > p2) {
        cout << p2 << endl;
    } else {
        cout << p1 << endl;
    }
    return 0;
}

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

int main() {
  int h, w; cin >> h >> w;
  vector<vector<int>> a(10, vector<int>(10));
  for (int i = 0; i < 10; i ++) {
    for (int j = 0; j < 10; j ++) cin >> a[i][j];
  }
  vector<vector<int>> g(h, vector<int>(w));
  for (int i = 0; i < h; i ++) {
    for (int j = 0; j < w; j ++) cin >> g[i][j];
  }
  
  for (int k = 0; k < 10; k ++) {
    for (int i = 0; i < 10; i ++) {
      for (int j = 0; j < 10; j ++) {
        a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
      }
    }
  }
  
  int sum = 0;
  for (int i = 0; i < h; i ++) {
    for (int j = 0; j < w; j ++) {
      if (g[i][j] == -1 || g[i][j] == 1) continue;
      sum += a[g[i][j]][1];
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 508
H, W = map(int, input().split())
sheet = []
flame = ""
for i in range(W+ 2):
  flame+= "."

sheet.append(flame)  
for i in range(H):
  row = "."+ input()+ "."
  sheet.append(row)
  
sheet.append(flame)

flag = 1
for i in range(1, H+ 1):
  for j in range(1, W+ 1):
    if(sheet[i][j] == "#"):
      if(sheet[i- 1][j] != "#" and sheet[i][j- 1] != "#" and \
        sheet[i+ 1][j] != "#" and sheet[i][j+ 1] != "#"):
        flag = 0
        print("No")
        break
  if(flag == 0):
    break

if(flag == 1):
  print("Yes")

Measured memory_bytes: 3064
#include <iostream>
 
using namespace std;
const int nmax=200005;
int a[nmax];
long long ans;
int n,i;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]-=i;
        if(a[i]>=0)
        {
            cout<<"-1";
            return 0;
        }
        if(a[i]<a[i-1]) ans=ans+1LL*(i+a[i]);
        else ans++;
        if(i>1&&a[i]>a[i-1])
        {
            cout<<"-1";
            return 0;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int ans = 0;

        int rCount = 0;

        for (int i = 0; i < n; i++) {
            if (s[i] == 'R') {
                rCount++;
            }
        }
        for (int i = 0; i < rCount; i++) {
            if (s[i] == 'W') {
                ans++;
            }
        }

        System.out.println(Math.min(ans, rCount));
    }
}

Measured memory_bytes: 40684
// 解説見た
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int main() {
    int h,w; cin >> h >> w;
    int ch,cw; cin >> ch >> cw;
    int dh,dw; cin >> dh >> dw;
    
    //lint h = 1000;
    //lint w = 1000;
    //lint ch = 1;
    //lint cw = 1;
    //lint dh = 1000;
    //lint dw = 1000;

    vector<string> s(h);
    rep(i,h) cin >> s[i];

    //bfs
    // <y,x>,cnt
    vector<vector<int>> cnt(h, vector<int>(w,100000000));
    priority_queue<pair<int,pair<int,int>>, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int>>>> hq;
    //cnt[ch-1][cw-1] = 0;
    hq.push(make_pair(0,make_pair(ch-1,cw-1)));
    vector<int> nex = {0,0,-1,1};
    vector<int> ney = {-1,1,0,0};
    while (not hq.empty()) {
        auto t = hq.top(); hq.pop();
        int cost = t.first;
        int y = t.second.first;
        int x = t.second.second;
        //cout << y << ' ' << x << endl;
        if (cnt[y][x] != 100000000) continue;
        cnt[y][x] = cost;
        rep(yyy,5) {
            rep(xxx,5) {
                if (yyy == 3 && xxx == 3) continue;
                int iy = 2-yyy;
                int ix = 2-xxx;
                int ny = y+iy;
                int nx = x+ix;
                if (ny >= 0 && ny < h && nx >= 0 && nx < w && s[ny][nx] == '.') {
                    //auto old = cnt[ny][nx];
                    //cnt[ny][nx] = min(cnt[ny][nx], cnt[y][x]+1);
                    //if (old != cnt[ny][nx]) que.push(make_pair(ny,nx));
                    if (cnt[ny][nx] > cnt[y][x]+1) hq.push(make_pair(cnt[y][x]+1,make_pair(ny,nx)));
                }
            }
        }
        
        rep(i,4) {
            int ny = y+ney[i];
            int nx = x+nex[i];
            if (ny >= 0 && ny < h && nx >= 0 && nx < w && s[ny][nx] == '.') {
                //auto old = cnt[ny][nx];
                //cnt[ny][nx] = min(cnt[ny][nx], cnt[y][x]);
                //if (old != cnt[ny][nx]) que.push(make_pair(ny,nx));
                if (cnt[ny][nx] > cnt[y][x]) hq.push(make_pair(cnt[y][x],make_pair(ny,nx)));
            }
        }
    }
    int ans = cnt[dh-1][dw-1];
    if (ans == 100000000) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 9936
#include <bits/stdc++.h>
using namespace std;
string s;
int n,danh,a[1000000],l,r,mid;
int kt(int o)
{
		cout<<o<<endl;
		fflush(stdout);
		cin>>s;
		if(s=="Vacant") return 0;
		else if(s=="Male") return 1;
		     else if(s=="Female") return 2;
}
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	danh=0;
	a[0]=kt(0);
	if(a[0]==0) return 0;
	a[n-1]=kt(n-1);
	if(a[n-1]==0) return 0;
	l=0;
	r=n-1;
	while(l+1!=r)
	  {
	  	mid=(l+r)/2;
	  	a[mid]=kt(mid);
	  	//if(a[mid]==0) return 0; 
	  	if(abs(a[mid]-a[0]) != (mid % 2)) r=mid;
	  	  else l=mid;
	  }
	int h;
	h=kt(l);
	if(h==0) return 0;
	else 
	   {
	   	 cout<<r<<endl;
	   	 fflush(stdout);
	   }
}

Measured memory_bytes: 976
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;

bool check(int s){
  for(int i=1;i<=sqrt(s);i++)
    if((s-i)%(2*i+1)==0) return true;
  return false;
}

int main(){
  int n,cnt=0,s;
  
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&s);
    if(check(s)==false) cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,temp,flg=0;
	cin>>a>>b>>c;
	if(a>b)
	{
		temp=b;
		b=a;
		a=temp;
	}
	for(int i=a;i<=b;i++)
	{
		if(i==c)
		{
			flg=1;
			break;
		}
	}
	if(flg==1)	
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * Problem C: Dividing Students
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		StringBuilder sb = new StringBuilder();
		while (!(line = br.readLine()).equals("0")) {

			int n = Integer.parseInt(line);

			for (int i = 0; i < n; ++i) {
				StringTokenizer st = new StringTokenizer(br.readLine());
				int pm = Integer.parseInt(st.nextToken());
				int pe = Integer.parseInt(st.nextToken());
				int pj = Integer.parseInt(st.nextToken());

				int sum = pm + pe + pj;
				char rank = 'C';
				if (pm > 99 || pe > 99 || pj > 99) {
					rank = 'A';
				} else if (sum > 239 || sum - pj > 179) {
					rank = 'A';
				} else if (sum > 209) {
					rank = 'B';
				} else if (sum > 149 && (pm > 79 || pe > 79)) {
					rank = 'B';
				}
				sb.append(rank).append('\n');
			}
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 22180
#include <stdio.h>

int a, b, c, i;
int d[64], t, l;
int main() {
t = 0;

scanf("%d %d %d", &a, &b, &c);

for(i=1; i<10001; i++) {
	if(c%i == 0) {
		d[t] = i;
		t++;
		l++;
	}
}

for(i=0; i<t; i++) {
	if(d[i] < a) l--;
	else if(d[i] > b) l--;
}

printf("%d\n", l);
return 0;
}

Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
	cin>>n;
	//vector<int>v;
	set<int>s;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		s.insert(x);
	}

	if(s.size() == n)
		cout<<"YES";
	else
		cout<<"NO";
}

Measured memory_bytes: 9600
import java.io.*;
  
class Main{
	public static void main(String[] args) throws IOException{

		int x,y;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){

			String str[] = br.readLine().split(" ");
			x = Integer.parseInt(str[0]);
			y = Integer.parseInt(str[2]);
			
			if(str[1].equals("+")){
			 	System.out.println(x + y);
			}else if(str[1].equals("-")){
				System.out.println(x - y);
			}else if(str[1].equals("*")){
			 	System.out.println(x * y);
			}else if(str[1].equals("/")){
				System.out.println(x / y);
			}else if(str[1].equals("?")){
				 break;
			}
		}
  	}
}

Measured memory_bytes: 17100
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
const long long Mod=998244353;
int n,k;
long long fac[500010],inv[500010];
long long pw(long long x,long long y)
{
	long long res=1;
	while (y)
	{
		if (y&1)
		{
			res=res*x%Mod;
		}
		x=x*x%Mod;
		y>>=1;
	}
	return res;
}
long long c(int n,int m)
{
	if (m<0 || m>n)
	{
		return 0;
	}
	return fac[n]*inv[m]%Mod*inv[n-m]%Mod;
}
int main()
{
	scanf("%d%d",&n,&k);
	fac[0]=1;
	for (int i=1;i<=k;i++)
	{
		fac[i]=fac[i-1]*i%Mod;
	}
	inv[k]=pw(fac[k],Mod-2);
	for (int i=k-1;i>=0;i--)
	{
		inv[i]=inv[i+1]*(i+1)%Mod;
	}
	long long ans=0;
	for (int i=n;i<=k;i++)
	{
		ans=(ans+c(k-1,i-1))%Mod;
	}
	printf("%lld\n",ans);
    return 0;
}
//秋丛绕舍似陶家，遍绕篱边日渐斜。
//不是花中偏爱菊，此花开尽更无花。
//——元稹《菊花》

Measured memory_bytes: 8064
#include<iostream>
#include<cmath>

using namespace std;

int D;
double V[16];

double interpolate(int n, int E)
{
    double sum=0.0;
    for(int k=0; k<D+3; k++)
    {
        if(k==n || k==E)
          continue;
        double p=V[k];
        for(int i=0;i<D+3;i++)
           if(i!=k && i!=E && i!=n)
             p *=(double)(n-i)/(double)(k-i);
        sum +=p;
    }
    return sum;
}

bool outlier(int E)
{
    for(int i=0;i<D+3;i++)
    {
        if(i==E)
          continue;
        double p=interpolate(i, E);
        if(abs(p-V[i])>0.1)
          return false;
    }
    return true;
}

int main()
{
    while(cin >> D && D)
    {
        for(int i=0;i<D+3;i++)
           cin >> V[i];
        for(int i=0;i<D+3;i++)
           if(outlier(i))
           {
               cout << i << endl;
               break;
           }
    }
}


Measured memory_bytes: 3184
def main():
    N, X = map(int, input().split())
    L = [int(v) for v in input().split()]

    d = [0] * (N + 1)

    for i in range(N):
        d[i + 1] = d[i] + L[i]
        if d[i + 1] > X:
            print(i + 1)
            exit()

    print(N+1)


main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define INF 1e9

int max(int x, int y){return x<y?y:x;}

int main(void){
	int N,M,A[10],i;
	int cost[10]={0,2,5,5,4,5,6,3,7,6};
	scanf("%d%d",&N,&M);
	for(i=0;i<M;i++)scanf("%d",&A[i]);
	int dp[N+1];
	dp[0] = 0;
	for(i=1;i<=N;i++){
		dp[i] = -INF;
		for(int j=0;j<M;j++){
			if(i-cost[A[j]]>=0)	dp[i] = max(dp[i-cost[A[j]]]+1,dp[i]);
		}
	}
	while(N>0){
		int j = 0;
		for(i=0;i<M;i++){
			if(N-cost[A[i]]>=0 && dp[N-cost[A[i]]]==dp[N]-1) j = max(A[i],j);
		}
		printf("%d",j);
		N -= cost[j];
	}
	return 0;
}

Measured memory_bytes: 256
'use strict';

function main(input) {
  let AB = input.split("\n")[0].split(' ').map(x => Number(x));
  let s = input.split("\n")[1];

  let reg = "^[0-9]{"+AB[0]+"}-[0-9]{"+AB[1]+"}$";
  if(s.match(reg)){
  	console.log("Yes");
  }else{
  	console.log("No");
  }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin >> s;
  if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba"){
    cout << "Yes" <<endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/*
 * atcoder/dp_2nd/f.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long
#define MOD 10e9+7

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 3100;
string S, T;

ll dp[MAX][MAX];

void input() {
  cin >> S >> T;
}

int rec(int s, int t) {
  ll &cache = dp[s][t];
  if (~cache) return cache;
  if (s == S.size() || t == T.size()) return cache = 0; // これ以上共通部分が増えることはない
  return cache = max(
    (S[s] == T[t]) + rec(s + 1, t + 1),
    max(
      rec(s + 1, t),
      rec(s, t + 1)
    )
  );
}

int memoRec() {
  memset(dp, -1, sizeof(dp));
  return rec(0, 0);
}

void printLcs(int count) {
  vector<char> lcs(count+1);
  int s = S.size()-1, t = T.size()-1;
  while (s >= 0 && t >= 0) {
    if (S[s] == T[t]) {
      lcs[dp[s+1][t+1]] = S[s];
      s--;t--;
      continue;
    }

    if (dp[s+1][t] > dp[s][t+1]) t--;
    else s--;
  }

  for (int i=1; i<count+1; i++) cout << lcs[i];
  cout << endl;
}

void solve() {
  for (int s=0; s<=S.size(); s++) {
    for (int t=0; t<=T.size(); t++) {
      if (t == 0 || s == 0) { dp[s][t] = 0; continue; }
      if (S[s-1] == T[t-1]) {
        chmax(dp[s][t], 1 + dp[s-1][t-1]);
      }
      else {
        chmax(dp[s][t], dp[s-1][t-1]);
        chmax(dp[s][t], dp[s-1][t]);
        chmax(dp[s][t], dp[s][t-1]);
      }
    }
  }
  printLcs(dp[S.size()][T.size()]);
}

void dump() {
  for (int s=0; s<S.size(); s++) {
    for (int t=0; t<T.size(); t++) {
      cout << dp[s][t] << " ";
    }
    cout << endl;
  }
}

int main() {
  // cout.precision(15);
  input();
  solve();
  // dump();
  return 0;
}


Measured memory_bytes: 73984
import java.util.*;
import java.io.*;


class Main {

    public static void main(String[] args) throws IOException
    {
        PrintWriter out = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        Long arr[] = new Long[n];
        StringTokenizer st1 = new StringTokenizer(br.readLine());
        for(int i = 0 ; i < n ; i++)
        {
            arr[i] = Long.parseLong(st1.nextToken());
        }
        Arrays.sort(arr);
        long sum = arr[n-1];
        int ind = n-2;
        for(int i = 0 ; i < n-2 ; i++)
        {
            sum += arr[ind];

            if(i%2 != 0)
                ind--;
        }
        out.println(sum);

        out.flush();
        out.close();

    }

    static class pair{
        long x1;
        long x2;

        public pair(long x1 , long x2)
        {
            this.x1 = x1;
            this.x2 = x2;
        }

    }

}


Measured memory_bytes: 58892
import math
k = int(input())
t = 0
# a = b = c
for x in range(1, k+1):
    t += x
# a = b != c
for a in range(1, k+1):
    for b in range(a+1, k+1):
        t += 6*math.gcd(a, b)
# a != b != c
for a in range(1, k+1):
    for b in range(a+1, k+1):
        for c in range(b+1, k+1):
            d = math.gcd(a, b)
            t += 6*math.gcd(d, c)
print(t)


Measured memory_bytes: 9188
#include <stdio.h>

int main(void)
{

	int n;
	while(1){
		int n;
		int a=0,b=0;
		int ac,bc;

		scanf("%d", &n);
		if(n == 0)
		break;
		for(int i = 0; i < n; i++){
			
			scanf("%d %d", &ac,&bc);
			if(ac > bc)
				a += (ac + bc);
			else if(ac < bc)
				b += (ac + bc);
			else {
				a += ac;
				b += bc;
			}
		}
		printf("%d %d\n", a,b);

	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;
vector<int> a[N];
bool vis[N];
void dfs(int u)
{
      if(vis[u]) return;
      vis[u]=true;
      for(auto x:a[u]) dfs(x);
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      int n,m;
      cin>>n>>m;
      for(int i=0;i<m;i++)
      {
            int x,y,z;
            cin>>x>>y>>z;
            a[x].pb(y);
            a[y].pb(x);
      }
      int an=0;
      for(int i=1;i<=n;i++)
      {
            if(!vis[i]){
                  an++;
                  dfs(i);
            }
      }
      cout<<an;
}     



Measured memory_bytes: 8960
#include <stdio.h> 
#include <stdlib.h> 
 
int main(void) 
{ 
    int h[10]; 
    int idx1, idx2, idx3 = -1; 
    int temp_h = 0; 
    int i; 

 
    for(i = 0; i < 10; i++) 
        scanf("%d", h + i); 
 
    /* 1 番目に高い山を探す */ 
    for(i = 0; i < 10; i++) { 
        if(h[i] > temp_h) { 
            temp_h = h[i]; 
            idx1 = i; 
        } 
    } 

 
    /* 2 番目に高い山を探す */ 
    temp_h = 0; 
    for(i = 0; i < 10; i++) { 
        if(i == idx1) continue; 

        if(h[i] > temp_h) { 
            temp_h = h[i]; 
            idx2 = i; 
        } 
    } 

 
    /* 3 番目に高い山を探す */ 
    temp_h = 0; 
    for(i = 0; i < 10; i++) { 
        if(i == idx1 || i == idx2) continue; 

 
        if(h[i] > temp_h) { 
            temp_h = h[i]; 
            idx3 = i; 
        } 
    } 


    printf("%d\n%d\n%d\n", h[idx1], h[idx2], h[idx3]); 

 
    return 0; 
} 


Measured memory_bytes: 2048
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 500005;

#define yes return cout << "YES\n", 0
#define no return cout << "NO\n", 0
#define YN(x) return cout << ((x) ? "YES\n" : "NO\n"), 0

int n, a, b, c, d;

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    /*for (int c = 0; c<10; c++) {
        for (int d = c; d<10; d++) {
            n = 20;
            bitset<52> possible[52];
            memset(possible, 0, sizeof(possible));
            possible[0][25] = 1;
            for (int i = 1; i <= n; i++) {
                for (int j = c; j <= d; j++) {
                    possible[i] |= possible[i-1]<<j, possible[i] |= possible[i-1]>>j;
                }bug(possible[i]);
            }bug(c, d, possible[n]);
        }
    }*/

    cin >> n >> a >> b >> c >> d;
    a = abs(a-b), --n;
    ll tmp = d*ll(n);
    if (a > tmp) no;
    YN((tmp-a)%(c+d) < 1+n*ll(d-c));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

#define SIZE 100010

int fact[SIZE];
void make_fact()
{
    fact[0] = fact[1] = 1;
    for (int i = 2; i < SIZE; i++)
        fact[i] = (fact[i - 1] * i) % mod;
}

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

    int n, m;
    cin >> n >> m;
    make_fact();
    int ans = 0;
    if (n == m)
        ans = (fact[n] * fact[m] * 2) % mod;
    else if (abs(n - m) == 1)
        ans = (fact[n] * fact[m]) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    int n,q,m,d[51][101],i,j,k,e[51][101],o[101],p,a;
    while(1){
        cin>>n>>q;
        if (n==0&&q==0) break;
        for (i=1;i<=n;i++){
            for (k=1;k<=100;k++){
                e[i][k]=0;
            }
            cin>>m;
            for (j=1;j<=m;j++){
                cin>>d[i][j];
                for (k=1;k<=100;k++){
                    if (k==d[i][j]) e[i][k]=1;
                }
            }
        }
        a=0;
        p=0;
        for (k=1;k<=100;k++){
            o[k]=0;
            for (i=1;i<=n;i++){
                o[k]+=e[i][k];
            }
            if (o[k]>=q) {
                if (o[k]>p) {
                    a=k;
                    p=o[k];
                }
            }
        }
        cout<<""<<a<<"\n";
    }
}

Measured memory_bytes: 1200
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var ans = 0;
        for (int i = 1; i < s.Length; i++)
        {
            if (s[i - 1] != s[i]) ans++;
        }
        Console.WriteLine(ans);
    }
}


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

int main(){

  int A, B, C, D;
  cin >> A >> B >> C >>D;
  
  if((A * B) > (C * D)){
  	cout << A * B << endl;
  }
  
  else {
    cout << C * D << endl;
  }
}  

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N, L;
  cin >> N >> L;
  vector<int> a(N);
  REP(i,N) cin >> a[i];

  int pnt = -1;
  REP(i, N - 1) {
    if(a[i] + a[i + 1] >= L) {
      pnt = i;
      break;
    }
  }
  if(pnt == -1) {
    cout << "Impossible" << endl;
  }else{
    cout << "Possible" << endl;
    REP(i, pnt) cout << i + 1 << endl;
    REP(i, N - 1 - pnt) cout << N - 1 - i << endl;
  }
  return 0;
}



Measured memory_bytes: 1152
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    vector<int> RCNT = {0,0};
    vector<int> ans; 
    rep(i,s.length())ans.push_back(0);
    rep(i,s.length()){
        char c = s[i];
        if(c == 'R'){
            RCNT[i%2]++;
        }else{
            int LPOS = i;
            vector<int> LCNT = {0,0};
            while(s[i] == 'L'){
                LCNT[i%2]++;
                i++;
            }
            if(LPOS % 2 == 0){
                if(LPOS != 0){
                    ans[LPOS-1] = RCNT[1] + LCNT[1];
                }
                ans[LPOS] = RCNT[0] + LCNT[0];
            }else{
                 if(LPOS != 0){
                    ans[LPOS-1] = RCNT[0] + LCNT[0];
                }
                ans[LPOS] = RCNT[1] + LCNT[1];
            }
            RCNT = {0,0};
            RCNT[i%2]++;
            LCNT = {0,0};
        }
    }
    rep(i,ans.size()){
        cout << ans[i];
        if(i != ans.size()-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }
}

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


Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  bool t = true;
  while (t) {
    t = false;
    REP(i, N) {
      if (A[i] % A[0] == 0) continue;
      A[i] = A[i] % A[0];
      t = true;
    }
    sort(A.begin(), A.end());
  }
  cout << A[0] << endl;
}

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

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int s, w;
	scanf("%d%d", &s, &w);
	printf("%s\n", s <= w ? "unsafe" : "safe");

	Please AC;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    vector<int>a(n+1,0);

    rep(i,m){
         int A;
         cin>>A;

         a[A]++;
    }

    int sum1=0,sum2=0;

    rep2(i,x,n)sum1+=a[i];
    repr(i,x,0)sum2+=a[i];

    cout<<min(sum1,sum2)<<endl;

}





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

using namespace std;

#define ll  long long
#define vi  vector<int>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

int main(){

  int a,b,c,d;
  cin >> a >> b >> c >> d;

  int ans = min(a,b) + min(c,d);
  pr(ans);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N;
	double a;
	scanf("%d",&N);
	if(N%2==1){
		a=(double)((N+1)/2)/(double)N;
		printf("%f",a);
	}else{
		a=(double)1/(double)2;
		printf("%f",a);
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

// PMAMP :)
// INL , IIWOIL

int solve(ll n,ll k)
{
    int count=0;
    while(n)
    {
        n=n/k;
        count++;
    }
    return count;
}
int main()
{
    jaldi
    ll n,k;
    cin>>n>>k;
    int ans=solve(n,k);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;
int dx,dy;

int main(){
  int n;
  cin>>n;
  string s=to_string(n);
  int sum=0;
  rep(i,s.size())sum+=s[i]-'0';
  if(n%sum==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

#include <string.h>

using namespace std;

bool isKibun(string str);

bool isOkPair(string &str, int i);

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

  int result = 0;

  if (isKibun(s)) {
    // 処理なし
  } else {
    for (int i = 0; i < (s.size() / 2); i++) {
      if (!isOkPair(s, i)) {
        result++;
      }
    }
  }

  cout << result << endl;
  return 0;
}

bool isKibun(string str) {
  for (int i = 0; i < (str.size() / 2); i++) {
    if (!isOkPair(str, i)) {
      return false;
    }
  }
  return true;
}

bool isOkPair(string &str, int i) {
  return str.at(i) == str.at(str.size() - 1 - i);
}


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

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

int main(){
    string a, b;
    cin >> a >> b;
    string S = "", T = "";
    int _a = (int)stoi(a);
    int _b = (int)stoi(b);
    //aをb回
    rep(i, _b) S += a;
    //bをa回
    rep(i, _a) T += b;
    if(S < T) cout << S << endl;
    else cout << T << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, c, a[100];
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	for(int i = 0; i < n; i++) {
		int k = i;
		for(int j = i + 1; j < n; j++) {
			if(a[k] > a[j]) k = j;
		}
		if(k != i) swap(a[k], a[i]), c++;
	}
	for(int i = 0; i < n; i++) {
		if(i) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
#define _GLIBCXX_DEBUG
     
int main() {
  ll n;
  cin >> n;
  ll ans=0;
  
  for (int i=1; i<n; ++i) ans += i;
  
  /*
  vector<int> vec(n);
  
  vec[0] = n;
  for (int i=1; i<n; ++i) vec[i] = i;
  
  rep (i, n) ans += (vec[i] % (i+1));
  */
  
  cout << ans << endl;
 
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> D(K);
  for (int i = 0; i < K; i++) cin >> D.at(i);
  for (int i = N; i < 100000; i++) {
    bool flag = true;
    int num = i;
    while (num != 0) {
      int digit = num % 10;
      for (int j = 0; j < K; j++) if (digit == D.at(j)) flag = false;
      num /= 10;
    }
    if (flag) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
//int	2,147,483,647
//1億    10^8 この辺が限界


int main(){

    ll X;
    int a=0,b=0;
    std::cin >> X;

    bool exist=false;
    for(int A=-1000;A<=1000;A++)
    {
        for(int B=-1000;B<=1000;B++)
        {
            if(std::pow<int,int>(A,5) - std::pow<int,int>(B,5) == X)
            {
                exist = true;
                a=A;
                b=B;
            }
        }
    }

    if(exist)
    {
        std::cout << a << " " << b << std::endl; 
    }

    return 0;
}


Measured memory_bytes: 4032
func readArrayInt() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}

// input
var line = readArrayInt()
let (N, M, X) = (line[0], line[1], line[2])
var C: [Int] = []
var A: [[Int]] = []
(1...N).forEach({ _ in
    line = readArrayInt()
    C.append(line[0])
    A.append(Array(line[1...M]))
})

// main
func allAchived(_ bits: Int) -> Bool {
    var achieved = Array(repeating: 0, count: M)
    (0..<N).forEach({ place in
        if ((1 << place & bits) > 0) {
            for (i, value) in A[place].enumerated() {
                achieved[i] += value
            }
        }
    })
    return !achieved.contains(where: {$0 < X})
}

func cost(_ bits: Int) -> Int {
    var cost = 0
    for i in 0..<N where ((1 << i & bits) > 0) {
        cost += C[i]
    }
    return cost
}

var ans = -1
(1..<(1 << N)).forEach { bits in
    if (allAchived(bits)) {
        ans = ans < 0 ? cost(bits) : min(cost(bits), ans)
    }
}

print(ans)


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int f(int n,int k){
	if(n==0)return 0;
	else{
		int v=f(n-1,k);
		//dbg(v);
		return (v+k)%n;
	}
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		int n,k,m;
		cin>>n>>k>>m;
		if(n==0)break;
		cout<<(f(n-1,k)+m)%n+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3432
import sys
X, Y = map(int, input().split())

# たどりつけない時
if ((X+Y) % 3 != 0) or (min(X, Y)*2 < max(X, Y)):
    print(0)
    sys.exit()

# 目的地までの移動回数
n = (X+Y)//3

# 少ない方の使用回数
r = 2*n-max(X, Y)

# n個の中からr個選ぶ組み合わせ
mod = pow(10, 9)+7
bunshi = 1
bunbo = 1
for i in range(r):
    bunshi = (bunshi*(n-i)) % mod
    bunbo = (bunbo*(i+1)) % mod

ans = (bunshi*pow(bunbo, -1, mod)) % mod

print(ans)


Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
ll mypow(ll a, ll b) {
  ll result = 1;
  for(ll i = 0; i < b; i++){
    result = result * a % 1000000007;
  }
  return result;
}
 
int main() {
  ll n;
  cin >> n;
  
  ll result;
  result = mypow(10, n) - 2 * mypow(9, n) + mypow(8, n);
  result %= 1000000007;
  result = (result + 1000000007) % 1000000007;
  
  cout << result << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int a[25],n;
double dp[25][200005];
int main(){
	cin >> n ; for(int i=1;i<=n;i++) cin >> a[i];
	rep(j,25) rep(i,200005) dp[j][i] = 1e9;
	dp[0][1] = 0;
	double ans = 1e9;
	for(int i=1;i<=n;i++){
		for(int j=1;j<200005;j++){
			for(int k=j;k<200005;k+=j){
				if(dp[i-1][j] < 1e8){
					dp[i][k] = min(dp[i][k],max(dp[i-1][j],(double)(abs(k-a[i]))/(double)(a[i])));
					if(i==n) ans = min(ans,dp[i][k]);
				}
			}
		}
	}
	printf("%.12f\n",ans);
}

Measured memory_bytes: 42268
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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; }

ll mod_pow(ll x, ll n, ll mod=mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

int main () {
  int n;
  cin >> n;
  vi cnt(n);
  rep(i,n) {
    int a;
    cin >> a;
    cnt[a]++;
  }

  rep(i,n) {
    bool ok = true;
    if (n%2 != 0) {
      if (i == 0) {
        if (cnt[i] != 1) ok = false;
      }
      else if (i%2 != 0 && cnt[i] != 0) ok = false;
      else if (i%2 == 0 && cnt[i] != 2) ok = false;
    }
    else {
      if (i%2 != 0 && cnt[i] != 2) ok = false;
      else if (i%2 == 0 && cnt[i] != 0) ok = false;
    }
    if (!ok) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = mod_pow(2,n/2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
	while (1) {
		int H, W;
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
					cout << "#";
				}

				else cout << ".";

			}
			cout << endl;
		}
		cout << endl;
	}
}
	


Measured memory_bytes: 3056