akhauriyash/Code-Regression huggingface dataset:
import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
class mod_comb3:
    def __init__(self,mod=10**9+7,n_max=1):
        self.mod,self.n_max=mod,n_max
        self.fact,self.inv,self.factinv=[1,1],[0,1],[1,1]
        if 1<n_max:setup_table(n_max)
    def comb(self,n,r):
        if r<0 or n<r:return 0
        if self.n_max<n:self.setup_table(n)
        return self.fact[n]*(self.factinv[r]*self.factinv[n-r]%self.mod)%self.mod
    def setup_table(self,t):
        for i in range(self.n_max+1,t+1):
            self.fact.append(self.fact[-1]*i%self.mod)
            self.inv.append(-self.inv[self.mod%i]*(self.mod//i)%self.mod)
            self.factinv.append(self.factinv[-1]*self.inv[-1]%self.mod)
        self.n_max=t
def main():
    n,k=map(int,input().split())
    mod=10**9+7
    m=mod_comb3()
    for i in range(1,k+1):
        print(m.comb(n-k+1,i)*m.comb(k-1,i-1)%mod) 
if __name__=='__main__':
    main()

Measured memory_bytes: 3948
#complete_binary_tree
#ALDS1_9_A

class Node
  attr_accessor :key,:parent,:left,:right

  def initialize
    @parent = nil
    @left   = nil
    @right  = nil
  end

  def add_left(child)
      self.left    = child
      child.parent = self
  end

  def add_right(child)
      self.right    = child
      child.parent = self
  end

  def make_c_b_tree(n,all)
    if (2*n <= all)
      self.left = $nodes[2*n]
      self.left.make_c_b_tree(2*n,all)
      self.left.parent = self
    end
    if (2*n+1 <= all)
      self.right = $nodes[2*n+1];
      self.right.make_c_b_tree(2*n+1,all)
      self.right.parent = self
    end
  end
    
  def describe
    printf(" key = %d, ",self.key)
    printf("parent key = %d, ",self.parent.key) if self.parent != nil 
    printf("left key = %d, ",self.left.key)     if self.left != nil 
    printf("right key = %d, ",self.right.key)    if self.right != nil 
    printf("\n")
  end
end

class Complete_bin_tree
  attr_accessor :root

  def initialize
    @root = nil
  end

  def make(n)
    self.root = $nodes[1]
    self.root.make_c_b_tree(1,n);
  end
end


$c_b_tree = Complete_bin_tree.new
$n = STDIN.gets.split[0].to_i
$a =Array.new($n+1)
$nodes = Array.new($n+1){|i| Node.new}
s  = STDIN.gets.split

$c_b_tree.make($n)

0.upto($n-1){|i|
  $nodes[i+1].key = s[i] }

0.upto($n-1){|i|
  printf("node %d:",i+1)
  $nodes[i+1].describe }

Measured memory_bytes: 8840
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import copy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():

    N = I()
    XY = LLIN(N)
    XY.sort()
    if N == 1:
        print(1)
        exit()
    
    count = defaultdict(int)
    for i, (x1, y1) in enumerate(XY):
        for j, (x2, y2) in enumerate(XY[i+1:]):
            dx, dy = x1 - x2, y1 - y2
            count[(dx, dy)] += 1
    print(N - max(count.values()))
    
    
                        
if __name__ == '__main__':
    main()

Measured memory_bytes: 39024
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;

static const int MAX_NUM = 105;
static const int NO_VISIT  = 0;
static const int END_VISIT = 2;

void BFS(int *matrix, int num)
{
    int i;
    int state[MAX_NUM]    = {0};
    int distance[MAX_NUM];
    queue<int> Q;
    int target;
    int dist = 0;
    int *tmp;
    bool first;

    for (i = 1; i <= num; i++) {
        distance[i] = -1;
    }

    Q.push(1);
    state[1] = END_VISIT;
    distance[1] = 0;

    while (Q.empty() == false) {
        target = Q.front();
        Q.pop();
        tmp = matrix + target * MAX_NUM;
        first = true;
        for (i = 1; i <= num; i++) {
            if ((*(tmp + i) == 1) && (state[i] == NO_VISIT)) {
                distance[i] = distance[target] + 1;
                Q.push(i);
                state[i] = END_VISIT;
            }
        }
    }

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

    return;
}

int main(void)
{
    int i, j;
    int num;
    int elem;
    int nume;
    int tmp;
    int matrix[MAX_NUM][MAX_NUM];

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        scanf("%d %d", &elem, &nume);
        for (j = 0; j < nume; j++) {
            scanf("%d", &tmp);
            matrix[elem][tmp] = 1;
        }
    }

    BFS(&matrix[0][0], num);

    return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
void solve(){
	string s;
	cin>>s;
	rep(i,0,sz(s)){
		if(s[i]=='?')cout<<'D';
		else
			cout<<s[i];
	}
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 3772
import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

public class Main {
	private static boolean[] vis;
	private static long[] dist;
	public static void merge(long arr[], int l, int m, int r) 
    { 
        // Find sizes of two subarrays to be merged 
        int n1 = m - l + 1; 
        int n2 = r - m; 
  
        /* Create temp arrays */
        long L[] = new long [n1]; 
        long R[] = new long [n2]; 
  
        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i) 
            L[i] = arr[l + i]; 
        for (int j=0; j<n2; ++j) 
            R[j] = arr[m + 1+ j]; 
  
  
        /* Merge the temp arrays */
  
        // Initial indexes of first and second subarrays 
        int i = 0, j = 0; 
  
        // Initial index of merged subarry array 
        int k = l; 
        while (i < n1 && j < n2) 
        { 
            if (L[i] <= R[j]) 
            { 
                arr[k] = L[i]; 
                i++; 
            } 
            else
            { 
                arr[k] = R[j]; 
                j++; 
            } 
            k++; 
        } 
  
        /* Copy remaining elements of L[] if any */
        while (i < n1) 
        { 
            arr[k] = L[i]; 
            i++; 
            k++; 
        } 
  
        /* Copy remaining elements of R[] if any */
        while (j < n2) 
        { 
            arr[k] = R[j]; 
            j++; 
            k++; 
        } 
    } 
	 public static void sort(long arr[], int l, int r) 
	    { 
	        if (l < r) 
	        { 
	            // Find the middle point 
	            int m = (l+r)/2; 
	  
	            // Sort first and second halves 
	            sort(arr, l, m); 
	            sort(arr , m+1, r); 
	  
	            // Merge the sorted halves 
	            merge(arr, l, m, r); 
	        } 
	    } 
	 private static int gcd(int n, int l) {
	        if (l == 0)
	            return n;
	        return gcd(l, n % l);
	    }
	 public static void dfs(ArrayList<Pair>[] gr,int v)
	    {
	         vis[v]=true;
	         ArrayList<Pair> arr=gr[v];
	         for(int i=0;i<arr.size();i++)
	         {
	             if(!vis[arr.get(i).v])
	             {  
	            	 dfs(gr,arr.get(i).v);
	             }
	         }
	    }
	 private static class Pair implements Comparable<Pair>{
	        int v,i;Pair j;
	        public Pair(int a,int b){
	            v=a;
	            i=b;
	        }
	        public Pair(int a,Pair b)
	        {
	            v=a;
	            j=b;
	        }
	        @Override
	        public int compareTo(Pair arg0) {
	            {
	            	return this.v-arg0.v;
	            }
	        }
	    }
	public static void main(String[] args) throws Exception
	{
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();int b=sc.nextInt();
		int x=a*3+b;
		System.out.println(x/2);
	}
}


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



int main() {
  int a,b,c,d;
  cin >> a >> b >>c >>d;
  int ans = min(a,b) + min(c,d);
  cout << ans << endl;


	return 0;
}



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

int main() {
	int orgn, n, a;
	int sum = 0;
	cin >> orgn;
	n = orgn;
	while (n != 0) {
		a = n % 10;
		sum += a;
		n /= 10;
	}
	if (orgn%sum == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

typedef long long int   ll;
#define f(i,st,en)    for(int i=st;i<en;i++)
#define s(n)            scanf("%d",&n)
#define sc(n)           scanf("%c",&n)
#define sl(n)           scanf("%lld",&n)
#define sf(n)           scanf("%lf",&n)

using namespace std;


int main(){
    float r;
    cin>>r;
    cout<<(3.14159265358979323846*r*2);
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// // assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm vi st gin
// cusum segtree

/*
 * table は半開区間2次元累積和配列
 */
int cusum(vvi &table, int minx, int miny, int maxx, int maxy)
{
    return table[maxx][maxy] + table[minx][miny]
        - table[maxx][miny] - table[minx][maxy];
}

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

    int3(n, m, q);
    vvi table(n, vi(m, 0));
    vvi cnt(n+1, vi(m+1, 0));
    rep(i, n) {
        string tmp; cin >> tmp;
        rep(j, tmp.size()) {
            table[i][j] = tmp[j] - '0';
            cnt[i+1][j+1] = tmp[j] - '0';
        }
    }
//    rep(i, n) {rep(j, m) cout << table[i][j] << " "; cout << endl;}

    rep(i, n) {
        rep(j, m) {
            cnt[i+1][j+1] += cnt[i+1][j] + cnt[i][j+1] - cnt[i][j];
        }
    }
//    rep(i, n+1) {rep(j, m+1) cout << cnt[i][j] << " "; cout << endl;} 
    //cout << endl;

    vvi tate(n+1, vi(m, 0));
    Rep(i, n+1) {
        Rep(j, m) {
            tate[i][j] = (table[i-1][j-1] && table[i-1][j]);
        }
    }
//    rep(i, n+1) {rep(j, m) cout << tate[i][j] << " "; cout << endl;}
    rep(i, n) {
        rep(j, m-1) {
            tate[i+1][j+1] += tate[i+1][j] + tate[i][j+1] - tate[i][j];
        }
    }
//    rep(i, n+1) {rep(j, m) cout << tate[i][j] << " "; cout << endl;}
    //cout << endl;

    vvi yoko(n, vi(m+1, 0));
    Rep(i, n) {
        Rep(j, m+1) {
            yoko[i][j] = (table[i-1][j-1] && table[i][j-1]);
        }
    }
//    rep(i, n) {rep(j, m+1) cout << yoko[i][j] << " "; cout << endl;}
    rep(i, n-1) {
        rep(j, m) {
            yoko[i+1][j+1] += yoko[i+1][j] + yoko[i][j+1] - yoko[i][j];
        }
    }
//    rep(i, n) {rep(j, m+1) cout << yoko[i][j] << " "; cout << endl;}
    //cout << endl;

    while (q--) {
        int2(sx, sy);
        int2(ex, ey);

        //cout << cusum(cnt, sx-1, sy-1, ex, ey) << endl; 
        //cout << cusum(tate, sx-1, sy-1, ex, ey-1) << endl;
        //cout << cusum(yoko, sx-1, sy-1, ex-1, ey) << endl;

        cout << cusum(cnt, sx-1, sy-1, ex, ey) - 
                cusum(tate, sx-1, sy-1, ex, ey-1) -
                cusum(yoko, sx-1, sy-1, ex-1, ey) << endl;

        //cout << endl;
    }

    return 0;
}


Measured memory_bytes: 127872
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
using namespace std;
typedef long long LL;
const int P=1000000007;
inline int Pow(int a,int b){
    int c=1;
    for(;b;b>>=1,a=a*1ll*a%P)if(b&1)c=c*1ll*a%P;
    return c;
}
inline void add(int &a,int b){a+=b;if(a>=P)a-=P;}
inline void dec(int &a,int b){a-=b;if(a<0)a+=P;}
const int N=405;
int n,c;
int l[N],r[N];
int w[N][N];
int po[N][N];
int f[N][N];
int main(){
    scanf("%d%d",&n,&c);
    int ans=0;
    rep(i,0,400)rep(j,0,400)po[i][j]=Pow(i,j);
    rep(i,1,n)scanf("%d",&l[i]);
    rep(i,1,n)scanf("%d",&r[i]);
    rep(i,1,n){
        rep(j,0,c){
            rep(k,l[i],r[i])add(w[i][j],po[k][j]);
        }
    }
    f[0][0]=1;
    rep(i,0,n-1)rep(j,0,c)if(f[i][j])rep(k,0,c-j)add(f[i+1][j+k],f[i][j]*1ll*w[i+1][k]%P);
    printf("%d\n",f[n][c]);
    return 0;
}






Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define maxn 100007
#define inf 1000000007
#define ll long long int
using namespace std;

int a,m=inf;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

inline void writ(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) writ(x/10);
	putchar(x%10+'0');
}
inline void write(int x){writ(x);putchar('\n');}

int main()
{
	int ans=0,a=read(),b=read(),c=read()<<1,x=read(),y=read();
	if (c<=a+b)
	{
		ans+=min(x,y)*c;
		ans<<1;
		int t=x;
		x=max(0,x-y),y=max(0,y-t);
	}
	if (c<=a) ans+=c*x,x=0;
	if (c<=b) ans+=c*y,y=0;
	ans+=a*x+b*y;
	write(ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int INF=INT_MAX;
const ld PI=3.1415926535897932384626433;
const ld E=2.71828183;
const int MOD=1e9+7;
vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed, adj[0].size()=0!!!
    //for n vertices, adj.size()=n+1. (constructed via push_back() ).

    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return dst;
}
vi bfsParents(vector<vi>adj,int src){
    vi parents=vi(adj.size(),INF);
    parents[src]=-1;
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                parents[nbr]=c;
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return parents;
}
int powMod(int base,int exp,int mod){
    //base^exp %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}

void solve();

int main() {
    //  int t;
    //cin >> t;
    //while(t--)
    solve();
}
void solve(){
    ld R;
    cin >> R;
    cout << 2*PI*R << "\n";
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> X(N);
  for(int i=0;i<N;i++){
    cin>>X.at(i);
  }
  sort(X.begin(),X.end());
  vector<int> SUM;
  for(int j=X.at(0);j<=X.at(N-1);j++){
    int sum = 0;
    for(int i=0;i<N;i++){
      sum+=(X.at(i)-j)*(X.at(i)-j);
    }
    SUM.push_back(sum);
  }
  sort(SUM.begin(),SUM.end());
  cout<<SUM.at(0)<<endl;
  return 0;
}
    
    
    
    
    
    
    
    

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VI A(N),B(N),C(N);
    REP(i,N) {
        cin >> A[i];
        A[i]--;
    }
    REP(i,N){
        cin >> B[i];
    }
    REP(i,N-1){
        cin >> C[i];
    }
    int ans = 0;
    int pre = -2;
    REP(i,N){
        ans += B[A[i]];
        if(pre+1 == A[i]){
            ans += C[pre];
        }
        pre = A[i];
    }
    cout << ans << endl;

}


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

int main()
{
    int n, m, a, p[100], o[100];

    while( cin >> n >> m )
    {
        if( n == 0 && m == 0 )
            break;
        
        for( int i = 0; i < 100; i++ )
        {
            p[i] = 0;
            o[i] = i;
        }

        for( int i = 0; i < n; i++ )
            for( int j = 0; j < m; j++ )
            {
                cin >>  a;
                if( a == 1 )
                    p[j]++;
            }

        for( int i = 0; i < m; i++ )
            for( int j = 0; j < m - 1; j++ )
                if( p[j] < p[j+1] )
                {
                    int temp = p[j];
                    p[j] = p[j+1];
                    p[j+1] = temp;

                    temp = o[j];
                    o[j] = o[j+1];
                    o[j+1] = temp;
                }
        
        for( int i = 0; i < m - 1; i++ )
            cout << o[i] + 1 << " ";
        cout << o[m-1] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3020
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()

int main(){
	int N;cin>>N;
	ote(N/3);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define logg2 0.30102999566398119521373889472449L

typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
FO

void solve(){
    int n,k;
    cin>>n>>k;
    vector<int> v(n+2);
    ll maxx=0;
    for(int i=1;i<=n;i++) cin>>v[i];
    for(int i=0;i<=n;i++){
        for(int j=n+1;j>=i+1;j--){
            if(i+n-j+1>k) continue;
            vector<int> vc;
            ll sum=0;
            for(int a=1;a<=i;a++) {vc.push_back(v[a]);sum+=v[a];}
            for(int a=j;a<=n;a++) {vc.push_back(v[a]);sum+=v[a];}
            sort(vc.begin(),vc.end());
            int m=k-(i+n-j+1);
            /*
            for(auto vv:vc) cout<<vv<<" ";
            cout<<endl;
            */
            for(int a=0;a<m && a<vc.size();a++){
                if(vc[a]<0) sum-=vc[a];
            }
            maxx=max(maxx,sum);

        }
    }

    cout<<maxx;
    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
int n,m,R;
vector<int> r;
vector<pair<int,int> > graph[200];
int cost[200][200];
void dijkstra(int r){
    bool used[n];
    REP(i,n){
        used[i] = false;
    }
    cost[r][r] = 0;
    REP(i,n-1){
        int target;
        int tmp= 100000000;
        REP(j,n){
            if(!used[j] && cost[r][j] < tmp){
                target = j;
                tmp = cost[r][j];
            }
        }
        used[target] = true;
        REP(j,graph[target].size()){
           int to = graph[target][j].first;
           int co=graph[target][j].second;
           cost[r][to] = min(cost[r][to], cost[r][target] + co); 
        }
    }
}
int main(){
    cin >> n >> m >> R;
    REP(i,R){
        int tmp; cin >> tmp; tmp--; r.push_back(tmp);
    }
    REP(i,200){
        REP(j,200){
            cost[i][j] = 100000000;
        }
    }
    REP(i,m){
        int a,b,c; cin >> a >> b >> c; a--; b--;
        graph[a].push_back(make_pair(b,c));
        graph[b].push_back(make_pair(a,c));
    }
    REP(i,R){
        dijkstra(r[i]);
    }
    sort(r.begin(), r.end());
    int ans = 100000000;
    do{
        int tmp=0;
        vector<int>::iterator it=r.begin();
        while(it+1!=r.end()){
            tmp += cost[*it][*(it+1)];
            it++;
        }
        ans = min(ans,tmp);

    }while(next_permutation(r.begin(), r.end()));
    cout << ans << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	string s;
	cin >> s;
	if (s[0] >= 'a' && s[0] <= 'z')
		cout << "a" << endl;
	else
		cout << "A" << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll v[3002][3002];
ll s[4][3002][3002];
int main() {
	ll R, C, K;
	cin >> R >> C >> K;
	
	rep(i, 3002) {
		rep(j, 3002) {
			v[i][j] = 0;
		}
	}
	rep(i, K) {
		ll r, c;
		cin >> r >> c;
		cin >> v[r - 1][c - 1];
	}
	
	s[0][0][0] = 0;
	s[1][0][0] = 0;
	s[2][0][0] = 0;
	s[3][0][0] = 0;
	if (v[0][0] > 0) {
		s[1][0][0] = v[0][0];
	}
	rep(i, R) {
		if (i != 0) {
			if (v[i][0] == 0) {

				s[0][i][0] = max(s[0][i - 1][0], s[1][i - 1][0]);
				rep(k, 3) {
					s[k + 1][i][0] = 0;
				}

			}
			else {
				s[0][i][0] = max(s[0][i - 1][0], s[1][i - 1][0]);
				s[1][i][0] = max(s[0][i - 1][0], s[1][i - 1][0]) + v[i][0];
				s[2][i][0] = 0;
				s[3][i][0] = 0;
			}
		}
		for (ll j = 1; j < C; j++) {
			if (v[i][j] == 0) {
				rep(k, 4) {

					s[k][i][j] = s[k][i][j - 1];


					if (i != 0) {
						rep(d, 4) {
							s[0][i][j] = max(s[0][i][j], s[d][i - 1][j]);
						}
					}


				}
			}
			else {

				s[0][i][j] = s[0][i][j - 1];
				s[1][i][j] = max(s[0][i][j - 1] + v[i][j], s[1][i][j - 1]);
				s[2][i][j] = max(s[1][i][j - 1] + v[i][j], s[2][i][j - 1]);
				s[3][i][j] = max(s[2][i][j - 1] + v[i][j], s[3][i][j - 1]);
				if (i != 0) {
					rep(d, 4) {
						s[0][i][j] = max(s[0][i][j], s[d][i - 1][j]);
						s[1][i][j] = max(s[1][i][j], s[d][i - 1][j] + v[i][j]);
					}
				}

			}
		}
	}
	ll an = 0;
	rep(i, 4) {
		an = max(an, s[i][R - 1][C - 1]);
	}
	cout << an << endl;
}


Measured memory_bytes: 355316
#include<iostream>
#include<algorithm>

using namespace std;

int const N = 1e5 + 41;
long long const INF = 1e18;

int n, a[N];
long long dp[N][4];


void solve(){
	for(int i=0;i<N;++i){
		for(int j=0;j<4;++j){
			dp[i][j] = -INF;
		}
	}

	dp[0][0] = 0;
	for(int i=1;i<=n;++i){
		for(int j=0;j<=2;++j){
			long long sign = (j & 1 ? -1LL : 1LL);
			dp[i][j] = dp[i-1][j] + sign * a[i];
		}
		
		for(int j=1;j>=0;--j){
			dp[i][j] = max(dp[i][j], dp[i][j+1]);
		}
		if(a[i] < 0){
			for(int j=2;j>0;--j){
				long long sign = (j & 1 ? 1LL : -1LL);
				dp[i][j] = max(dp[i][j], dp[i-1][j-1] + a[i] * sign);
			}
		}
	}
	printf("%lld\n",dp[n][0]);
}

void read(){
	scanf("%d",&n);
	scanf("%d",&a[1]);
	for(int i=2;i<=n;++i){
		char s;
		scanf(" %c %d",&s,&a[i]);
		if(s == '-'){
			a[i] = -a[i];
		}
	}
}

void prepare(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}

int main(){
	prepare();
	read();
	solve();




	return 0;
}

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

int main(){
        int a,b;
        while(scanf("%d%d",&a,&b) != EOF){
                a += b;
                if(a == 0){
                        puts("1");
                        continue;
                }
                int ans = 0;
                while(a){
                        a /= 10;
                        ans++;
                }
                printf("%d\n",ans);
        }
        return 0;
}


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

int main() 
{
    int w,h,n,x,y,a,left,right,up,down;
    cin>>w>>h>>n;
    left=0;right=w;down=0;up=h;
    for(int i=1;i<=n;i++)
    {
    	cin>>x>>y>>a;
    	if(a==1) left=max(left,x); 
    	if(a==2) right=min(right,x); 
    	if(a==3) down=max(down,y); 
    	if(a==4) up=min(up,y); 
	}
	if(left>right||down>up)cout<<0;
	else
	cout<<(right-left)*(up-down);
   	return 0; 
}


Measured memory_bytes: 384
N, M = gets.split.map(&:to_i)
xs, ys, zs = [], [], []
N.times do |i|
    xs[i], ys[i], zs[i] = gets.split.map(&:to_i)
end

ans = 0
[-1, 1].each do |cx|
    [-1, 1].each do |cy|
        [-1, 1].each do |cz|
            result = N.times.map{|i|cx*xs[i] + cy*ys[i] + cz*zs[i]}.sort.reverse[0, M].inject(0, :+)
            ans = result if ans < result
        end
    end
end
puts ans


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
struct pr{int nw,cnt;};

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<vector<int>>v(n+1);
	for(int i=0;i<m;++i){
		int a,b; cin>>a>>b;
		v.at(a).emplace_back(b);
		v.at(b).emplace_back(a);
	}
	vector<pair<int,int>>a(n+1,{1e9,1e9}); a.at(1)={0,0};
	queue<pr>q; q.push({1,0});
	while(q.size()){
		pr tmp=q.front(); q.pop();
		int nw=tmp.nw,cnt=tmp.cnt;
		for(auto&&i:v.at(nw)){
			if(cnt+1<a.at(i).second){
				a.at(i).first=nw,a.at(i).second=cnt+1;
				q.push({i,cnt+1});
			}
		}
	}
	bool yes=true;
	for(int i=2;i<a.size();++i){
		if(a.at(i).first==1e9)yes=false;
	}
	if(yes){
		cout<<"Yes\n"s;
		for(int i=2;i<a.size();++i){
			cout<<a.at(i).first<<"\n"s;
		}
		
	}else cout<<"No\n"s;
}

Measured memory_bytes: 10860
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
 
  if (n % 2 != 0) cout << n / 2 + 1 << endl;
  else cout << n / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const LL mod=1e9+7;
LL pow(LL a,LL b)
{
	LL ans=1;
	while(b)
	{
		if(b&1) ans=(LL)ans*a%mod;
		a=(LL)a*a%mod;b>>=1;
	}
	return ans;
}
LL n,k,m,a[25010],last[410],p[25010],l[25010];
LL ans=0,f[2][25010][410],sum[410],fac[410],inv[410];
void dp(LL op,LL len)
{
	f[op][0][len]=1;
	for(LL i=1;i<=n;i++)
	{
		sum[0]=0;for(LL j=1;j<k;j++) sum[j]=(sum[j-1]+f[op][i-1][j])%mod;
		for(LL j=1;j<k;j++) f[op][i][j]=((sum[k-1]-sum[j-1])%mod+f[op][i-1][j-1]*(k-j+1)%mod)%mod;
	}
}
void pre()
{
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(LL i=2;i<=400;i++) fac[i]=(LL)fac[i-1]*i%mod,inv[i]=pow(fac[i],mod-2);
}
int main()
{
	pre();
	scanf("%lld %lld %lld",&n,&k,&m);
	for(LL i=1;i<=m;i++)
	{
		scanf("%lld",&a[i]);
		p[i]=last[a[i]];last[a[i]]=i;
	}
	LL t=0;bool flag=false;
	for(LL i=1;i<=m;i++)
	{
		t=max(t,p[i]+1);
		l[i]=t;if(i-l[i]+1==k) flag=true;
	}
	if(flag)
	{
		for(LL i=0;i<=n-m;i++) (ans+=(LL)pow(k,i)*pow(k,n-m-i)%mod)%=mod;
		printf("%lld",ans);return 0;
	}
	for(LL i=1;i<=m;i++) if(l[i]==1) t=i;
	if(t==m)
	{
		dp(0,0);
		for(LL i=1;i<=n;i++)
		{
			sum[0]=0;for(LL j=1;j<k;j++) sum[j]=(sum[j-1]+f[1][i-1][j])%mod;
			for(LL j=1;j<k;j++)
			{
				f[1][i][j]=((sum[k-1]-sum[j-1])%mod+f[1][i-1][j-1]*(k-j+1)%mod)%mod;
				if(j>=m) (f[1][i][j]+=f[0][i][j])%=mod;
			}
			//sum[0]=0;for(LL j=1;j<k;j++) sum[j]=((sum[j-1]+f[1][i-1][j])%mod+f[0][i-1][j])%mod;
			//for(LL j=m;j<k;j++) f[1][i][j]=((sum[k-1]-sum[j-1])%mod+(f[1][i-1][j-1]+f[0][i-1][j-1]*(k-j+1)%mod)%mod)%mod;
		}
		LL ans=0,tot=(LL)(n-m+1)*pow(k,n-m)%mod;
		for(LL i=1;i<k;i++) (ans+=(LL)f[1][n][i])%=mod;
		ans=(LL)ans*fac[k-m]%mod*inv[k]%mod;
		(tot-=ans)%=mod;
		printf("%lld",(tot+mod)%mod);
		return 0;
	}
	dp(0,t);dp(1,m-l[m]+1);
	for(LL i=0;i<=n-m;i++)
	{
		t=(LL)pow(k,i)*pow(k,n-m-i)%mod;
		LL k1=0,k2=0;
		for(LL j=1;j<k;j++) (k1+=f[0][i][j])%=mod,(k2+=f[1][n-m-i][j])%=mod;
		(ans+=(t-(LL)k1*k2%mod)%mod)%=mod;
	}
	printf("%lld",(ans+mod)%mod);	
}

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

int main(){
	int n;
	int ans=1000000;
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		int cnt=0;
		while(a%2==0){
			a/=2;
			cnt++;
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3616
from sys import stdin

if __name__ == '__main__':
    n = stdin.readline()
    l = stdin.readline()
    s = l.split(' ')[0]
    t = l.split(' ')[1]
    ans = ''
    sw = 0
    for i in range(len(s)):
        ans += s[i]
        ans += t[i]
    print(ans)


Measured memory_bytes: 3060
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, a[101010];

int main(){
    INIT;
    cin >> n;
    REP(i, n)cin >> a[i];
    sort(a, a + n);
    reverse(a, a + n);
    LL g = 0;
    REP(i, n){
        int num = a[i] - a[i + 1];
        if(num%2) g^=(n-i);
    }
    cout<<(g?"first":"second")<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;
typedef long long ll;

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl;
#else
#define DEBUG(x)
#endif

#define ALL(obj) (obj).begin(), (obj).end()
#define BIT(n) (1LL << (n))

const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

ll op(ll a, ll b)
{
    return a + b;
}
ll e()
{
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    // write code below
    int n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    segtree<ll, op, e> seg(a);
    for (int i = 0; i < q; i++)
    {
        int k;
        cin >> k;
        if (k == 0)
        {
            int p;
            ll x;
            cin >> p >> x;
            seg.set(p, seg.get(p) + x);
        }
        else
        {
            int l, r;
            cin >> l >> r;
            cout << seg.prod(l, r) << endl;
        }
    }
    // write code above
    return 0;
}


Measured memory_bytes: 16436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int n, k;
    cin >> n >> k;
    vector<int> victim(n, 1);
    for (int i = 0; i < n; i++) {
        int cnt;
        cin >> cnt;
        for (int j = 0; j < cnt; j++) {
            int snuke;
            cin >> snuke;
            victim[snuke-1] = 0;
        }
    }
    int total = 0;
    for (int i = 0; i < n; i++) {
        total += victim[i];
    }
    cout << total << endl;
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
    char s = 'a';
    int n, count, _count, ind;

    cin >> n;
    vector<string> ve(n);
    for(int i = 0; i < n; i++) cin >> ve[i];

    while(s <= 'z'){
        count = 0;
        for(int j = 0; j < n; j++){
            _count = 0;
            ind = ve[j].find(s);
            while(ind != -1){
                ind = ve[j].find(s, ind + 1);
                _count++;
            }
            if(_count == 0){
                count = _count;
                break;
            }else{
                if(count > _count || j == 0) count = _count;
            }
        }
        for(int j = 0; j < count; j++) cout << s;
        s++;
    }
    cout << '\n';
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long fid(int n)
{
	long long c,a,b;int i;
	a=2;b=1;
		if(n==0) return a;
		if(n==1) return b;
		if(n>=2)
			for(i=2;i<=n;i++)
			{
				c=a+b;
				a=b;
				b=c;
			}
			return c;

}
int main()
{
	int n;
	long long a;
	scanf("%d",&n);
	a=fid(n);
	printf("%lld\n",a);
}




Measured memory_bytes: 128
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
#define MOD 1000000007ll
using namespace __gnu_pbds;
using namespace std;

cc_hash_table<int,int> mp[10010],ans;

inline int my_pow(int x,int y)
{
	if(y==0ll) return 1ll;
	if(y==1ll) return x;
	int res=my_pow(x,y/2ll);
	if(y%2ll==0ll) return (res*res)%MOD;
	else return (((res*res)%MOD)*x)%MOD;
}

int n,a[10010];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		int p=a[i];
		for(int j=2;j*j<=p;j++) if(p%j==0){
			while(p%j==0){p/=j;mp[i][j]++;}
		}
		if(p!=1) mp[i][p]++;
	}
	for(int i=1;i<=n;i++){
		for(cc_hash_table<int,int>::iterator it=mp[i].begin();it!=mp[i].end();it++){
			ans[it->first]=max(ans[it->first],it->second);
		}
	}
	int lcm=1ll;
	for(cc_hash_table<int,int>::iterator it=ans.begin();it!=ans.end();it++){
		lcm*=my_pow(it->first,it->second);
		lcm%=MOD;
	}
	int ans=0ll;
	for(int i=1;i<=n;i++){
		int num=(lcm*my_pow(a[i],MOD-2ll))%MOD;
		ans+=num;
		if(ans>=MOD) ans-=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	c=a*b;
	if(c%2==0){
		printf("Even\n");
	}
	else{
		printf("Odd\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;


int main(){
	int N,A,B,C,L[10],Akari,Bkari,Ckari,ans=999999999,unite=0;
	cin>>N>>A>>B>>C;
	for(int i=0;i<N;i++){
		cin>>L[i];
	}
	for(int i=0;i<=pow(4,N);i++){
		int icopy=i;
		int ima=pow(4,N-1);
		unite=-3;
		Akari=0;
		Bkari=0;
		Ckari=0;
		for(int j=0;j<N;j++){//N回ループ L[j]について考える。
			if(icopy/ima==1){
				Akari+=L[j];
				icopy%=ima;
				unite++;
			}else if(icopy/ima==2){
				Bkari+=L[j];
				icopy%=ima;
				unite++;
			}else if(icopy/ima==3){
				Ckari+=L[j];
				icopy%=ima;
				unite++;
			}
			ima/=4;
		}
		if(Akari!=0&&Bkari!=0&&Ckari!=0){
			ans=min(ans,abs(Akari-A)+abs(Bkari-B)+abs(Ckari-C)+10*unite);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <vector>
#include <string.h>

#define pb push_back

using namespace std;

int main() {
	int n, m, k, s, p[15], ans = 0, t[15];
	bool valid;
	vector<int> adj[15];
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= m; i++) {
		scanf("%d", &k);
		while (k--) {
			scanf("%d", &s);
			adj[s].pb(i);
		}
	}
	for (int i = 1; i <= m; i++)
		scanf("%d", &p[i]);
	for (int i = 0; i < (1 << n); i++) {
		memset(t, 0, sizeof t);
		for (int j = 1; j <= n; j++)
			if (i & (1 << (j - 1)))
				for (int k = 0; k < (int) adj[j].size(); k++) {
					s = adj[j][k];
					t[s] = (t[s] + 1) % 2;
				}
		valid = true;
		for (int j = 1; j <= m; j++)
			if (t[j] != p[j]) {
				valid = false;
				break;
			}
		if (valid)
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N + 1), B(N);
	for (int i = 0; i < N + 1; i++) {
		cin >> A.at(i);
	}
	for (int i = 0; i < N; i++) {
		cin >> B.at(i);
	}

	vector<pair<int, int>> f(N);
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			f.at(i).first = min(A.at(i), B.at(i));
		} else {
			f.at(i).first = min(A.at(i) - f.at(i - 1).second, B.at(i));
		}
		f.at(i).second = min(A.at(i + 1), B.at(i) - f.at(i).first);
	}

	for (auto x : f) {
		ans += x.first + x.second;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1920
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,M = [int(x) for x in input().split()]
ABdict = {}
for _ in range (N):
    A,B = [int(x) for x in input().split()]
    if A in ABdict.keys():
        ABdict[A] += B
    else:
        ABdict[A] = B

dct = sorted(ABdict.items())
ls = []
ans = 0
for i in dct:
    if M >= 0:
        ans += min(M,i[1])*i[0]    
        M -= i[1]  

print(ans)


Measured memory_bytes: 23004
#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;
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 998244353
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 1000003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int n,d,a[mx],di[mx],b[mx];
int main(){
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	di[0]=d;
	for(int i=1;i<=n;i++){
		di[i]=di[i-1];
		if(abs(di[i-1]-a[i])<di[i-1]){
			di[i]=abs(di[i-1]-a[i]);
		}
	}
	b[n]=1;
	if(a[n]==1)b[n]++;
	for(int i=n-1;i>0;i--){
		//ga pake
		int sa=1e9+7;
		if(abs(b[i+1]-a[i])>=b[i+1])sa=b[i+1];
		// pake kurang
		int du=b[i+1]+a[i];
		//pake lebih a[i]-cari==b[i+1]
		int ti=1e9+7;
		if(a[i]>=b[i+1] && a[i]-b[i+1]>=b[i+1])ti=a[i]-b[i+1];
		b[i]=min(sa,min(du,ti));
	}
	for(int i=1;i<=n;i++){
		//debug(b[i]);
	}
	int q;
	cin>>q;
	while(q--){
		int x;
		cin>>x;
		if(x==n){
			if(di[x-1]>0){
				cout<<"YES\n";
			}
			else cout<<"NO\n";
			continue;
		}
		if(di[x-1]>=b[x+1]){
			cout<<"YES\n";
		}
		else cout<<"NO\n";
	}
}




Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 998'244'353;

int main() {
    std::ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }
    vector<vector<int>> vv(N);
    for(int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        vv[u - 1].push_back(v - 1);
        vv[v - 1].push_back(u - 1);
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        int good = 1;
        for(auto e: vv[i]) {
            if(H[e] >= H[i]) {
                good = 0;
            }
        }
        ans += good;
    }
    cout << ans;
}




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

int main(void){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H+1, vector<char>(W+1));
    
    for (int i = 1; i < H+1; i++) {
        for (int j = 1; j < W+1; j++) {
            cin >> a.at(i).at(j);
        }
    }
    
    // 行の確認
    for (int i = 1; i < H+1; i++) {
        bool is_all_white = false;
        int white_counter = 0;
        for (int j = 1; j < W + 1; j++) {
            if (a.at(i).at(j) == '.') {
                white_counter++;
            }
        }
        if (white_counter == W) {
            is_all_white = true;
        }
        if (is_all_white) {
            a.at(i).at(0) = '*';
        }
    }
    
    // 列の確認
    for (int i = 1; i < W + 1; i++) {
        bool is_all_white = false;
        int white_counter = 0;
        for (int j = 1; j < H + 1; j++) {
            if (a.at(j).at(i) == '.') {
                white_counter++;
            }
        }
        if (white_counter == H) {
            is_all_white = true;
        }
        if (is_all_white) {
            a.at(0).at(i) = '*';
        }
    }
    
    for (int i = 1; i < H + 1; i++) {
        // cout << a.at(0).at(i) << endl;
        for (int j = 1; j < W + 1; j++) {
            if (a.at(0).at(j) == '*' || a.at(i).at(0) == '*') {
                continue;
            }
            cout << a.at(i).at(j);
            
            bool bl = true;
            for (int k = j + 1; k < W + 1; k++) {
                if (a.at(0).at(k) != '*')
                    bl = false;
            }
            if (bl) {
                cout << 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 = 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 Lmax = L[0];
		int Rmax = R[0];
		int Lmin = L[0];
		int Rmin = R[0];
		for(int i = 0; i < M; i++) {
			if(Lmax < L[i]) Lmax = L[i];
			if(Lmin > L[i]) Lmin = L[i];
			if(Rmax < R[i]) Rmax = R[i];
			if(Rmin > R[i]) Rmin = R[i];

		}
		int ok = 0;

		for(int i =1; i<=N; i++) {
			if(Lmax<=i && i<=Rmin) ok++;


		}

		System.out.println(ok);


	}

}

Measured memory_bytes: 76688
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<tuple>
#include<set>
#include<functional>

template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
int main()
{
	int N, M;
	std::cin >> N >> M;
	std::vector<std::map<int, int>> edge(N);
	std::set<std::pair<int, int>> set;
	for (int i{};i < M;++i)
	{
		int a, b, c;
		std::cin >> a >> b >> c;
		edge[a - 1][b - 1] = c;
		edge[b - 1][a - 1] = c;
		set.emplace(std::max(a - 1, b - 1), std::min(a - 1, b - 1));
	}

	for (int i{};i < N;++i)
	{
		std::vector<int> flag(N, 9999999);
		flag[i] = 0;
		p_queue<std::tuple<int, int, int>> queue;
		for (auto const& p : edge[i])
		{
			queue.emplace(p.second, p.first, i);
		}
		while (queue.size())
		{
			auto top = queue.top();
			queue.pop();
			auto dis = std::get<0>(top);
			auto now = std::get<1>(top);
			auto from = std::get<2>(top);
			if (flag[now] < dis)
			{
				continue;
			}
			set.erase(std::make_pair(std::max(from, now), std::min(from, now)));
			if (flag[now] == dis)
			{
				continue;
			}
			flag[now] = dis;
			for (auto const& p : edge[now])
			{
				queue.emplace(dis + p.second, p.first, now);
			}
		}
	}
	std::cout << set.size() << std::endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string s;
    cin >> s;
    ll cnt = 0, n = s.size();
    rep(i, 0, n/2) {
        if(s[i] != s[n-1-i]) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256