akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

vector<string> explode(string const & s, char delim) {
    vector<string> result;
    istringstream iss(s);

    for (string token; getline(iss, token, delim);) {
        result.push_back(move(token));
    }
    return result;
}

void solve() {
    string s;
    getline(cin, s);
    auto v = explode(s, ' ');
    deque<int> q;
    for (auto t : v) {
        if (t == "+") {
            int a = q.back(); q.pop_back();
            int b = q.back(); q.pop_back();
            q.emplace_back(a + b);
        } else if (t == "-") {
            int a = q.back(); q.pop_back();
            int b = q.back(); q.pop_back();
            q.emplace_back(b - a);
        } else if (t == "*") {
            int a = q.back(); q.pop_back();
            int b = q.back(); q.pop_back();
            q.emplace_back(a * b);
        } else {
            q.emplace_back(stoi(t));
        }
    }
    cout << q.back() << endl;
}



Measured memory_bytes: 3236
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
check = [0]*N
ima = 0

for i in range(K):
  if check[A[ima]-1] != 0:
    loopen = ima
    check[ima] = i+1
    looplen = check[ima] - check[A[ima]-1] + 1
    loopend = i
    break
  if i == K-1:
    print(A[ima])
    exit()
  check[ima] = i+1
  ima = A[ima]-1

offset = (K-(i-looplen)-1)%looplen
ima = 0
for i in range(loopend-looplen+offset+1):
  ima = A[ima]-1
print(ima+1)


Measured memory_bytes: 32176
n,m,q=gets.split.map &:to_i
s=[]
result = []
q.times do
  num = gets.split.map &:to_i
  s << num
end
ar = [*(1..m)].repeated_combination(n).to_a
ar.each do |ar|
  sum = 0
  s.each do |s|
    a,b,c,d=s[0],s[1],s[2],s[3]
    sum = sum + d if ar[b-1] - ar[a-1] == c
  end
  result << sum
end
puts result.max

Measured memory_bytes: 28736
import java.util.*;

  class Main{
    public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      /*int[][] a = new int[n+2][m+2];
      for(int i = 0; i <= n+1; i++)Arrays.fill(a[i],0);
      for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
          a[i-1][j-1] = revers(a[i-1][j-1]);
          a[i-1][j] = revers(a[i-1][j]);
          a[i][j-1] = revers(a[i][j-1]);
          a[i-1][j+1] = revers(a[i-1][j+1]);
          a[i][j] = revers(a[i][j]);
          a[i][j+1] = revers(a[i][j+1]);
          a[i+1][j-1] = revers(a[i+1][j-1]);
          a[i+1][j] = revers(a[i+1][j]);
          a[i+1][j+1] = revers(a[i+1][j+1]);
        }
      }
      for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
          System.out.print(a[i][j]);
        }
        System.out.println();
      }
    }

    static int revers(int i){
      return 1-i;
    }*/
    if(m==1&&n==1)System.out.print(1);
    else if(m==2||n==2)System.out.print(0);
    else System.out.print((long)(n==1?1:n-2)*(m==1?1:m-2));
  }
}


Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

long long gcd(long long a, long long b){

    if(a < b){
        long long temp = a;
        a = b;
        b = temp;
    }

    if(b == 0 ) return a;

    return gcd(b, a % b);

}

