akhauriyash/Code-Regression huggingface dataset:
/*=============================================================================================================================/*
                                               Bismillahir Rahmanir Rahim

      _     ____  ___  ____   _   _  _         ___  ____   _         _     __  __
     / \   / ___||_ _|| __ ) | | | || |       |_ _|/ ___| | |       / \   |  \/  |
    / _ \  \___ \ | | |  _ \ | | | || |        | | \___ \ | |      / _ \  | |\/| |
   / ___ \  ___) || | | |_) || |_| || |___     | |  ___) || |___  / ___ \ | |  | |
  /_/   \_\|____/|___||____/  \___/ |_____|   |___||____/ |_____|/_/   \_\|_|  |_|

   _   __           __  __  __
  |_) (_  _  o__   /   (_  |_
  |_)o__)(_  || |  \__ __) |__

    ___                    _   _      _                _ _               __   ___                 _         _        _
   / __|_ _ ___ ___ _ _   | | | |_ _ (_)_ _____ _ _ __(_) |_ _  _   ___ / _| | _ ) __ _ _ _  __ _| |__ _ __| |___ __| |_
  | (_ | '_/ -_) -_) ' \  | |_| | ' \| \ V / -_) '_(_-< |  _| || | / _ \  _| | _ \/ _` | ' \/ _` | / _` / _` / -_|_-< ' \
   \___|_| \___\___|_||_|  \___/|_||_|_|\_/\___|_| /__/_|\__|\_, | \___/_|   |___/\__,_|_||_\__, |_\__,_\__,_\___/__/_||_|
                                                            |__/                           |___/


   FB: https://facebook.com/SIAsibul
   Gmail: asibulislam8@gmail.com

/*=============================================================================================================================*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
typedef vector<pll> vll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,n) for(ll i=0;i<(n);i++)
#define f1(i,n) for(ll i=1;i<=(n);i++)
#define f2(i,a,n) for(ll i=(a);i<=(n);i++)
#define fr(i,n,a) for(ll i=(n);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define nl "\n"


const int INF = 1e9 + 5;
const int MXN = 2e5 + 5;
const int MOD = 1e9 + 7;


void solve(){
    int64_t n, d; cin >> n >> d;
    int64_t cnt = 0;
    f0(i, n){
        int64_t x, y; cin >> x >> y;
        if(x*x + y*y <= d*d) cnt++;
    }

    cout << cnt << nl;
}

int main(){
    ll t;
    //cin >> t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
 }


Measured memory_bytes: 3600
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const long long MOD = i64(1e9) + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;

auto mpow = [](auto x, i64 y){
 auto z = x;
 decltype(x) val = y & 1 ? x : decltype(x)(1);
 while(z *= z, y >>= 1)
  if(y & 1)
   val *= z;
 return val;
};

auto factoring = [](i64 x){
 int sq = sqrt(x) + 1;
 vector<int> ret;
 if(x == 1){
  ret.emplace_back(1);
  return ret;
 }
 for(i64 i = 2; i < sq; ++i)
  while(x % i == 0){
   ret.emplace_back(i);
   x /= i;
  }
 if(x != 1)
  ret.emplace_back(x);
 return ret;
};

void solve(long long n, std::vector<long long> a){

    map<int,int> t;
    for(auto& x : a){
        auto fac = factoring(x);
        map<int,int> tt;
        for(auto& y : fac)
            ++tt[y];
        for(auto& p : tt)
            chmax(t[p.first], p.second);
    }

    mint m = 1;
    for(auto& p : t)
        m *= mpow(mint(p.first), p.second);

    mint ans = 0;
    for(auto& x : a){
        ans += m * mpow(mint(x), 1e9 + 5);
    }
    cout << ans << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 768
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
s = [0]*(N+1)

d = defaultdict(int)
for i in range(N):
    s[i+1] = s[i] + A[i]
for i in range(N+1):
    d[s[i]]+=1

ans = 0
for v in d.values():
    if v >= 2:
        ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 112976
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int a,b;
  cin>>a>>b;
  
  if(a>9 ||b >9)
  {
    cout<<"-1"<<endl;
  }
  else
  {
   cout<<a*b<<endl; 
  }
  return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  n <- readInt
  arr <- UV.fromList <$> readIntList
  let valSum = UV.sum arr
  m <- readInt
  drinks <- forM [1..m] (const readIntList)
  forM_ drinks (\d -> print $ solve d arr valSum)

solve [p, x] arr valSum = valSum - arr UV.! (p - 1) + x


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

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

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

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

	string s, t; cin >> s >> t;
	int ans = 987654321;
	for (int i = 0; i <= s.size() - t.size(); i++)
	{
		int res = 0;
		for (int j = 0; j < t.size(); j++)
		{
			if (s[i + j] != t[j]) res++;
		}
		ans = min(ans, res);
	}

	cout << ans;
}

Measured memory_bytes: 3656
#include<stdio.h>
int main(){
	bool p[100010];//そすう
//	bool pold[100010];
	bool q[100010];//似た数
	int que;
	int l[100010];
	int r[100010];
	scanf("%d",&que);
	for(int i=0;i<que;i++){
		scanf("%d %d",&l[i], &r[i]);
	}
	for(int i=0;i<100010;i++){
		p[i]=1;
		q[i]=0;
	}
	p[0]=0;
	p[1]=0;
	for(int i=2;i<500;i++){
		if(p[i]){
			int baisuu=i;
			while(baisuu<100010){
				baisuu+=i;
				p[baisuu]=0;
			}
		}
	}
	for(int i=3;i<100010;i++){
		if(p[i]&&p[(i+1)/2]){
			q[i]=1;
		}
	}
	q[0]=0;
	q[1]=0;
	q[2]=0;
	int qs[100010];
	qs[0]=0;
	for(int i=1;i<100010;i++){
		qs[i]=qs[i-1]+q[i];
	}
	for(int i=0;i<que;i++){
		printf("%d\n",qs[r[i]]-qs[l[i]-1]);
	}
//	printf("end\n");		
}

Measured memory_bytes: 1920
while line = gets
  a = line.chomp.to_i
  break if a == 0
  b = gets.chomp.split.map(&:to_i)

  i, n = 0, 32
  while n > 0
    n -= (n - 1) % 5
    puts n
    c = b[i % a]
    c = n if c > n
    n -= c
    puts n
    i += 1
  end
end

Measured memory_bytes: 8704
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Arrays;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		for(int x = 0; x < totalVertex; x++){
			for(int y = 0; y < totalVertex; y++){
				adjMatrix[x][y] = 0;
			}
		}

		for(int i = 0; i < totalVertex; i++){
			for(int j = 0; j < totalVertex; j++){
				for(Integer o: adjList.get(i)){
					if(o == j){
						adjMatrix[i][j] = 1;
					}
				}
			}
		}
		for(int j = 0; j < totalVertex; j++){
			for(int k = 0; k < totalVertex; k++){
				if(k == totalVertex - 1){
					System.out.print(adjMatrix[j][k]);
				}else{
					System.out.print(adjMatrix[j][k] + " ");
				}
			}
			System.out.print("\n");
		}
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
		
	}
}



Measured memory_bytes: 34972
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int D; cin >> D;
  switch(D) {
    case 25: cout << "Christmas" << endl; break;
    case 24: cout << "Christmas Eve" << endl; break;
    case 23: cout << "Christmas Eve Eve" << endl; break;
    case 22: cout << "Christmas Eve Eve Eve" << endl; break;
  }
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  int d[n];
  int check[n];
  int ans = 0;
  
  for(int i = 0; i < n; i++){
    cin >> d[i];
    
    int j;
    for(j = 0; j < i; j++){
      if(d[i] == check[j]){
        break;
      }
    }
    if(j == i){
      check[j] = d[i];
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a;
	int sum=0;
	for(int i=0;i<5;i++){
		scanf("%d",&a);
		if(a<40){
			sum+=40;
		}
		else{
			sum+=a;
		}
	}
	printf("%d\n",sum/5);
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

    map<string,int> mp;
    rep(i,n){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans=0;
    for(auto p:mp){
        int s=p.second;
        ans+=(ll)s*(s-1)/2;
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 11396
#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;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 998244353
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 100005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len,cnt[MAXN],mx;
ll fact[MAXN],res=1;

int main(){
	scanf("%d",&len);
	fact[0] = 1;
	for(int i=1; i<=len; i++){
		int a; scanf(" %d",&a);
		cnt[a]++;
		if(a == 0 && i != 1) return 0*printf("0\n");
		fact[i] = (fact[i-1]*i)%MOD;
		mx = max(mx,a);
	}
	if(!cnt[0]) return 0*printf("0\n");
	for(int i=1; i<=mx; i++){
		if(i && !cnt[i-1]) return 0*printf("0\n");
		ll val = fpow(cnt[i-1],cnt[i],MOD);
		res = (res*val)%MOD;
	}
	printf("%lld\n",res);
}

Measured memory_bytes: 1408
N = int(input())
A = [int(x) for x in input().split()]

confortability = sorted(A,reverse=True)
neighbours = 0
idx = 0
ans = 0
for i, conf in enumerate(confortability):
    if i == 0:
        continue
    if neighbours < 1:
        ans += confortability[idx]
        neighbours += 1
    else:
        idx += 1
        ans += confortability[idx]
        neighbours = 0

print(ans)

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n = 5;
  vector<P> data(n);
  rep(i,n) {
    int a;
    cin >> a;
    int b = (a-1) % 10;
    data[i] = make_pair(b,a);
  }
  sort(rall(data));
  int ans = 0;
  rep(i,n-1) {
    ans += data[i].second;
    ans += 9-data[i].first;
  }
  ans += data[4].second;
  cout << ans << endl;
}

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

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

  int all = 0;
  for(int i = 0;i<N;i++){
    all += s[i];
  }
  if(all%10 != 0) cout << all << endl;
  else{
    sort(s.begin(),s.end());
    int c = 0;
    for(int i = 0;i<N;i++){
      if(s[i]%10 != 0){
        c = s[i];
        break;
      }
    }
    if(c != 0) cout << all-c << endl;
    else cout << 0 << endl;
  }
      
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
using namespace std; 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() << x; }
template<typename T> void db(T x , T y){ debug() << x <<" "<< y; }
template<typename T> void db(T x , T y , T z){ debug() << x <<" "<< y <<" "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() << x <<" " << y <<" "<< z <<" "<< a; }

const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;


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

  int n;
  cin >> n;
  vector<int>A(n+1);
  for(int i=1;i<=n;i++){
    cin >> A[i];
  }

  map<int,int>Cnt;
  int ans = 0;
  for(int i=1;i<=n;i++){
    ans += Cnt[i - A[i]];
    Cnt[i + A[i]]++;
  }

  cout << ans << '\n';

}

Measured memory_bytes: 27016
#abc147c
n=int(raw_input())
p=[[] for i in range(n)]
for i in range(n):
 a=int(raw_input())
 for j in range(a):
  p[i].append(map(int,raw_input().split()))
res=0
for i in range(2**n):
 a=[(i>>j) & 1 for j in range(n-1,-1,-1)]
 x=1
 for k in range(n):
  if a[k]*x==1:
   for l in p[k]:
    if a[l[0]-1]!=l[1]:
     x=0
 res=max(res,x*sum(a))
print res


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, m; cin >> n >> m;
    vector<vector<int>> city(n);
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        city[a].push_back(b);
        city[b].push_back(a);
    }
    rep(i, n) cout << (int)city[i].size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n;
    cin >> n;
    vector<ll> x(n);
    REP(i, n) cin >> x[i];
    ll min_v = INF;
    FOR(i, 1, 100) {
        ll sum = 0;
        REP(j, n) {
            sum += (x[j]-i)*(x[j]-i);
        }
        min_v = min(min_v, sum);
    }
    cout << min_v << endl;
    return 0;
}

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

using namespace std;

struct net
{
    int x,y;
};

char a[3005],b[3005];
int mem[3005][3005];
net btrack[3005][3005];


int main()
{
    cin >> a;
    cin >> b;
    int x,y;
    x = strlen(a);
    y = strlen(b);
    int i,j;
    btrack[0][1] = {0,0};
    for(i=1;i<=x;i++)
    {
        for(j=1;j<=y;j++)
        {
            if(a[i-1] == b[j-1])
            {
                mem[i][j] = mem[i-1][j-1]+1;
                btrack[i][j].x = i-1;
                btrack[i][j].y = j-1;
            }
            else
            {
                if(mem[i][j-1]>mem[i-1][j])
                {
                    mem[i][j] = mem[i][j-1];
                    btrack[i][j].x = i;
                    btrack[i][j].y = j-1;
                }
                else
                {
                    mem[i][j] = mem[i-1][j];
                    btrack[i][j].x = i-1;
                    btrack[i][j].y = j;
                }
            }
        }
    }
    net l;
    l.x = x;
    l.y = y;
    int c = 0;
    char d[3005];
    while(l.x||l.y)
    {
        if(a[l.x-1] == b[l.y-1])
        {
            d[c++] = a[l.x-1];
        }
        l = btrack[l.x][l.y];
    }
    for(i=0;i<c;i++)
    {
        printf("%c",d[c-i-1]);
    }
}


Measured memory_bytes: 106112
import sys

input = sys.stdin.readline


def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    time = sum(B)
    i_B = M - 1
    ans = 0
    for i in range(0, N + 1):
        for j in reversed(range(i_B + 1)):
            if time <= K:
                break
            time -= B[j]
            i_B -= 1
        if time > K:
            break
        ans = max(ans, i + (i_B + 1))
        if i < N:
            time += A[i]

    print(ans)


if __name__ == "__main__":
    main()


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


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

  if(n==1){
    cout<<"Hello World"<<endl;
  }else{
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
  }


return 0;}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#define all(x) (x).begin(),(x).end()
#define size(x) ((int)(x).size()) 
#define FIRST first 
#define SECOND second
#define FRONT front
#define PUSH_BACK push_back
#define MAKE_PAIR make_pair 
#define EMPTY empty
#define PRIORITY_QUEUE priority_queue
using namespace std;
typedef long long LL;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef unsigned long long uLL;  
//head

const int maxn = 123;
int vin[maxn], vout[maxn];
const int inf = 1e8;
int len[maxn];
struct edge
{
	int v, r, w, c;
};
std::vector<edge> G[maxn];
int h[maxn], dist[maxn];
int pv[maxn], pe[maxn];
int V;
std::vector<pii> d[maxn];
int DAG_longest_path(int u, int t){
	if(u == t || len[u]) return len[u];
	for(auto e : d[u]){
		len[u] = max(len[u], e.second + DAG_longest_path(e.first, t));	
	}
	return len[u];
}

void add(int u, int v, int w, int cost){
	G[u].push_back((edge){v, size(G[v]), w, cost});
	G[v].push_back((edge){u, size(G[u])-1, 0, -cost});
} 

int min_cost_flow(int s, int t, int flow){
	int res = 0;
	fill(h, h+V, 0);
	while(flow > 0){
		fill(dist, dist+V, inf);
		dist[s] = 0;
		priority_queue<pii, std::vector<pii>, greater<pii> > q;
		q.push(pii(0, s));
		while(!q.empty()){
			pii x = q.top(); q.pop();
			int u = x.second;
			if(dist[u] < x.first) continue;
			for(int i = 0; i < size(G[u]); i++){
				edge &e = G[u][i];
				int k = h[u] + dist[u] + e.c - h[e.v];
				if(k < dist[e.v] && e.w > 0){
					dist[e.v] = k;
					q.push(pii(k, e.v));
					pv[e.v] = u;
					pe[e.v] = i;
				}
			}
		}
		if(dist[t] == inf) {
			return -1;	//不能再增广
		}
		for(int i = 0; i < V; i++){
			h[i] += dist[i];
		}   
		int tf = flow;
		for(int v = t; v != s; v = pv[v]){
			tf = min(tf, G[pv[v]][pe[v]].w);
		}	
		if(tf){
			for(int v = t; v != s; v = pv[v]){
				edge &e = G[pv[v]][pe[v]];
				e.w -= tf;
				G[v][e.r].w += tf;
			}
			res += tf * h[t];
			flow -= tf;
		}
	}
	return res;	
}


int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	int tot = 0;
	for(int i = 0; i < m; i++){
		int u, v, w;
		cin >> u >> v >> w;
		vin[v]++, vout[u]++;
		d[u].push_back(pii(v, w));
		add(u, v, inf, -w);
		tot += w;
	}
	DAG_longest_path(0, n-1);
	int s = n, t = n+1;
	V = n+2;
	add(n-1, 0, inf, len[0]);
	for(int i = 0; i < n; i++){
		if(vin[i] > vout[i]){
			add(s, i, vin[i]-vout[i], 0);
			vout[s] += vin[i] - vout[i];
		}else if(vout[i] > vin[i]){
			add(i, t, vout[i]-vin[i], 0);
		}
	}
	cout << min_cost_flow(s, t, vout[s]) - tot << endl;
	return 0;
}


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

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

  vector<int> a(N);

  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }

  int ans = 1, sum = 0;

  for(int i = 0; i < N; i++){
    sum += a.at(i);
    if(sum <= x){
      ans++;
    }
  }

  cout << ans << endl;

  
}

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

int n;
vector<vector<int>> g;

int counter = 1;
vector<bool> visited;
vector<int> ord, par, low;

struct Graph {
  size_t n;
  int cnt;
  vector<vector<int>> g;
  vector<bool> isArt;
  vector<int> ord, low;
  vector<pair<int, int>> bridges;

  Graph(size_t n) : n(n), cnt(0), g(n), ord(n, -1), low(n, -1), isArt(n, false) {}

  void addEdge(int u, int v) {
    g[u].push_back(v);
    g[v].push_back(u);
  }
  void dfs(int u) {
    ord[u] = low[u] = cnt++;
    for (auto&& v : g[u]) {
      if (ord[v] == -1) {
        dfs(v);
        low[u] = min(low[u], low[v]);
        if (ord[u] <= low[v]) isArt[u] = (ord[u] > 0) || (ord[v] > 1);
        if (ord[u] < low[v]) bridges.push_back({min(u, v), max(u, v)});
      } else {
        low[u] = min(low[u], ord[v]);
      }
    }
  }
  void biconnectedComponents() {
    for (int i = 0; i < n; ++i) {
      if (ord[i] == -1) dfs(i);
    }
  }
};

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

  int m; cin >> n >> m;
  Graph g(n);
  while (m--) {
    int s, t; cin >> s >> t;
    g.addEdge(s, t);
  }
  g.biconnectedComponents();
  for (int i = 0; i < n; ++i) {
    if (g.isArt[i]) cout << i << endl;
  }
  return 0;
}



Measured memory_bytes: 4284
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  string s;
  cin >> s;
  string a = "A", kih = "KIH", b = "B", r = "R";
  REP(i, (1 << 4))
  {
    string ans = "";
    if ((i & 1) % 2 == 1)
    {
      ans += a;
    }
    ans += kih;
    if ((i >> 1) % 2 == 1)
    {
      ans += a;
    }
    ans += b;
    if ((i >> 2) % 2 == 1)
    {
      ans += a;
    }
    ans += r;
    if ((i >> 3) % 2 == 1)
    {
      ans += a;
    }
    if (ans == s)
    {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e5 + 7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    vector<vector<int>> roads(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        roads[x].push_back(y);
        roads[y].push_back(x);
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        bool ok = true;
        for (auto x : roads[i]) {
            if (h[i] <= h[x]) ok = false;
        }
        if (ok) cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 8776
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  ll ans=0;
  ll ans2=0;
  int M=-1001001001;
  int MM=-1;
  rep(i,N){
    if(i%2 and A[i]>0) ans+=A[i];
    else if(i%2==0 and A[i]>0) ans2+=A[i];
    if(M<A[i]){
      M=A[i];
      MM=i;
    }
  }
  if(M<0){
    cout<<M<<endl;
    cout<<N-1<<endl;
    rep(i,MM) cout<<1<<endl;
    rep(i,N-MM-1) cout<<N-MM-i<<endl;
  }else if(ans>ans2){
    VI F(N);
    rep(i,N) if(i%2 and A[i]>0) F[i]++;
    VI X;
    while(!F[0]){
      X.pb(1);
      F.erase(F.begin());
    }
    while(!F[F.size()-1]){
      X.pb(F.size());
      F.erase(F.end()-1);
    }
    while(F.size()>1){
      rep(i,F.size()-2){
        if(!F[i+1] and F[i]==F[i+2]){
          X.pb(i+2);
          F.erase(F.begin()+i);
          F.erase(F.begin()+i);
          break;
        }
      }
    }
    cout<<ans<<endl;
    cout<<X.size()<<endl;
    rep(i,X.size()) cout<<X[i]<<endl;
  }else{
    VI F(N);
    rep(i,N) if(i%2==0 and A[i]>0) F[i]++;
    VI X;
    while(!F[0]){
      X.pb(1);
      F.erase(F.begin());
    }
    while(!F[F.size()-1]){
      X.pb(F.size());
      F.erase(F.end()-1);
    }
    while(F.size()>1){
      rep(i,F.size()-2){
        if(!F[i+1] and F[i]==F[i+2]){
          X.pb(i+2);
          F.erase(F.begin()+i);
          F.erase(F.begin()+i);
          break;
        }
      }
    }
    cout<<ans2<<endl;
    cout<<X.size()<<endl;
    rep(i,X.size()) cout<<X[i]<<endl;
  }
}

Measured memory_bytes: 256
import math
import numpy as np


#横並び
#a, b, c, x = map(int, [input() for i in range(4)])
#z = list(map(int, input().split()))
#n, a, b = map(int, input().split())

#print(len(z))
#for i in z:
#    print(i)

#a = sorted(a,reverse = True)
#print(sum(a[::2]) - sum(a[1::2]))
#z = map(int, [input() for i in range(int(n))])
#data_list = [ list(map(int,input().split(" "))) for i in range(3)]


a = int(input())
s = input()

if a >= 3200:
    print(s)
else:
    print("red")


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

struct my{
    string cityName;
    int score;
    int no;
}x[200];

bool cmp(my &a, my &b){
    if(a.cityName == b.cityName)
        return a.score > b.score;
    else
        return a.cityName < b.cityName;
}

int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin>>x[i].cityName>>x[i].score;
        x[i].no = i+1;
    }
    sort(x, x+n, cmp);
    for(int i=0;i<n;i++)
        printf("%d\n",x[i].no);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>

using namespace std;

long arr[100007];
int num[3];
int N;

int main(){
  num[0] = num[1] = num[2] = 0;
  cin >> N;
  for( int i = 0; i < N; i++ ){
	cin >> arr[i];
	if( (arr[i] >> 2) << 2 == arr[i] ){
	  num[2]++;
	}else if( (arr[i] >> 1) << 1 == arr[i] ){
	  num[1]++;
	}else{
	  num[0]++;
	}
  }
  if( num[0] > num[2] + 1 ){
	cout << "No" << endl;
  }else if( num[0] == num[2] + 1 && num[1] > 0 ){
	cout << "No" << endl;
  }else{
	cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;




int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll a,b;cin>>a>>b;
    if(a > b) swap(a, b);
    if((a+b)&1) cout << "IMPOSSIBLE";
    else cout << (a+b)/2;
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer x = Integer.parseInt(scanner.next());

        int[] a = new int[x];
        for(int i=0; i < x; i++) {
            a[Integer.parseInt(scanner.next()) - 1] = i;
        }

        for(int i = 0; i < x; i++) {
            System.out.println(a[i]+1);
        }
    }
}

Measured memory_bytes: 52240
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
temp = [0]*n
ans = [0]*n

for i in range(n):
    temp[i] = t - h[i] * 0.006
    ans[i] = abs(temp[i] - a)

print(ans.index(min(ans))+1)

Measured memory_bytes: 3064
n = int(input())
a = [0] + list(map(int,input().split())) + [0]
s = 0
for i in range(n+1):
  s += abs(a[i+1] - a[i])

for i in range(n):
  print(s - abs(a[i+2]-a[i+1]) - abs(a[i+1]-a[i]) + abs(a[i+2]-a[i]))

Measured memory_bytes: 13920
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};


int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int diviser(int n) {
  int ret = 0;
  for(int i=1; i<=n; i++) {
	if(n % i == 0) ret++;
  }
  return ret;
}


int main(){
  int N;
  int ans = 0;
  cin >> N;
  for(int i=1; i <=N; i++) {
	if(i % 2 == 1) {
	  int num = diviser(i);
	  if(num == 8) ans++;
	}
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ALDS1_1_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] r = new int[n];
            int maxv, min;
            for (int i = 0; i < n; i++)
            {
                r[i] = int.Parse(Console.ReadLine());
            }
            maxv = r[1] - r[0];
            min = r[0];
            for (int i = 1; i < n; i++)
            {
                if (maxv < r[i] - min) { maxv = r[i] - min; }
                if (min > r[i]) { min = r[i]; }
            }
            Console.WriteLine(maxv);
        }
    }
}



Measured memory_bytes: 22352
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cassert>
#include <string.h>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n;i>0;i--)
#define  REP(i,a,b) for(int i=a;i<b;i++)
typedef long long int lld;
typedef vector<lld> vl;
typedef vector<int> vi;
typedef vector<string> vs;



//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();

int main() {

	int n,ans=0,tmp;
	cin>>n;
  vi a(n),b(n);
 rep(i,n){
   cin>>a[i];
 }
  rep(i,n){
   cin>>b[i];
 }
  rep(i,n){
    tmp=a[i]-b[i];
    if(tmp>0)
      ans+=tmp;
  }
  cout<<ans;
  return 0;
  
}
 
    


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000003
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 1000010


int main() {
	long long k[N];
	long long r[N];
	bool s[40];
	long long ss[40];
	long long n, a, b, c,d;
	long long x, y, z, ans,w;
	long long q;
	x = MOD - 2;
	k[0] = 1;
	f(i, N - 1)k[i + 1] = (k[i] * (i + 1)) % MOD;
	x = MOD-2;
	f(i, 40) {
		if (x % 2 == 1)s[i] = true;
		else s[i] = false;
		x /= 2;
	}
	f(i, N) {
		ss[0] = k[i];
		f(j, 39)ss[j + 1] = (ss[j] * ss[j]) % MOD;
		r[i] = 1;
		f(j, 40)if (s[j])r[i] = (r[i] * ss[j]) % MOD;
	}

	scanf("%lld", &q);
	f(qq, q) {
		scanf("%lld %lld %lld", &a, &d, &n);
		if (d == 0) {
			x = n;
			f(i, 40) {
				if (x % 2 == 1)s[i] = true;
				else s[i] = false;
				x /= 2;
			}
			ss[0] = a;
			f(j, 39)ss[j + 1] = (ss[j] * ss[j]) % MOD;
			y = 1;
			f(j, 40)if (s[j])y = (y * ss[j]) % MOD;
			printf("%lld\n", y);
		}
		else {
			if (n >= MOD)printf("0\n");
			else {

				x = n;
				f(i, 40) {
					if (x % 2 == 1)s[i] = true;
					else s[i] = false;
					x /= 2;
				}
				ss[0] = d;
				f(j, 39)ss[j + 1] = (ss[j] * ss[j]) % MOD;
				w = 1;
				f(j, 40)if (s[j])w = (w * ss[j]) % MOD;


				x = MOD-2;
				f(i, 40) {
					if (x % 2 == 1)s[i] = true;
					else s[i] = false;
					x /= 2;
				}
				ss[0] = d;
				f(j, 39)ss[j + 1] = (ss[j] * ss[j]) % MOD;
				y = 1;
				f(j, 40)if (s[j])y = (y * ss[j]) % MOD;
				x = (a*y) % MOD;
				y = x + n - 1;
				if (x == 0)printf("0\n");
				else if (y >= MOD)printf("0\n");
				else {
					z = k[y];
					z = (z*r[x - 1]) % MOD;
					z = (z*w) % MOD;
					printf("%lld\n", z);
				}
			}
		}
	}

	return 0;
}

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

int main() {
    
    int N, K, diff;
    cin >> N;
    cin >> K;
    diff = N-K;
    
    if (diff<=0){
        cout << 0 << endl;
    }
    else{
        vector<int> vec(N);
    
        for (int i=0;i<N; i++){
            cin >> vec.at(i);
        }
        sort(vec.begin(), vec.end());
    
        long count=0;
        for (int i=0; i<diff; i++){
            count+=vec.at(i);
        }
        cout << count << endl;
}
}

Measured memory_bytes: 1024
N =list(str(input()))
l=['A','C','G','T']

ans=0
for i in range(len(N)):
    num=0
    for u in range(len(N)-i):
        #print(N[i+u])
        if N[i+u] in l:
            num+=1
        else:
            break
    ans=max(ans,num)        
print(ans)

Measured memory_bytes: 61800
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
#define ll long long
const int mod1 = 1e9+7;
const int mod2 = 998244353;

int n,m;
int a[maxn],b[maxn];

int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	b[0]=0;
	int k;
	for(int i=1;i<=n;i++){
		b[i]=b[i-1]+a[i];
		if(b[i]>m){
			k=i;
			break;
		}
	}
	cout<<k;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const long long maxn=100000+50;
long long n,m,w[maxn],v[maxn],dp[maxn];
int main()
{
	cin>>n>>m;
	for(long long i=1;i<=n;i++)cin>>w[i]>>v[i];
	memset(dp,0x7f7f7f7f,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=100000;j>=v[i];j--)
		{
			if(dp[j-v[i]]||j-v[i]==0)
			{
				dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
			}
		}
	}
	for(int j=100000;j>=1;j--)
	{
		if(dp[j]&&dp[j]<=m)
		{
			cout<<j<<endl;
			return 0;
		}
	}
	return 0;
}
//Phoenix-ZH

Measured memory_bytes: 4344
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
const long long INF = 1LL<<60;


int main(){	
	int A,B;
	cin >> A >> B;
	if(A-(B*2) < 0){
		cout << 0 << endl;
	}else{
		cout << A-(B*2) << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
	string s;
	int x[26] = {};
	while(getline(cin,s) ){
		for(int i = 0;i < s.size();i++){
			char c = s.at(i);
			c = tolower(c);
			x[c - 'a']++;
		}
	}
	
	for(int i = 0;i < 26;i++){
		cout << char(i+'a') <<" : "<< x[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3224
k = int(input())

if k == 1:
    ans = 1
elif k % 2 == 0 or k % 5 == 0:
    ans = -1
else:
    l = (9*k//7) if k % 7 == 0 else 9*k
    v = 1
    for i in range(1, l+1):
        v = (v*10) % l
        if v == 1:
            ans = i
            break
print(ans)


Measured memory_bytes: 62996
from collections import deque

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
move = [(1,0), (0,1), (-1,0), (0,-1)]

queue = deque()
visited = [[-1] * w for _ in range(h)]
for row in range(h):
    for col in range(w):
        if a[row][col] == "#":
            visited[row][col] = 0
            queue.append((row, col, 0))
dist = 0
while queue:
    row, col, dist = queue.popleft()
    for drow, dcol in move:
        if a[row+drow:row+drow+1] and a[row+drow][col+dcol:col+dcol+1] and visited[row+drow][col+dcol] == -1 and a[row+drow][col+dcol] == ".":
            visited[row+drow][col+dcol] = dist + 1
            queue.append((row+drow, col+dcol, dist+1))


print(dist)


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N;
	cin >> N;
	vector <ll> A(N, 0);
	for (int ii = 0; ii < N; ++ii){
		cin >> A[ii];
	}

	vector <ll> X(N, 0);
	X[0] = A[0];
	for (ll ii = 1; ii < N; ++ii){
		ll sign = 1 - 2 * (ii % 2);
		X[0] += sign * A[ii];
	}
	for (int ii = 0; ii < N - 1; ++ii){
		X[ii+1] = 2 * A[ii] - X[ii];
	}

	for (int ii = 0; ii < N; ++ii){
		cout << X[ii] << " ";
	}
	cout << "\n";

	return 0;
}


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

int main() {
	// your code goes here
	long long int a,b,k;
	cin>>a>>b>>k;
	if(a>=k)
	{
	    a=a-k;
	}
	else if(a+b>=k)
	{
	    b=b-(k-a);
	    a=0;
	}
	else
	{
	    a=0;b=0;
	}
	cout<<a<<" "<<b<<"\n";
	return 0;
}


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

int main(int argc, char const* argv[])
{
    uint64_t n, c, k;
    std::cin >> n >> c >> k;

    auto vec = std::vector<uint64_t>(n);
    for(auto &a_t: vec)
    {
        std::cin >> a_t;
    }

    std::sort(vec.begin(), vec.end());

    uint64_t result = 0;
    uint64_t wait_first = -1;
    uint64_t num_of_passenger = 0;
    for(auto a_t: vec)
    {
        if(wait_first == -1)
        {
            wait_first = a_t;
            num_of_passenger = 1;
            continue;
        }

        if((a_t - wait_first) <= k)
        {
            if(num_of_passenger >= c)
            {
                result++;
                wait_first = a_t;
                num_of_passenger = 1;
            }
            else
            {
                num_of_passenger++;
            }
        }
        else
        {
            result++;
            wait_first = a_t;
            num_of_passenger = 1;
        }
    }

    std::cout << ++result << std::endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX (1<<20)

using namespace std;

typedef long long ll;

ll dp[MAX][2],ans;
int N,H,W,r[20][20],CNT=1;

int main(){
  cin >> N;
  while(N--){
    ans = 0;
    cin >> W >> H;
    rep(i,H)rep(j,W)cin >> r[i][j];
    rep(i,MAX)rep(j,2)dp[i][j] = 0;
    rep(i,(1<<W)){
      ll cost = 0;
      bool out = false;
      rep(j,W){
	if( ( (i>>j)&1 ) && ( j-1>=0 && ((i>>(j-1))&1) ) ){
	  out = true;
	  break;
	}
	if( (i>>j)&1 )cost += r[0][j];
      }
      if(out)continue;
      dp[i][0] = cost;
      ans = max(ans,cost);
    }
    int bitmask = (1<<W)-1;
    bool phase = 0;
    REP(y,1,H){
      rep(x,W){
	rep(state,(1<<W)){
	  // not use
	  int nstate = (state>>1)&bitmask;
	  dp[nstate][!phase] = max(dp[nstate][!phase],dp[state][phase]);
	  ans = max(ans,dp[nstate][!phase]);

	  // use
	  if( (state&1) || ( ( (state>>(W-1))&1 ) && x-1>=0  ) )continue;
	  nstate |= (1<<(W-1));
	  dp[nstate][!phase] = max(dp[nstate][!phase],dp[state][phase]+r[y][x]);
	  ans = max(ans,dp[nstate][!phase]);
	}
	rep(i,(1<<W))dp[i][phase] = 0;
	phase = !phase;
      }
    }

    cout << "Case " << CNT++ << ": " << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 17548
#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};
// cmd

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

    int2(n, m);
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cin >> b[i];
        cin >> c[i];
    }

    int ans = 0;
    for (int i = 0; i < 8; i++) {
        vi score(0);
        rep(j, n) {
            int tmp = 0;
            if (i & 1) {
                tmp += a[j];
            } else {
                tmp += -a[j];
            }
            if (i & 2) {
                tmp += b[j];
            } else {
                tmp += -b[j];
            }
            if (i & 4) {
                tmp += c[j];
            } else {
                tmp += -c[j];
            }
            score.pb(tmp);
        }
        sort(all(score)); reverse(all(score));
        int tmp = 0;
        rep(j, m) tmp += score[j];
        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0; i<N; i++){
        cin >> a.at(i);
    }

    int count=0, num=1;

    while(count < N){
        num = a.at(num-1);
        count ++;
        if (num == 2){
            break;
        }
    }
    
    if(num == 2){
        cout << count << endl;
    }
    else{
        cout << -1 << endl;
    }

}

Measured memory_bytes: 640