akhauriyash/Code-Regression huggingface dataset:
/*
Author- Aasav Badera
Time- Sat Aug 29 17:20:31 2020
*/
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL  
#include <sys/resource.h>
#define meminc             rlimit rlim;if (getrlimit(RLIMIT_STACK, &rlim)) return 1;rlim.rlim_cur = 268435456;if (setrlimit(RLIMIT_STACK, &rlim)) return 2;
#else
#define meminc      
#endif
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define int                long long int
#define ll                 int
#define vi                 vector<int >
#define ordered_set        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define rep(i, a, b)       for(int  i=a;i<b;i++)
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (int )x.size()
#define yes                cout << "Yes" << endl
#define no                 cout << "No" << endl
#define endl               '\n' 
// const int hell = (int)998244353;
const int hell = (int)1e9 + 7;
const int inf = 3223372036854775807;
const double PI = 3.14159265;
const int N = (int) 1e6 + 5;
int n, m, k, a[N];


int32_t main()
{
    meminc;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.precision(10);
    cout.precision(25);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int tests = 1;
    // cin >> tests;
    rep(test, 1, tests+1)
    {
    	double d,t, s;
    	cin >> d >> t >> s;
    	double spe = (d * 1.0000000000000000) / t;
    	if(spe - s > 0)no;
    	else yes;
    }
    #ifdef LOCAL
        // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int A,B;
  cin >> A >> B;
  vector<vector<bool>> grid(100,vector<bool>(100,false));
  rep(i,100){
    rep(j,50) {
      grid[j][i] = true;
    }
    srep(j,50,100) {
      grid[j][i] = false;
    }
  }
  A--;
  B--;
  int wx = 0;
  int wy = 0;
  rep(i,100) {
    rep(j,50) {
      if(A == 0) {
        break;
      }
      if(i % 2 == 0 && j % 2 == 0) {
        grid[j][i] = false;
        A--;
      }
    }
    srep(j,50,100) {
      if(B == 0) {
        break;
      }
      if(i % 2 == 0 && j % 2 == 1) {
        grid[j][i] = true;
        B--;
      }
    }
  }
  cout << 100 << " " << 100 << endl;
  rep(i,100) {
    rep(j,100) {
      if(grid[i][j]) {
        cout << "#";
      } else {
        cout << ".";
      }
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n<=104)cout<<"0"<<endl;
  else if(n<=134)cout<<"1"<<endl;
  else if(n<=164)cout<<"2"<<endl;
  else if(n<=188)cout<<"3"<<endl;
  else if(n<=194)cout<<"4"<<endl;
  else if(n<=200)cout<<"5"<<endl;
}

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

int main() {
  int arr[3];
  cin>>arr[0]>>arr[1]>>arr[2];
  sort(arr, arr + 3);
  if((arr[0] == arr[1] || arr[1] == arr[2]) && (arr[0] != arr[2])) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;


  int nowx = sx;
  int nowy = sy;
  string path = "";
  //path1
  while(nowy != ty) {
    nowy++;
    path.push_back('U');
  }
  while(nowx != tx) {
    nowx++;
    path.push_back('R');
  }
  //cout << path << endl;


  //path2
  while(nowy != sy) {
    nowy--;
    path.push_back('D');
  }
  while(nowx != sx) {
    nowx--;
    path.push_back('L');
  }
  //cout << path << endl;

  //path3
  nowx = sx-1;
  path.push_back('L');
  while(nowy != ty+1) {
    nowy++;
    path.push_back('U');
  }
  while(nowx != tx) {
    nowx++;
    path.push_back('R');
  }
  path.push_back('D');
  nowy -= 1;
  //cout << path << endl;

  //path4
  nowx = tx + 1;
  path.push_back('R');
  while(nowy != sy-1) {
    nowy--;
    path.push_back('D');
  }
  while(nowx != sx) {
    nowx--;
    path.push_back('L');
  }
  path.push_back('U');
  cout << path << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define pb push_back
#define mp make_pair

ll x;

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> x;
    ll cur = 0;
    for(int i = 1; i <= x; i++){
        cur += i;
        if(cur >= x){
            cout << i << endl;
            exit(0);
        }
    }
    return 0;
}


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

int main(void) {
	int N;
	cin >> N;
	double sum = 0.0;
	for (int i = 0; i < N; i++) {
		double A;
		cin >> A;
		sum += (1 / A);
	}
	if (sum != 0) {
		cout << 1 / sum << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;

}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=[list(map(int,input().split())) for i in range(K*2)]
count=0
a=0
for i in range(K):
    del A[i]
a_list=[]
for i in range(K):
    for j in range(len(A[i])):
        a_list.append(A[i][j])
for i in range(1,N+1):
    #print(i,count)
    #print(i in a_list)
    if (i in a_list)==True:
        count+=1
#print(N,count)
print(N-count)

Measured memory_bytes: 9264
#read matrix size
r, c = gets.split(" ").map(&:to_i)

#prepare array
mat = Array.new(r)
rvec = Array.new(r){0}
cvec = Array.new(c){0}

#read data and calculation part
sum = 0
for i in 0..r-1 do
  mat[i] = gets.chomp
  arr = mat[i].split(" ").map(&:to_i)
  for j in 0..c-1 do
    cvec[j] += arr[j]
    rvec[i] += arr[j]
    sum += arr[j]
  end
  i += 1
end

#output
for i in 0..r-1
  printf "%s %d\n", mat[i], rvec[i]
end
for j in 0..c-1
  printf "%d ", cvec[j]
end
printf "%d\n", sum

Measured memory_bytes: 8952
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
using namespace std;
signed main()
{
	cin.tie(0); ios::sync_with_stdio(0);
	int x[3];
	cin >> x[0] >> x[1] >> x[2];
	sort(x, x + 3);
	cout << x[2] * 10 + x[1] + x[0];
}

Measured memory_bytes: 256
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[] l=new int[m];
		int[] r=new int[m];
		for(int i=0;i<m;i++){
			l[i]=sc.nextInt();
			r[i]=sc.nextInt();
		}
		int maxl=0;
		int minr=n;
		for(int i=0;i<m;i++){
			if(maxl<l[i])
				maxl=l[i];
		}
		for(int i=0;i<m;i++){
			if(minr>r[i])
				minr=r[i];
		}
		int count=0;
		for(int i=1;i<=n;i++){
			if(maxl<=i&&i<=minr)
				count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 77712
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  uint64_t v = 1000000007;
  
  int N, M;
  cin >> N >> M;
  
  if ( N == 1 ) {
    cout << 1 << endl;
    return 0;
  }
  
  vector<uint64_t> dp(100007, 1);
  
  for (int i=0; i<M; i++) {
    int n; cin >> n;
    dp.at(n-1) = 0;
  }
  
  int p = 0;
  while ( p < N ) {
    p++;
    if( dp.at(p-1) && dp.at(p) ) {
      dp.at(p) = 2;
      break;
    } 
  }
  for (int i=0; i<N-1; i++) {
    if( !dp.at(i) ) {
      if( !dp.at(i+1) ) {
        cout << 0 << endl;
        return 0;
      }
      else if ( dp.at(i+2) ) {
        dp.at(i+2) = dp.at(i+1);
      }
    }
    else if ( dp.at(i+2) ) {
      if ( !dp.at(i+1) )  dp.at(i+2) = dp.at(i);
      else dp.at(i+2) = (dp.at(i) + dp.at(i+1)) % v;
    }
  }
  
  cout << dp.at(N-1) << endl;
  
  return 0;
}

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

int main(){
    
    int a,b,c,ans;
    cin >> a >> b >> c;

    if(a-b >= c)ans = 0;
    else ans = c-a+b;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int a,b,c,d = 0;
    cin >> a >> b >> c;
    d = a*100+b*10+c;
    if(d % 4 == 0)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
def floor_sum(n, m, a, b):
    """ sum( (a*i + b) // m ), i = 0..n-1 を返す"""
    ans = 0
    while True:
        if a >= m:
            ans += n * (n - 1) * (a // m) // 2
            a %= m
        if b >= m:
            ans += n * (b // m)
            b %= m
        y_max = (a * n + b) // m
        x_max = y_max * m - b
        if y_max == 0:
            break
        ans += (n - (x_max + a - 1) // a) * y_max
        n, m, a, b = y_max, a, m, (a - x_max % a) % a
    return ans


if __name__ == "__main__":
    import sys
    input = sys.stdin.buffer.readline
    sys.setrecursionlimit(10 ** 7)

    T = int(input())
    for _ in range(T):
        ans = floor_sum(*map(int, input().split()))
        print(ans)

Measured memory_bytes: 9344
N, K = map(int,input().split())
MOD = 10**9 + 7

state= [] # 同じ状態とみなしてよいものの個数の配列
i = 1
while i <= N:
    if i*i <= N:
        state.append(1)
        i += 1
    else:
        j = N // i # iの後における最大の数
        state.append(N//j-i+1) 
        i = N//j + 1

L = len(state)
#print(state)

# dp[k][x] : 最後が状態xであるようなk個の整数を並べる場合の数
dp = [[0]*L for _ in range(K+1)]
dp[0][0] = 1

#dp[k+1][x] = sum_{y: xを後ろにおける状態} dp[k][y]
for k in range(K):
    cum_sum = [0] * (L+1)
    for y in range(L): 
        cum_sum[y+1] = (cum_sum[y] + dp[k][y]) % MOD

    for x in range(L):
        # xを後ろにおけるような最大の状態はL-x-1
        dp[k+1][x] += cum_sum[L-x]
        dp[k+1][x] *= state[x]
        dp[k+1][x] %= MOD

#print(dp)
print(sum(dp[K]) % MOD)

Measured memory_bytes: 173676
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    ll H,N;
    cin >> H >> N;
    ll sum = 0;
    for (int i=0; i<N; ++i)
    {
        ll tmp;
        cin >> tmp;
        sum += tmp;
    }

    if(H<=sum) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=0;i<n;i++)
#define endl   "\n"
int sum(int n)
{
    if(n==0) return  0;

    return n%10+ sum((n/10));




}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 int n,k;
 cin>>n>>k;
 vector<int> v(n);
 f(n)cin>>v[i];
 
 int operation=1;
 int i=k;
 while(i<n)
 {
    i+=k-1;
    operation++;


 }
 cout<<operation<<endl;






}

Measured memory_bytes: 3992
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n ,k;
  cin>>n>>k;
  if(n>=10)
   cout<<k;
 else 
   cout<<(10-n)*100+k;
  return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    s = input().split()
    if s[0] < s[1]:
        tmp = s[0]
        s[0] = s[1]
        s[1] = tmp
    while True:
        x = int(s[0]) % int(s[1])
        if x==0:
            break
        s[0] = s[1]
        s[1] = x
 
    print (s[1])


Measured memory_bytes: 5596
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

const int INF = -100000000;

int main(){
  int d,n,a[200],b[200],c[200],t[200];
  scanf("%d %d",&d,&n);
  for(int i=0;i<d;i++) scanf("%d",t+i);
  for(int i=0;i<n;i++) scanf("%d %d %d",a+i,b+i,c+i);
  int dp[200][200];
  fill(dp[0],dp[0]+200,INF);
  for(int i=0;i<d;i++){
    for(int j=0;j<n;j++){
      if(i==0){
        if(a[j]<=t[i]&&t[i]<=b[j]){
          dp[i][j] = 0;
        }
        continue;
      }
      dp[i][j] = 0;
      for(int k=0;k<n;k++){
        if(a[j]<=t[i]&&t[i]<=b[j]){
          dp[i][j] = max(dp[i][j],dp[i-1][k]+max(c[j],c[k])-min(c[j],c[k]));
        }
      }
    }
  }
  int ans = 0;
  for(int i=0;i<n;i++) ans = max(ans,dp[d-1][i]);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 2908
import collections

s = list(input())
c = collections.Counter(s)

lm = list()
for i in list(c.keys()):
    l = [-1]
    for j in range(len(s)):
        if s[j] == i:
            l.append(j)
    l.append(len(s))
    lm.append(max([l[k+1]-l[k]-1 for k in range(len(l)-1)]))

print(min(lm))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "Yes";
const string NO  = "No";

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

    string s;

    cin >> s;

    if (s[0] == s[1] && s[1] == s[2] || s[3] == s[2] && s[2] == s[1]) {
        cout << YES;
    } else {
        cout << NO;
    }
    cout << endl;

    return 0;
}



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

typedef struct{
  int d;
  int f;
}timestamp;

typedef struct{
  int u;
  int k;
  int *v;
}graph;

void dfs(int);
void visit(int);

graph g[110];
timestamp t[110];
int mytime = 0;


int main(void){
  int i,j,n;

  scanf("%d", &n);


  for(i = 0; i <= n; i++)
    t[i].d = t[i].f = 0;

  for(i = 1; i <= n; i++){
    scanf("%d%d", &g[i].u, &g[i].k);
    g[i].v = (int *)malloc(sizeof(int) * (g[i].k+1));
    for(j = 1; j <= g[i].k; j++){
      scanf("%d", &g[i].v[j]);
    }
  }

  dfs(n);

  for(i = 1; i <= n; i++)
    printf("%d %d %d\n", i, t[i].d, t[i].f);
 
  return 0;
}


void dfs(int n){
  int i;

  for(i = 1; i <= n; i++)
    if(t[i].d == 0)
      visit(i);

}


void visit(int u){
  int i,j;

  t[u].d = ++mytime;

  for(i = 1; i <= g[u].k; i++){
    if(t[g[u].v[i]].d == 0)
      visit(g[u].v[i]);
  }

  t[u].f = ++mytime;

}

Measured memory_bytes: 600
#include<stdio.h>
#define MAX (100)
int number[MAX][MAX];
int main()
{
  int num1,num2,len,num3,i,j;//number[MAX][MAX];//len,num1,num2,num3,number[100][1001];
  scanf("%d", &len);
  for(i=0;i<len;i++){
    scanf("%d",&num1);
    scanf("%d",&num2);
    for(j = 0; j < num2; j++){
      scanf("%d", &num3);
      number[num1-1][num3-1] = 1;
      }
  }
  for(i = 0; i < len; i++){
        for(j = 0; j < len-1; j++)
	  printf("%d ", number[i][j]);
        printf("%d\n", number[i][j]);
  }
  return 0;
}

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

using ll = long long;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> h(N);
    for(int i=0; i<N; ++i) {
        cin >> h[i];
    }
    ll lb = -1, ub = 1e9+1;
    while(ub - lb > 1) {
        ll m = (lb + ub) / 2;
        ll t = 0;
        for(int i=0; i<N; ++i) {
            ll hh = max(h[i] - B * m, 0LL);
            t += (hh + A - B - 1) / (A - B);
        }
        if(t <= m) {
            ub = m;
        } else {
            lb = m;
        }
    }
    cout << ub << endl;
}


Measured memory_bytes: 1152
INF = 999999999999

def BellmanFord_edge(s, v, edge):
    dp = [INF] * v
    dp[s] = 0
    for i in range(0, v):
        dp1 = dp[:]
        for fr, to, d in edge:
            if dp[fr] == INF:
                continue
            if dp[to] > dp[fr] + d:
                dp[to] = dp[fr] + d
                if i == v - 1:
                    return -1
        if dp == dp1:
            break
    return dp

def BellmanFord_graph(s, v, graph):
    dp = [INF] * v
    dp[s] = 0
    for i in range(0, v):
        for k in range(0, v):
            dp1 = [dp[k] + graph[k][j] if dp[k] != INF and graph[k][j] != INF and dp[j] > dp[k] + graph[k][j]
                  else dp[j]
                  for j in range(0, v) ]
            if dp1 != dp and i == v - 1:
                return -1
            dp = dp1
    return dp

dp = []
line = input()
v, e = list(map(int, line.split()))
graph = [ [INF] * v for _ in range(0, v)]
edge = []
for _ in range(0, e):
    line = input()
    s, t, d = list(map(int, line.split()))
    edge += [[s, t, d]]
    graph[s][t] = d
for s in range(0, v):
#    dp = BellmanFord(s, v, graph)
    dp = BellmanFord_edge(s, v, edge)
    if dp == -1:
        print("NEGATIVE CYCLE")
        break
    else:
        print(" ".join(map(str, [dp[t] if dp[t] != INF else "INF" for t in range(0, v)])))


Measured memory_bytes: 6788
#include<bits/stdc++.h>
#include<iostream>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    else return gcd(b,a%b);
}
vector<ll>A(200010);
vector<vector<ll> >dp(200010,vector<ll>(3,-inf*inf));
ll solve1(ll a,ll b){
    if(dp[a][b]!=-inf*inf){
        return dp[a][b];
    }
    ll res=A[a];
    if(b==0){
        res+=max(solve1(a+2,b),max(solve1(a+3,b+1),solve1(a+4,b+2)));
    }else if(b==1){
        res+=max(solve1(a+2,b),solve1(a+3,b+1));
    }else{
        res+=solve1(a+2,b);
    }
    dp[a][b]=res;
    return res;
}
ll solve2(ll a,ll b){
    if(dp[a][b]!=-inf*inf){
        return dp[a][b];
    }
    ll res=A[a];
    if(b==0){
        res+=max(solve2(a+3,b+1),solve2(a+2,b));
    }else if(b==1){
        res+=solve2(a+2,b);
    }
    dp[a][b]=res;
    return res;
}

signed main(){
    ll n;cin>>n;
    rep(i,n)cin>>A[i];
    if(n%2==0){
        ll ans;
        dp[n-1][1]=A[n-1];
        dp[n-2][0]=A[n-2];
        ans=max(solve2(0,0),solve2(1,1));
        cout<<ans<<endl;
    }else{
        ll ans;
        dp[n-1][2]=A[n-1];
        dp[n-2][1]=A[n-2];
        dp[n-3][0]=A[n-3];
        ans=max(solve1(0,0),max(solve1(1,1),solve1(2,2)));
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 25176
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
            int count = 0;
            while (a > 0 && b > 0 && c > 0) {
                a--;
                b--;
                c--;
                count++;
            }
            while (a > 1 && b > 0) {
                a -= 2;
                b--;
                count++;
            }
            while (a > 2) {
                a -= 3;
                count++;
            }
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 26840
#include <stdio.h>

int main(void)
{
  int a, b, c, d;

  scanf("%d %d %d %d", &a, &b, &c, &d);
  if (a * b > c * d){
    printf("%d\n", a * b);
  }
  else {
    printf("%d\n", c * d);
  }

  return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

void ntoarray( int a[], int n ) {
	int i = 0;
	while( n > 0 ) {
		a[ i ] = n % 10; n = n / 10;
		i += 1;
	}
	return;
}

bool chk_permu( int n, int i ) {
	const int amax = 12;
	int na[ amax ] = { 0 };
	int ia[ amax ] = { 0 };

	ntoarray( na, n );
	std::sort( na, na + amax );
	ntoarray( ia, i );
	std::sort( ia, ia + amax );

	bool issame = true;
	for( int i = 0; i < amax; i++ ) {
		if( na[ i ] !=  ia[ i ] ) {
			issame = false;
			break;
		}
	}

	return issame;
}

int next_permu( int n, int nmax ) {
	int p = 0;
	for( int i = n + 1; i < nmax; i++ ) {
		bool ispermu = chk_permu( n, i );
		if( ispermu ) {
			p = i;
			break;
		}
	}
	return p;
}

bool isallconnected( int np, int n, int m, int a[], int b[] ) {
	std::vector<int> nv;
	int t = np;
	while( t > 0 ) {
		nv.insert( nv.begin(), t % 10 );
		t = t / 10;
	}

	int edges = 0;
	for( int i = 0; i < nv.size() - 1; i++ ) {
		for( int j = 0; j < m; j++ ) {
			if( ( nv[ i ] == a[ j ] and nv[ i + 1 ] == b[ j ] ) or
					( nv[ i ] == b[ j ] and nv[ i + 1 ] == a[ j ] ) ) {
				edges += 1;
			}
		}
	}

	return ( edges == n - 1 ? true : false );
}

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

	const int mmax = 28;
	int a[ mmax ], b[ mmax ];
	for( int i = 0; i < m; i++ ) {
		std::cin >> a[ i ] >> b[ i ];
	}

	int np = 0;
	for( int i = 1; i <= n; i++ ) {
		np = np * 10 + i;
	}

	int nmax = std::pow( 10, n - 1 ) * 2;
	int cnt = 0;
	while( np > 0 ) {
		bool isall = isallconnected( np, n, m, a, b );
		if( isall ) {
			cnt += 1;
		}

		np = next_permu( np, nmax );
	}

	std::cout << cnt << std::endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<string, string> ss;
typedef pair<int, ss> iss;
 
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, string> mss;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, vi> mivi;
typedef map<int, bool> mib;
typedef map<int, ll> mill;
typedef map<int, vpii> mivpii;

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

bool in(int n) {
	return n >= 1 and n <= 9;
}


int main() {
	fast_io();
//	freopen("input/ABC144A.txt", "r", stdin);
	
	int a, b;
	cin >> a >> b;
	
	cout << (in(a) and in(b) ? a * b : -1) << '\n';
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var X, tmp1, tmp2 int
	fmt.Scan(&X)
	// Y := X
	// num := 0
	// for {
	// 	Y = Y / 10;
	// 	num++
	// 	if Y <= 0 {break}
	// }

	// for i := 0 ; i < num ; i++ {
	// 	ans[i] = 
	// }
	if X < 500 {
		tmp1 = X / 5
		fmt.Println(tmp1 * 5)
	}else {
		tmp1 = X / 500
		tmp2 = (X - tmp1*500) / 5
		fmt.Println(tmp1*1000 + tmp2*5)
	}
}

Measured memory_bytes: 512
//AtCoder ABC079 A - Good Integer
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    string N;
    cin>>N;
    bool ans=false;
    for(ll i=0;i<N.size()-2;++i){
        if(N[i]==N[i+1]&&N[i]==N[i+2]){
            ans=true;
            break;
        }
    }
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, k = mi()
    print(0) if n % k == 0 else print(1)


if __name__ == "__main__":
    main()


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

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

int main(void){
	int64 N, X=-1;
	int64 res = -1;
	cin >> N >> X;
	REP(i, N){
		int64 a;
		cin >> a;
		if(res == -1) res = abs(X-a);
		else res = gcd(res, abs(X-a));
	}
	cout << res << endl;
}


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

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

	ll p = log2l(h);
	// cout<<"p:"<<p<<"\n";
	ll ans = (1ll<<(p+1)) - 1;

	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#include<regex>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;


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

	vector<LL> a(N);
	rep(i, N) cin >> a[i];

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>

#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double dd;



int main() {
	int A, B;
	cin >> A >> B;
	int add, sub, multi;
	add = A + B;
	sub = A - B;
	multi = A * B;
	if (sub <= add && multi <= add) cout << add;
	else if (add <= sub && multi <= sub) cout << sub;
	else cout << multi;

	return 0;
}

Measured memory_bytes: 256
s_orig = gets.chomp
t_orig = gets.chomp

s = s_orig.codepoints
t = t_orig.codepoints

s_size = s.size
t_size = t.size

dp = Array.new(s_size + 1) { Array.new(t_size + 1, 0) }

0.upto(s_size - 1).each do |i|
  dpi = dp[i]
  dpi1 = dp[i + 1]
  0.upto(t_size - 1).each do |j|
    if s[i] == t[j]
      dpi1[j + 1] = dpi[j] + 1
    else
      dpi1[j + 1] = dpi[j + 1] > dpi1[j] ? dpi[j + 1] : dpi1[j]
    end
  end
end

ans = ''
y = s_size
x = t_size

while y > 0
  if dp[y - 1][x] == dp[y][x]
    y -= 1
  elsif dp[y][x - 1] == dp[y][x]
    x -= 1
  else
    y -= 1
    x -= 1
    ans << s_orig[y]
  end
end

puts ans.reverse

Measured memory_bytes: 74748
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int h, w;
string a[100];
bool hs[100];
bool _ws[100];


void init() {

}

void input() {
	cin >> h >> w;
	REP(i, h) cin >> a[i];
}

void solve() {
	REP(i, h) hs[i] = false;
	REP(j, w) _ws[j] = false;
	REP(i, h) {
		bool b = true;
		REP(j, w) if (a[i][j] == '#') b = false;
		if (b) hs[i] = true;
	}
	REP(j, w) {
		bool b = true;
		REP(i, h) if (a[i][j] == '#') b= false;
		if (b) _ws[j] = true;
	}
	REP(i, h) if (!hs[i]) REP(j, w) {
		if (!_ws[j]) cout << a[i][j];
		if (j == w-1) cout << endl;
	}


}

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string w,t;
    cin >> w;
    int count = 0;
    
    while(cin >> t && t != "END_OF_TEXT"){
        for(int i=0; i<t.size() && t.size() == w.size(); i++){
            bool can = false;
            if(w[i] == t[i]) can = true;
            else if('a' <= w[i] && w[i] <= 'z'){
                if(t[i] == w[i] - 'a' + 'A') can = true;
            }
            else if('A' <= w[i] && w[i] <= 'Z'){
                if(t[i] == w[i] - 'A' + 'a') can = true;
            }
            if(!can) break;
            if(i == t.size()-1) count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3220
#include <iostream>
#include <math.h>

using namespace std;

int main(void)
{
    int D, N, count=0, i=1;

    cin >> D >> N;

    if(D==0){
        while(1){
            if(i % 100 != 0){
                count++;
            }

            if(count == N){
                break;
            }

            i++;
        }
    }

    else if(D==1){
        while(1){
            if(i % 100 == 0 && i % 10000 != 0){
                count++;
            }

            if(count == N){
                break;
            }

            i++;
        }
    }

    else{
        while(1){
            if(i % 10000 == 0 && i % 1000000 != 0){
                count++;
            }

            if(count == N){
                break;
            }

            i++;
        }   
    }

    cout << i << endl;

    return 0;
}

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

int main(){
  int D,N;
  cin >> D >> N;
  int a;
  if (D==0){
    if(N==100)
      a=101;
    else
      a=N;
    cout << a << endl;
  }
  if (D==1){
    if(N==100)
      a=101*100;
    else
      a=N*100;
    cout << a << endl;
  }
  if (D==2){
    if(N==100)
      a=101*10000;
    else
      a=N*10000;
    cout << a << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int N, A, B, C, X;
	int Y[100];		
	while(cin >> N >> A >> B >> C >> X, N){
		for(int i=0;i<N;i++) cin >> Y[i];
		int idx = 0;
		int res = -1;
		for(int turn=0;turn<=10000;turn++){
			if(X == Y[idx]) ++idx;
			if(idx == N){
				res = turn;
				break;
			}
			X = (A*X+B)%C;
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <atcoder/maxflow>
using namespace std;
using namespace atcoder;
#define ll long long
//#define fr(i,j,k) for(int i=j;i<k;i++)
//#define f(n) fr(i,0,n)
//#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const ll mod = 998244353;
const int maxn = 5e5+5;

void solve() {
    int n, m;
    cin >> n >> m;
    string s[n];
    int st = n * m;
    int ed = n * m + 1;
    mf_graph<int>g(n*m+2);
    for (int i = 0 ; i < n ; i++) {
        cin >> s[i];
    }
    int dx[] = {1,-1,0,0};
    int dy[] = {0,0,1,-1};
    for (int i = 0 ; i < n ; i++) {
        for (int j = 0 ; j < m ; j++) {
            if (s[i][j] == '#')continue;
            if ((i + j) & 1) {
                g.add_edge(m*i+j,ed,1);
            }
            else {
                g.add_edge(st,m*i+j,1);
                for (int k = 0 ; k < 4 ; k++) {
                    int nx = i + dx[k];
                    int ny = j + dy[k];
                    if (nx < 0 || nx >= n || ny < 0 || ny >= m || s[nx][ny] == '#')continue;
                    g.add_edge(m*i+j,nx*m+ny,1);
                }
            }
        }
    }
    int c = g.flow(st,ed);
    char ans[n][m] = {};
    for (auto &i : g.edges()) {
        if (i.flow && i.from != st && i.to != ed) {
            int x1 = i.from/m,x2=i.to/m;
            int y1 = i.from%m,y2 = i.to%m;
            if (x1 > x2) {
                swap(x1, x2);
            }
            if (y1 > y2) {
                swap(y1, y2);
            }
          //cout << x1 <<' '<<x2<<' '<<y1<<' '<<y2<<endl;
            if (x1 == x2) {
                ans[x1][y1] = '>';
                ans[x2][y2] = '<';
            }
            else {
                ans[x1][y1] = 'v';
                ans[x2][y2] = '^';
            }
        }
    }
    cout << c << '\n';
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < m ; j++) {
            if (ans[i][j] != '\0') {
                cout << ans[i][j];
            }
            else {
                cout << s[i][j];
            }
        }
        cout << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        solve();
    }
    
}


Measured memory_bytes: 5468
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
#define int long long
const int N=200005;
struct D{int o,w,x;}d[N];
int n,va[2][N],b[2],a,r=1e18;bool v[2][N];
set<pair<int,int> >s;
bool cmp(D x,D y){return x.x<y.x;}
inline int mn(int x,int y){return x<y?x:y;}
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;++i)
		scanf("%lld%lld",&d[i*2-1].x,&d[i*2].x),
		va[0][i]=d[i*2-1].x,va[1][i]=d[i*2].x,
		d[i*2-1].w=d[i*2].w=i,d[i*2-1].o=0,d[i*2].o=1;
	sort(d+1,d+n*2+1,cmp);
	for(int i=1;i<=n;++i)
		a+=d[i].x,++b[d[i].o],v[d[i].o][d[i].w]=1;
	if(b[0]==n||b[1]==n)return printf("%lld",a),0;
	for(int i=1;i<=n;++i)if(!v[0][i]&&!v[1][i])return printf("%lld",a),0;
	for(int i=n+1;i<=n*2;++i)s.insert(make_pair(d[i].x,d[i].w));
	for(int i=1;i<=n;++i)
		for(auto j=s.begin();j!=s.end();++j)
			if((*j).second!=i){r=mn(r,a+(*j).first-(v[0][i]?va[0][i]:va[1][i]));break;}
	return printf("%lld",r),0;
}

Measured memory_bytes: 15988
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

vector<int> Eratosthenes(int N){
	vector<int> arr(N,1);
    vector<int> res;
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for(int i = 1; i < N; i++){
		if(arr[i]){
            res.push_back(i);
		}
	}
    return res;
}

const ll INF = 1LL << 60;
 
ll N;
vector<ll> a;
int main() {
    cin >> N;
    a.resize(N + 1);
    rep(i, N) cin >> a[i + 1];
    vector<ll> ans(N + 1, -1);
    for (int i = N; i > 0; i--) {
        int loop_cnt = N / i;
        if (loop_cnt >= 2) {
            ll tmp = 0;
            for (int j = i + i; j <= N; j += i) {
                tmp += ans[j];
            }
            tmp = tmp % 2;
            ans[i] = tmp ^ a[i];
        } else {
            ans[i] = a[i];
        }
    }
    set<ll> st;
    for (int i = 1; i <= N; i++) {
        if (ans[i] == 1) {
            st.insert(i);
        };
    }
 
    cout << st.size() << endl;
 
    for (auto v : st) {
        cout << v << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 11972
#include<stdio.h>

int main(void)

{

int a,b,d,r;


double f=0;


scanf("%d",&a);


scanf("%d",&b);


d=a/b;


r=a%b;


f=(double)a/(double)b;


printf("%d %d %lf\n",d,r,f);


return 0;

}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 1; i < n; ++i) cin >> a.at(i);
  
  vector<int> ans(n);
  for(int i = 1; i < n; ++i){
    int k = a.at(i) - 1;
    ans.at(k)++;
  }
  
  for(int i = 0; i < n; ++i) cout << ans.at(i) << endl;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define int long long int
#define modulo 1000000007
using namespace std;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double n;
    cin>>n;
    long double odd=0;
    for(int i=1;i<=n;i++){
        if(i%2)odd++;
    }
    cout<<setprecision(10)<<(long double)odd/n;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    a,b=map(int,input().split())
    print((b-a+1)*(b-a)//2-b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main() {
    string s;
    cin >> s;
    
    if (s == "zyxwvutsrqponmlkjihgfedcba")
    {
        cout << -1 << endl;
        return 0;
    }
    
    
    map<char, int> ss;
    
    for (int i = 0; i < s.size(); ++i)
    {
        ss[s[i]]++;
    }
    
    string ret = s;
    
    if (ss.size() == 26)
    {
        int pos = (int)s.size() - 1;
        while (1)
        {
            ss[s[pos]]--;
            int flag = 0;
            if (ss[s[pos]] == 0)
            {
                ret = s.substr(0, pos);
                for (int i = 0; i < 26; ++i)
                {
                    string tmp = ret;
                    char c = 'a' + i;
                    if (ss[c] == 0)
                    {
                        tmp += c;
                        if (tmp > s)
                        {
                            ret = tmp;
                            flag = 1;
                            break;
                        }
                    }
                }
                if (flag)
                {
                    break;
                }
            }
            pos--;
        }
    }
    else
    {
        for (int i = 0; i < 26; ++i)
        {
            int c = 'a' + i;
            if (ss.count(c) == 0)
            {
                ret += c;
                cout << ret << endl;
                return 0;
            }
        }
    }
    
    cout << ret << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(_) for _ in input().split()]

exp = []
if n % 2 == 0:
    for i in range(0, n // 2):
        exp.append(2 * i + 1)
        exp.append(2 * i + 1)
else:
    exp.append(0)
    for i in range(1, n // 2 + 1):
        exp.append(2 * i)
        exp.append(2 * i)

a_sorted = sorted(a)

if a_sorted == exp:
    ans = 1
    for i in range(0, n // 2):
        ans *= 2
        if ans > 1000000007:
            ans -= 1000000007
    print(ans)
else:
    print(0)

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

int main(){
    while(true){
        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++)cout<< "#";
            cout << endl;
        } 
        cout << endl;  
    }
return 0;
}


Measured memory_bytes: 3084
#include <iostream>
using namespace std;
int main(){
  int n,m; cin>>n>>m;
  int l,r;
  int maxl=1,minr=n;
  for(int i=0;i<m;i++){
    cin>>l>>r;
    maxl=max(maxl,l);
    minr=min(minr,r);
  }
  if(maxl<=minr) cout << minr-maxl+1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;
const int MOD = 1000000007;

char t[N];
string s;
int d, S[N][100], R[N][100], i, j, k, tab[N], n;

int main() {
scanf("%s", t);
s = t;
n = s.size();
for (i=0;i<n;i++) tab[i] = int(s[i]) - 48;
scanf("%d", &d);
for (i=0;i<=9;i++) S[0][i % d]++;
for (j=1;j<n;j++) for (i=0;i<=9;i++) for (k=0;k<d;k++) S[j][(k + i) % d] = (S[j][(k + i) % d] + S[j - 1][k]) % MOD;
for (i=0;i<=tab[n - 1];i++) R[0][i % d]++;
for (j=1;j<n;j++) {
	for (i=0;i < tab[n - 1 - j];i++) for (k=0;k<d;k++) R[j][(k + i) % d] = (R[j][(k + i) % d] + S[j - 1][k]) % MOD;
	i = tab[n - 1 - j];
	for (k=0;k<d;k++) R[j][(k + i) % d] = (R[j][(k + i) % d] + R[j - 1][k]) % MOD;
}
printf("%d\n", (R[n - 1][0] + MOD - 1) % MOD);
return 0;
}

Measured memory_bytes: 12288
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int N,M;

class UnionFind {
public:
    vector<int> par, rank;
    int cnt;

    UnionFind(int n) : cnt(n) {
        par = vector<int>(n);
        iota(par.begin(), par.end(), 0);
        rank = vector<int>(n, 0);
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
        cnt--;
    }

    bool same(int x, int y) {
        return (root(x) == root(y));
    }
};


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

  cin >> N >> M;
  int N_MAX=101000;
  int p[N_MAX];
  int ans=0;
  int b;
  for(int i=0;i<N;i++){
    cin >> b;
    p[i]=b-1;

  }
  int x,y;
  UnionFind uf1=UnionFind(N);
  for(int i=0;i<M;i++){
    cin >> x >> y;
    x--;
    y--;
    uf1.unite(p[x],p[y]);
    //uf1.unite(i,i);
  }
  for(int i=0;i<N;i++){
    if(i==p[i]){
      //cout << "A" << endl;
      ans++;
    }
    else if(uf1.same(p[i],i)){
      //cout << "B" << endl;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408