int main(){

    long long n, k;
    cin >> n >> k;

    vector<long long>v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    if(v[n-1] < k){
        cout << "IMPOSSIBLE" << endl;
    }
    else{
        long long g = 0;
        for(int i = 0; i < n; i++){
            g = gcd(v[i], g);
        }
        
        k = k % g;
        for(int i = 0; i < n; i++){
            if(v[i] % g == k){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
        cout << "IMPOSSIBLE" << endl;
    }

}

Measured memory_bytes: 1024
S = input()
L = [i for i in range(97,123)]
n = len(S)
for i in range(n):
    L.remove(ord(S[i]))
if n <= 25:
    X = L[0]
    ans = S + chr(X)
else:
    T = []
    x = S[-1]
    T.append(x)
    for i in range(2,27):
        y = S[-i]
        if y > x:
            x = y
            T.append(y)
        else:
            break
    m = 26 - len(T)
    if m > 1:
        ans = S[0]
        for i in range(1,m-1):
            ans += S[i]
        for t in T:
            if t > S[m-1]:
                ans += t
                break
    elif m == 0:
        ans = -1
    else:
        for t in T:
            if t > S[m-1]:
                ans = t
                break
print(ans)

Measured memory_bytes: 3064
# coding: utf-8
# Your code here!
N,M =map(int,input().split(" "))

num =[]
for i in range(M):
    l,m =map(int,input().split(" "))
    x =[m,l]
    num.append(x)
num.sort()
#print(num)
t = num[0][0]
ans =1
for i in range(1,M):
    k =num[i][1]
    if t<=k:
        t = num[i][0]
        ans +=1
        #print(k)
print(ans)

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n){
        int a;
        cin >> a;
        while(a % 2 == 0 && a > 0){
            a /= 2;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
list_A = [ list(map(int,input().split(" "))) for i in range(n)]
list_A.insert(0, [0, 0, 0])
ans = "Yes"
for i in range(1, n+1):
    l = list_A[i]
    k = list_A[i-1]
    distance = abs(l[1]-k[1]) + abs(l[2]-k[2])
    if distance > l[0] - k[0]:
        ans = "No"
        break
    else:
        if (distance - (l[0]-k[0])) % 2 == 1:
            ans = "No"

print(ans)

Measured memory_bytes: 27324
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	vector<int> a(3 * n);
	for (int i = 0; i < 3 * n; i++)
	{
		cin >> a.at(i);
	}

	sort(rall(a));

	ull res = 0;
	for (int i = 0; i < 2 * n; i += 2)
	{
		res += a.at(i + 1);
	}

	println(res);
}


Measured memory_bytes: 1408
s = input()
t = input()

can = False
for i in range(len(s)):
    if s == t:
        can = True
        break
    slist = list(s)
    tmp = slist[0]
    del(slist[0])
    slist.append(tmp)
    s = ''.join(slist)

if can:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std ; 
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
//template<class C> min(C x,C y){ if(x>y) return y ; return x ; } 
//template<class C> max(C x,C y){ if(x>y) return x ; return y ; } 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main() 
{
	int n ; cin>>n ; //, k ; cin>>n>>k ; 
	//cout<<n*n*n<<endl;	
	vi A(n) , B(n) , C(n-1) ;
	for(int i = 0 ; i <n ; i++ )cin>>A[i] ; 
	for(int i = 0 ; i <n ; i++ )cin>>B[i] ; 
	for(int i = 0 ; i <n-1 ; i++ )cin>>C[i] ; 
	int last = -3 , ans = 0 ; 
	for(int i = 0 ;i < n ; i++ )
	{
		A[i] -- ;
		ans += B[A[i]] ;
		//cout<<last<<" "<<A[i]-1<<endl;
		if(last == A[i] - 1) 
		{
			ans += C[last] ;
		//	cout<<ans<<endl; 
		}
		last = A[i] ; 
		//cout<<ans<<" "<<C[0]<<endl;
	} 
	cout<<ans<<endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> L(N);

  rep(i,N){
    cin >> L[i];
  }

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

  auto ans = 0;

  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      int ij = L[i] + L[j];

      int itr = lower_bound(L.begin(),L.end(),ij) - L.begin();
      int temp = itr - (j+1);
      ans += temp;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> b(n, 1);
    vector<pair<bool, bool> > rw(n);
    rw[0] = make_pair(1, 0);
    REP(i,1,n)rw[i] = make_pair(0, 1);
    rep(i,m){
        ll x, y;
        cin >> x >> y;
        x--; y--;
        if(!rw[x].first && rw[x].second)rw[y].second = 1;
        else if(rw[x].first && !rw[x].second)rw[y].first = 1;
        else rw[y].first = rw[y].second = 1;
        b[x]--; b[y]++;
        if(b[x] == 0)rw[x].first = rw[x].second = 0;
    }

    ll ans = 0;
    rep(i,n)if(rw[i].first)ans++;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15

signed main(){
  fast;
  int r,d,x;
  cin>>r>>d>>x;
  for(int i=1;i<=10;i++){
  	x = r*x-d;
  	cout<<x<<endl;
  }

}
  


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int i,j,temp,rtime,tri[3];

	scanf("%d",&rtime);
	
	for(i = 0;i < rtime;i ++){
		for(j = 0;j < 3;j ++){
			scanf("%d",&tri[j]);
		}
		for(j = 0;j < 3;j ++){
			temp = tri[0] * tri[0];
			if(temp == tri[1] *tri[1] + tri[2] * tri[2]){
				printf("YES\n");
				break;
			}
			if(j == 2){
				printf("NO\n");
			}
			temp = tri[2];
			tri[2] = tri[1];
			tri[1] = tri[0];
			tri[0] = temp;
		}
	}
	return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int x, y;
	cin >> x >> y;
	(y % 2 == 0 && y/2 - x >= 0 && y <= 4*x) ? cout << "Yes" << "\n" : cout << "No" << "\n";;	
	return 0;
}


Measured memory_bytes: 3656
k = int(input())
cnt = 0
for i in range(1,k+1):
  for j in range(i+1,k+1):
    if (i % 2 == 0 and j % 2 == 1) or (j % 2 == 0 and i % 2 == 1):
      cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int a[110][110],n,m,f[110][110];
int main()
{
    int i,j,x,y;
    char s;
    cin>>n>>m;
    for(i=1;i<=n;i++)
     for(j=1;j<=m;j++)
     {
         cin>>s;
         if(s=='#') a[i][j]=1;
         else a[i][j]=0;
     }
    f[1][1]=(a[1][1]==1);
    for(i=1;i<=n;i++)
     for(j=1;j<=m;j++)
     {
         x=i;y=j;
         if(x*y!=1) f[x][y]=999999;
     if(x>1)
     {
         if(a[x][y]==0||a[x-1][y]==1) f[x][y]=min(f[x][y],f[x-1][y]);
         else f[x][y]=min(f[x][y],f[x-1][y]+1);
     }
     if(y>1)
     {
         if(a[x][y]==0||a[x][y-1]==1) f[x][y]=min(f[x][y],f[x][y-1]);
         else f[x][y]=min(f[x][y],f[x][y-1]+1);
     }
    }
    cout<<f[n][m];
    //system("pause");
}
      


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

int main() {
 int x,y;
 cin>>x>>y;
 int res=0;
 for(int i=0;i<=x;i++)
 {
 	if(y==(2*i+4*(x-i)))
 	{
 		res++;
 		break;
 	}
 }
 if(res)
 cout<<"Yes"<<endl;
 else 
 cout<<"No"<<endl;
 	
return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll n,m,k;
    cin>>n>>m>>k;
    ll a[n],b[m];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<m;i++) cin>>b[i];
    vector<ll> cum(m,0);
    for(int i=0;i<m;i++){
        cum[i]=b[i];
        if(i!=0) cum[i]+=cum[i-1];
    }
    ll ans=0,cur=0;
    for(int i=0;i<n;i++){
        if(cur>k) break;
        ll id=upper_bound(all(cum),k-cur)-cum.begin();
        ans=max(ans,i+id);
        cur+=a[i];
    }
    if(cur<=k){
        ll id=upper_bound(all(cum),k-cur)-cum.begin();
        ans=max(ans,n+id);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long

const ll inf = 1e18+7;
const int N = 1e6;
const int mod = 1e9+7;

ll n, a[N];

int main()
{
	cin >>n;
	int col=0;
	cout << n * (n-1) / 2;	
 	return 0;
}

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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;
map<string,Int> Dict;
map<string,Int> exist;

int main(void) {
    cin>>N;
    
    for(int i = 0;i < N;i++) {
        vector<char> v;
        string s;
        cin>>s;
        for(int j = 0;j < s.size();j++) {
            v.push_back(s[j]);
        }
        sort(v.begin(),v.end());
        string key = "";
        for(int j = 0;j < s.size();j++) {
            key += v[j];
        }

        
        Dict[key] += exist[key];
        exist[key] += 1;
    }

    Int ans = 0;
    for(auto v: Dict) {
        if(v.second >= 1) {
            ans += v.second;
        }
    }

    cout<<ans<<endl;
    
    return 0;
}


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

public class Main {

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

		int cost = Integer.parseInt(br.readLine());
		int month = 0;
		boolean more = true;
		StringBuilder sb = new StringBuilder();

		while (true) {

			line = br.readLine();
			if (line == null || line.isEmpty())
				break;

			if (line.contains(" ") && more) {
				int in = Integer.parseInt(line.substring(0, line.indexOf(' ')));
				int out = Integer
						.parseInt(line.substring(line.indexOf(' ') + 1));
				cost -= in - out;
				month++;
				if (cost <= 0) {
					more = false;
					continue;
				}
			} else if (!line.contains(" ") && !line.equals("0")) {
				if (cost <= 0) {
					sb.append(month + "\n");
				} else {
					sb.append("NA\n");
				}
				cost = Integer.parseInt(line);
				month = 0;
				more = true;
			} else if (line.equals("0")) {
				if (cost <= 0) {
					sb.append(month + "\n");
				} else {
					sb.append("NA\n");
				}
			}
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 21016
/**
       **********    ************
	  Author : Avi J Patel
	  University : DAIICT
       **********    ************
**/
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 1844674407370955161
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define min_heap priority_queue<int, vector<int>, greater<int>>
#define max_heap priority_queue<int>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define pp pair<pair<int,int>,pair<int,int>>
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> 

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    if(a.ss < b.ss) return true; 
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.ff>b.ff) return true;
	else if(a.ff==b.ff) return a.ss<b.ss;
	else return false;
} 
bool sortff_resortss(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.ff<b.ff) return true;
	else if(a.ff==b.ff) return a.ss>b.ss;
	else return false;
}
bool sortbystring(const string &a, const string &b)
{
	string c=a+b;
	string d=b+a;
	if(c>=d) return true;
	else return false;
}

ll modi(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
ll Logn(ll  n, ll r) 
{ 
    return (n > r - 1) ? 1 + Logn(n / r, r) : 0; 
} 

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 


int main()
{
	FAST
	int t=1;
//	cin>>t;
	while(t--)
	{	
		ll n;
		cin>>n;
		ll ans=0;
		ans+=(n/500)*1000;
//		cout<<ans;
		n-=(n/500)*500;
		ans+=(n/5)*5;
		cout<<ans;
	}
	return 0;
}
















Measured memory_bytes: 256
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
ans = 'Yes'
n = min(len(s), len(t))
if s[:n] == t[:n]:
    if len(s) >= len(t):
        ans = 'No'
else:
    for sc, tc in zip(s, t):
        if sc == tc:
            continue
        if sc > tc:
            ans = 'No'
        else:
            ans = 'Yes'
        break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void calculate(int& N, int& K, int& C, string& S)
{
  vector<int> o_position, work_day_min(K), work_day_max(K);
  for (int i = 0; i < N; i++)
    if (S[i] == 'o')
      o_position.push_back(i);
  int count = 0;
  for (int i = o_position[0]; i < N && count <= K; i++)
    if (S[i] == 'o'){
      work_day_min[count] = i;
      i += C;
      count++;
    }
  count = K - 1;
  for (int i = o_position[o_position.size() - 1]; i > 0 && count >= 0; i--)
    if (S[i] == 'o'){
      work_day_max[count] = i;
      i -= C;
      count--;
    }
  for (int i = 0; i < K; i++)
    if (work_day_min[i] == work_day_max[i])
      cout << work_day_min[i] + 1 << '\n';
}

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K, C;
  string S;
  cin >> N >> K >> C >> S;
  calculate(N, K, C, S);
  return 0;
}


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


def main():
    n,a,b = map(int, input().split())
    ans = 0
    list_s = []

    num = 0
    for i in range(n+1):
        for j in range(len(str(i))):
            m = str(i)[j]
            num += int(m)

        if a <= num <= b:
            ans += i
        num = 0

    print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 74248
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
#    n = 10**5
    p = [int(i) for i in ipt().split()]
#    p = [int(n-i) for i in range(n)]
    ip = [0]*(n+1)
    for i,pi in enumerate(p):
        ip[pi] = i
    ans = 0

    os = [-1,-1,n,n]
    for i in range(n,0,-1):
        pl = ip[i]
        j = bisect.bisect_left(os,pl)
        w,x,y,z = os[j-2],os[j-1],os[j],os[j+1]
        ans += i*((x-w)*(y-pl)+(pl-x)*(z-y))
        os.insert(j,pl)

    print(ans)


    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 91696
#include <bits/stdc++.h>
// For policy based data structure
/*#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> */
using namespace std;
/*using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set;*/
 
#define MD 1000000007
#define X first
#define Y second
#define pb push_back
#define debug(val, ch) cout <<val <<ch
 
typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<int, bool> pib;
typedef pair<bool, int> pbi;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
void sieve(vector<bool>&isprime)
{
	int i,j,k;
	for(i=2;i<=sqrt(1000000);i++)
	{
		if(!isprime[i])
		{
			for(j=2*i;j<=1000000;j+=i)
			{
				isprime[j]=1;
			}
		}
	}
}
/*********************************************************************/
void test(int r)
{
	vector<bool>pr(1e6+1,0);
	sieve(pr);
	vector<int>pi;
	int n;
	cin>>n;
	vector<int>v(n);
	int i;
	for(i=0;i<n;i++)
		cin>>v[i];
	for(i=2;i<=1e6;i++)
	{
		if(!pr[i])
		{
			pi.pb(i);
		}
	}
	// cout<<pi.size()<<endl;
	vector<int>pc(1e6+1,0);
	for(i=0;i<n;i++)
	{
		int j;
		int x=v[i];
		for(j=0;pi[j]<=sqrt(x)&&j<pi.size();j++)
		{
			if(x%pi[j]==0)
			{
				pc[pi[j]]++;
				while(x-(x/pi[j])*pi[j]==0)
				{
					x=x/pi[j];
				}
			}
			if(x==1)
				break;
		}
		if(x!=1)
			pc[x]++;
	}
	int f=0;
	for(i=2;i<=1e6;i++)
	{
		f=max(f,pc[i]);
	}
	if(f<=1)
	{
		cout<<"pairwise coprime";
	}
	else if(f!=n)
	{
		cout<<"setwise coprime";
	}
	else
	{
		cout<<"not coprime";
	}

	

}
/***********************************************************************/
int main()
{
	fast();
    int t=1,r;
    // cin>>t;
    for(r=1;r<=t;r++)
        test(r);
    return 0;
}

Measured memory_bytes: 11668
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := readInt()
	m := make(map[int]bool)
	for i := 0; i < n; i++ {
		d := readInt()
		m[d] = true
	}
	fmt.Println(len(m))
}


Measured memory_bytes: 640
#include <stdio.h>
#define int long long

int main()
{
  int n, i, sum = 0;
  int a[200005];
  int b[200005];
  int c[200005];
  int d[200005];
  
  scanf("%d", &n);
  
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[a[i]]++;
  }
  
  for (i = 1; i <= n; i++) {
    c[i] = b[i]*(b[i]-1)/2;
    d[i] = (b[i]-1)*(b[i]-2)/2;
    sum += c[i];
  }
  
  for (i = 1; i <= n; i++)
    printf("%lld\n", sum-c[a[i]]+d[a[i]]);
  
  return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll n;
    cin >> n;
    int res = INT_MAX;
    rep(i, 1, (int)sqrt(n) + 1)
        if (n % i == 0)
            res = min(res, max((int)floor(log10(i)) + 1, (int)floor(log10(n/i)) + 1));
    cout << res;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char s[200020];
int main()
{
	int n,a,b,c,d,i;cin>>n>>a>>b>>c>>d;
	cin>>s+1;
	for (i=b;i<d;i++)
	{
		if (s[i+1]=='#' && s[i]=='#') {puts("No");exit(0);}
	}
	for (i=a;i<c;i++)
	{
		if (s[i+1]=='#' && s[i]=='#') {puts("No");exit(0);}
	}
		if (d>c) puts("Yes");
		else
		{
			for (i=b;i<=d;i++) if (s[i-1]==s[i] && s[i]==s[i+1] && s[i]=='.') {puts("Yes");exit(0);}
			puts("No");
		}
}


Measured memory_bytes: 384
#include <iostream>
#include <stack>
#include <string>

using namespace std;

bool judge(string &str);

main(void) {
	string text;
	while(1) {
		
		getline(cin, text);
		if(text[0] == '.')		break;
		
		if( judge(text)) {
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}
}

bool judge(string &str) {
	stack<char> S;
	char c;
	for(unsigned int i = 0; i < str.size(); ++i) {
		
		if(str[i] == '(' || str[i] == '[') {
			S.push( str[i] );
		} else if(str[i] == ')' ) {
			//スタックが空の時だったらはじく
			if( S.empty() )					return false;
			//直前のかっこが[の時だったらはじく
			c = S.top();
			if( c != '(' )		return false;
			S.pop();
		} else if(str[i] == ']' ) {
			//スタックが空の時だったらはじく
			if( S.empty() )					return false;
			//直前のかっこが(の時だったらはじく
			c = S.top();
			if( c != '[' )		return false;
			S.pop();
		}
	}
		return S.empty();
}

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

long long floor_sum(long long n, long long m, long long a, long long b) {
    long long sum = 0;
    if (a >= m) {
        sum += (a / m) * n * (n - 1) / 2;
        a %= m;
    }
    if (b >= m) {
        sum += (b / m) * n;
        b %= m;
    }
    long long y = (a * n + b) / m;
    long long x = y * m - b;
    if (y == 0) return sum;
    sum += (n - (x + a - 1) / a) * y;
    sum += floor_sum(y, a, m, a - 1 - (x + a - 1) % a);
    // sum += floor_sum(y, a, m, (a - x % a) % a);
    return sum;
}

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

    int T;
    cin >> T;
    while (T--) {
        int N, M, A, B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << "\n";
    }
}

Measured memory_bytes: 3644
use std::io::BufRead;

fn main() {
   let stdin = std::io::stdin();
   let [mut ac, mut wa, mut tle, mut re] = [0u32; 4];

   {
       let mut s = String::new();
       stdin.read_line(&mut s).expect("err");
   }

   for line in stdin.lock().lines() {
       match line.unwrap().trim() {
           "AC" => ac += 1,
           "WA" => wa += 1,
           "TLE" => tle += 1,
           "RE" => re += 1,
           _ => (),
       }
   }

   println!("AC x {}", ac);
   println!("WA x {}", wa);
   println!("TLE x {}", tle);
   println!("RE x {}", re);
}


Measured memory_bytes: 2080
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<stdio.h>
#include<vector>
#include<map>
using namespace std;

int N, L;
int list[210];
int ans;

int main() {
	cin >> N >> L;
	for (int i = 1; i <= N; i++) {
		list[i] = i - 1 + L;

		ans += list[i];
		if (list[i] < 0) {
			list[i] *= -1;
		}
	}
	sort(list, list + N + 1);
	if (ans >= 0) {
		ans -= list[1];
	}
	else {
		ans += list[1];
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;

typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999


int main(){
  int n;
  scanf("%d",&n);
  n=n*n*n;
  printf("%d",n);
}


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

typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;

int main()
{
    ll arr[3] ;
    cin >> arr[0] >> arr[1] >> arr[2] ;
    sort(arr, arr + 3) ;

    if ((arr[0] == arr[1] and arr[0] != arr[2]) or (arr[1] == arr[2] and arr[1] != arr[0])) cout << "Yes" << endl ;
    else    cout << "No" << endl ;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N, M;
		long ans = 1;

		N = Integer.parseInt(sc.next());
		M = Integer.parseInt(sc.next());

		if(Math.abs(N - M) == 0){
			for(int i = N; i > 0; i--){
				ans = (ans * i) % (int)(Math.pow(10, 9) + 7);
			}
			for(int i = M; i > 0; i--){
				ans = (ans * i) % (int)(Math.pow(10, 9) + 7);
			}
			ans = (ans * 2) % (int)(Math.pow(10, 9) + 7);
		}else if(Math.abs(N - M) == 1){
			for(int i = N; i > 0; i--){
				ans = (ans * i) % (int)(Math.pow(10, 9) + 7);
			}
			for(int i = M; i > 0; i--){
				ans = (ans * i) % (int)(Math.pow(10, 9) + 7);
			}
		}else{
			ans = 0;
		}

		System.out.println(ans);

	}

}

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;


int main() {
  int N;
  cin >> N;
  map< int64, int > app;
  app[0] = 1;
  int64 sum = 0, ret = 0;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    sum += x;
    ret += app[sum];
    app[sum]++;
  }
  cout << ret << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  cout << reduce(v.begin(), v.begin() + K, 0LL) << endl;
}


Measured memory_bytes: 3596
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod = 1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn = 200111;
int n, M;
int a[maxn];
bool check(int x)
{
	for (int i=1; i<=x; i++)
	{
		if (a[2*n-x+i]+a[2*n-x-i+1]<M) return false;
	}
	return true;
}
int main()
{
	getii(n, M);
	for (int i=1; i<=2*n; i++)
	{
		geti(a[i]);
	}
	sort(a+1, a+2*n+1);
	int l = 0, r = n;
	while (l<=r)
	{
		int m = l+r>>1;
		if (check(m)) l = m+1;
		else r = m-1;
	}
	int ans = 0;
	int x = r;
	for (int i=1; i<=x; i++) ans = max(ans, a[2*n-x+i]+a[2*n-x-i+1]-M);
	for (int i=1; i<=2*n-2*x; i++) ans = max(ans, a[i]+a[2*n-2*x-i+1]);
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

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

typedef long long LL;
typedef pair<int, int> Pii;

const int inf = 0x3f3f3f3f;
const LL infLL = 0x3f3f3f3f3f3f3f3fLL;

int S(LL n) {
  int ret = 0;
  do
    ret += n % 10;
  while (n /= 10);
  return ret;
}

inline bool check(int p, LL b) {
  LL n = p * b + (b - 1);
  return n <= b * S(n);
}

int main() {
  // For(n, 1, 10000000) {
  //   bool ok = true;
  //   For(m, n + 1, n * 2) if (n * S(m) > m * S(n)) {
  //     ok = false;
  //     break;
  //   }
  //   if (ok) printf("%d: %.10f\n", n, (double)n / S(n));
  // }

  vector<LL> vec;
  for (LL b = 1; b < 1000000000000000LL; b *= 10) {
    int l = 1, r = 1000;
    while (l < r) {
      int mid = (l + r + 1) / 2;
      if (check(mid, b))
        l = mid;
      else
        r = mid - 1;
    }
    For(i, 1, l) vec.push_back(i * b + (b - 1));
  }
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  // for (LL v : vec) printf("%lld\n", v);

  int k;
  scanf("%d", &k);
  rep(i, k) printf("%lld\n", vec[i]);

  return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class BOneClue {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int k,x;
        in>>k>>x;
        for(int i=max(-1000000,x-k+1);i<=min(1000000,x+k-1);++i) out<<i<<" ";
        out<<endl;
    }
};

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


Measured memory_bytes: 256
user1,user2,user3=map(int,input().split())

if user3<user2:
    user3,user2=user2,user3

if user2<user1:
    user2,user1=user1,user2

if user3<user2:
    user2,user3=user3,user2

print(user1,user2,user3)

Measured memory_bytes: 7692
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int n,Mod;
void add(int& x,int y)
{
	x+=y;
	if(x>=Mod)x-=Mod;
	return ;
}
int A[510],B[510];
int f[510][510];
int calc(int x,int a,int b)
{
	int res=1;
	for(int i=A[x];i>A[x+1];i--)
	{
		int cur=n*2-i;
		if(x-a-cur<0)res=0;
		res=(long long)res*(x+1-a-cur+Mod)%Mod;
	}
	for(int i=B[x];i>B[x+1];i--)
	{
		int cur=n*2-i;
		if(A[i-1]-b-cur<0)res=0;
		res=(long long)res*(A[i-1]-b-cur+Mod)%Mod;
	}
//	if(!a&&!b){
//		printf("calc(%d)=%d\n",x,res);
//	}
	return res;
}
int solve(int m)
{
	//choose exactly m
	memset(f,0,sizeof(f));
	f[0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<=m;j++)
		{
			add(f[i+1][j],(long long)f[i][j]*calc(i,j,m-j)%Mod);
			if(j<m)add(f[i+1][j+1],(long long)f[i][j]*calc(i,j+1,m-j-1)%Mod);
		}
	int ans=f[n][m];
	for(int i=A[n];i>B[0];i--)
	{
		int cur=n*2-i;
		if(A[i-1]-m-cur+Mod<0)ans=0;
		ans=(long long)ans*(A[i-1]-m-cur+Mod)%Mod;
	}
//	printf("%d:%d\n",m,ans);
	return ans;
}
int main()
{
	scanf("%d %d",&n,&Mod);
	for(int i=0;i<n*2;i++)
	{
		while(A[i]<(n*2)&&A[i]*A[i]+i*i<=(n*2)*(n*2))
			A[i]++;
		while(B[i]<n&&B[i]*B[i]+i*i<n*n)
			B[i]++;
	}
	int ans=0;
	for(int i=0;i<=n;i++)
		if(i&1)ans=(ans-solve(i)+Mod)%Mod;
		else ans=(ans+solve(i))%Mod;
	printf("%d\n",ans);
	return 0;
}

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

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

	// ( mod 13 )
	const int N = 13;

	//dp配列
	vector<int64_t> dp(N);
	// 0%13=0なので余り0の個数を1にする
	dp[0] = 1;

	//答えはこれで割った余りを出力
	int64_t mod = 1e9+7;

	//何の位かを表す（1の位、10の位、100の位、......）
	int64_t mul = 1;

	//文字列を一桁ずつ見ていく（1の位から見ていくよ）
	for(int i = S.size()-1; i >= 0; i--)
	{
		//更新したdp配列
		vector<int64_t> nextDP(N);

		char c = S[i];

		if(c == '?')
		{
			//'?'が0-9の場合をそれぞれ考えていく
			for(int k = 0; k < 10; k++)
			{
				//各余りの個数を更新
				for(int j = 0; j < N; j++)
				{
					//(k * mul + j)は、一つ前のdp配列のインデックスが
					//次のdp配列のインデックスがいくつがずれるか
					//つまり、余りの個数が移動する
					nextDP[(k * mul + j) % 13] += dp[j];
					nextDP[(k * mul + j) % 13] %= mod;
				}
			}
		}
		else
		{
			//文字cをintに変換
			int k = (int)(c - '0');

			//各余りの個数を更新
			for(int j = 0; j < N; j++)
			{
				//(k * mul + j)は、一つ前のdp配列のインデックスが
				//次のdp配列のインデックスがいくつがずれるか
				//つまり、余りの個数が移動する
				nextDP[(k * mul + j) % 13] += dp[j];
				nextDP[(k * mul + j) % 13] %= mod;
			}
		}

		//dp配列を更新
		dp = nextDP;

		//次の位に更新
		mul *= 10;
		//ここで余りをとっても結果は変わらない
		mul %= N;
	}

	//余り5の個数を出力
	cout << dp[5] << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  for (int i=0; i<=N; i+=7) {
    if ((N-i)%4==0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
      cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using std::cin;
using std::cout;
typedef long long ll;
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e6 + 5;
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
struct str
{
	int cnt, *addr;
	bool operator<(str A) const { return cnt < A.cnt; }
} d[Maxn];
int Disc(int t)
{
	rg int tmp = 0;
	std::sort(d + 1, d + t + 1);
	for (int i = 1; i <= t; i++)
	{
		if (i == 1 || d[i].cnt != d[i - 1].cnt)
			d[++tmp] = d[i];
		*d[i].addr = tmp;
	}
	return tmp;
}
int prime[Maxn], cnt, ans;
bool P[Maxn];
ll A, B;
ll gcd(ll x, ll y)
{
	ll z = x % y;
	while (z)
	{
		x = y;
		y = z;
		z = x % y;
	}
	return y;
}
int main()
{
	for (int i = 2; i <= 1000000; i++)
	{
		if (!P[i])
			prime[++cnt] = i;
		for (int j = 1; j <= cnt && i * prime[j] <= 1000000; j++)
		{
			P[i * prime[j]] = true;
			if (i % prime[j] == 0)
				break;
		}
	}
	rg ll x;
	cin >> A >> B;
	x = gcd(A, B);
	for (int i = 1; i <= cnt && x != 1; i++)
		if (x % prime[i] == 0)
		{
			ans++;
			while (x % prime[i] == 0)
				x /= prime[i];
		}
	if (x != 1)
		ans++;
	cout << ans + 1 << '\n';
	return 0;
}
//D


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
int main(void) {
    int n, m; cin >> n >> m;
    int ans = n*(n-1)/2 + m*(m-1)/2;
    cout << ans;
}


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

using namespace std;

typedef long long int lli;

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

    const lli mod = 1000000007;
    string s;
    cin >> s;

    int bitcount[8] = {0, 1, 1, 2, 1, 2, 2, 3};
    lli pow3[100001] = { 1 }, qnum = 0;
    for (int i=1; i<=100000; i++) {
        pow3[i] = (pow3[i-1]*3) % mod;
    }
    for (int i=0, len=s.size(); i<len; i++) {
        if (s[i] == '?') qnum++;
    }

    lli ans = 0, a, ab, abc;
    for (int pat=0; pat<=7; pat++) {
        a = ab = abc = 0;
        //int i=0, len=s.size(); i<len; i++) {
        for (auto c : s) {
            switch (c) {
            case '?':
                if (pat&0b001) abc += ab;
                if (pat&0b010) ab += a;
                if (pat&0b100) a++;
                break;
            case 'A':
                if (!(pat&0b100)) a++;
                break;
            case 'B':
                if (!(pat&0b010)) ab += a;
                break;
            case 'C':
                if (!(pat&0b001)) abc += ab;
                break;
            }
        }
        int q = qnum - bitcount[pat];
        ans = (ans + (abc%mod * pow3[max(0, q)])%mod) % mod;
    }

    cout << ans << endl;

    return 0;
}

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

long long sum = 0, x = 0, ans = 1000000000000000000LL;

int main() {
    int n; cin >> n;
    vector<long long> a(n);
    rep(i, 0, n) {
        cin >> a[i];
        sum += a[i];
    }
    rep(i, 0, n) {
        x += a[i];
        if (i + 1 < n){
            ans = min(ans, abs(sum - 2 * x));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
from decimal import *
import math
a,b,c=input().strip().split(" ")

a,b,c=[int(a),int(b),int(c)]
getcontext().prec=500
p=Decimal(a).sqrt()
q=Decimal(b).sqrt()

r=Decimal(c).sqrt()

if p+q<r:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5204
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    int a;
    int r = 0;
    cin >> a;
    for(int i=0;i<=a;i++){
        if(!(i % 3 == 0 || i % 5 == 0)){r+=i;}
    }
    cout << r << endl;
}

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

using namespace std;
using   ll=long long;

#define fast            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl            "\n"
#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define int             long long int
#define pll                pair<int , int>

#define ALL(v)          v.begin(),v.end()
#define ALLR(v)         v.rbegin(),v.rend()
#define pii             3.14159265358979323
#define inf             LLONG_MAX
#define ones(x)         __builtin_popcount(x)
#define fill(a,b)       memset(a,b,sizeof(a))
#define mod             1000000007
#define hell            998244353
const int maxn = 2e5 + 1;

vector<vector<int>> a(maxn);

int tot;

int vis[maxn];

void dfs(int u) {
	vis[u] = 1;
	
	tot++;
	
	for(auto v : a[u]) {
		if(!vis[v])  {
			dfs(v);
		}
	}
}

void solve()
{
	int n , m;
	
	cin >> n >> m;
	
	for(int i = 0; i < m; ++i) {
		int x , y;
		
		cin >> x >> y;
		
		a[x].pb(y);
		a[y].pb(x);
	}
	
	int ans = 0;
	
	for(int i = 1; i <= n; ++i) {
		if(!vis[i]) {
			tot = 0;
			
			dfs(i);
			
			//cout << i <<" " << tot << endl;
			
			ans = max(ans , tot);
		}
	}
	
	cout << ans;
}

signed main() {
    fast;

    int t = 1;
   
    //cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 21968
#include <stdio.h>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 10e7;
  scanf("%lld", &n);
  for(i = 1; i < n; ++i) {
    ll a = i, b = n - i, t;
    t = 0;
    while(a || b) {
      t += a % 10;
      t += b % 10;
      a /= 10, b /= 10;
    }
    if(ans > t) {
      ans = t;
    }
  }
  printf("%lld", ans);
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int s = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        s = (s ^ A[i]);
    }
    for (int i = 0; i < N; ++i) {
        cout << (s ^ A[i]) << endl;
    }
}


Measured memory_bytes: 3936
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;


int main() {
	int n, k;
	cin >> n >> k;
	vector<ll>h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end());
	reverse(h.begin(), h.end());
	ll ans = 0;
	for (int i = k; i < n; i++) {
		ans += h[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
	int n, g;
	scanf("%d", &n);
	g = n / 100;
	g = g * 100 + g * 10 + g;
	if(n <= g)printf("%d\n", g);
	else printf("%d\n", g + 111);
	return 0;
}


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

int f(int n, int i,int a[30]){
for(int j=n;j>=1;j--){
	if(i==0 || a[i-1] >= j ){
		a[i]=j;
		if(n-j>0){
			f(n-j,i+1,a);
		}else{
			cout << a[0];
			for(int k=1;k<=i;k++){
				cout << ' ' <<a[k];
			}
			cout << endl;
		}
	}
}
}

int main() {
	int n;
	int a[30]={};
	while(1){
		cin >> n;
		if(n==0){
			return 0;
		}
		f(n,0,a);
	}
}

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

int main() {
  
  int a=0, b=0, c=0, d=0;
  
  cin >> a >> b >> c >> d;
  
  int dis1 = abs(a-b);
  int dis2 = abs(a-c);
  int dis3 = abs(b-c);
  
  if(dis2<=d) {
    
    cout << "Yes" << endl;
    
  } else if(dis1<=d && dis3<=d) {
    
    cout << "Yes" <<endl;
    
  } else {
    
    cout << "No" << endl;
    
  }
  
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace id_0030cs
{
    class Program
    {
        static void Main(string[] args)
        {
            string tmp;
            while((tmp = Console.ReadLine()) != null)
            {
                var vs = tmp.Split(' ').Select(int.Parse).ToArray();
                if (vs[0] == 0 && vs[1] == 0)
                {
                    break;
                }
                var result = search(9, vs[0], vs[1]);
                Console.WriteLine(result);
            }
        }
        static int search(int p, int n, int s)
        {
            if (n == 0 && s == 0) return 1;
            if (n == 0 && s != 0) return 0;
            if (p == -1) return 0;
            return search(p - 1, n - 1, s - p) + search(p - 1, n, s);
        }
    }
}



Measured memory_bytes: 9440