akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define rep(i,q) for(int i = 0; q > i; i++)
using namespace std; 
int x1,y1,x2,y2;
void input() { 
  cin >> x1 >> y1 >> x2 >> y2;
} 
void compute() { 

} 
void output() { 
  int x3 = y1 - y2 + x2;
  int y3 = x2 - x1 + y2;
  cout << x3 << " " << y3 << " " << x3 + (x1 - x2) << " " << y3 + (y1 - y2) << endl;
} 
int main() { 
    input(); 
    compute(); 
    output(); 
    return 0; 
} 

//x1,y1 - x2,y2


//2,3,6,6 
//2,3|6,6
// #####.
// ######
// ######
// #.####
// ######
// ######

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


int main()
{
    ll n;
cin>>n;
map<ll,ll>m;
ll x,y,z,a;
for(ll x=1;x<=100;x++)
            {
            for(ll y=1;y<=100;y++)
            {
                for(ll z=1;z<=100;z++)
                {
                    a=x*x+y*y+z*z+x*y+x*z+y*z;
                    m[a]++;
                }
            }
            }

for(ll i=1;i<=n;i++)
{

    cout<<m[i]<<endl;
}

return 0;
}


Measured memory_bytes: 5904
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){ 
  int n;
  cin >> n;
  string s;
  cin >> s;
  unordered_set<string> w;
  unordered_set<string> a;
  for (char cur: s){
    w = a;
    for (auto c: w){
      if (len(c) < 3){
        a.insert(c+cur);
      }
    }
    string t;
    t += cur;
    a.insert(t);
  }
  int ans = 0;
  for (auto c: a){
    if (len(c) == 3) ans++;
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 



9 8 7 10 5 6 3 4 2 1 * 9 8 7 10 5 6 3 4 2 1 * 9 8 7 10 5 6 3 4 2 1

 */

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
bool ans = true;
int cnt;
int main(){
  string s;
  cin >> s;
  int n = s.size();
  
  for(int i = 0;i<n;i++){
    if(s[i]!='A' && i==0){
      ans = false;
      break;
    }
    if((s[i]=='C' && i>=2 && i<n-1)){
        cnt++;
        if(cnt>1){
      ans = false;
      break;}
    }
    if(s[i]=='C' && i<2 && i>n-2){
        ans = false;
        break;
    }
    
    if(s[i]!='A' && s[i]!='C' && s[i]!=tolower(s[i])){
      ans=false;
      break;
    }
}
    
       
       if(ans && cnt)cout << "AC" << endl;
       else cout << "WA" << endl;
       
       return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


void trace(int A[],int N){
int i;
for(i=0;i<N;i++){
if(i>0) printf(" ");
  printf("%d",A[i]);
}
printf("\n");
}

void insertionSort(int A[] ,int N){
  int i,j,v;
for(i=1 ; i<=N-1 ; i++){
  v = A[i];
  j = i - 1;
  while(j >= 0 && A[j] > v){
    A[j+1] = A[j];
    j--;
}
    A[j+1] = v;
    trace(A,N);
 }
}

int main() {
int N,i,j;
int A[1000];

scanf("%d", &N);
for(i=0 ; i<N ; i++) scanf("%d", &A[i]);
trace(A,N);
insertionSort(A,N);
return 0;
}



Measured memory_bytes: 2072
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    array<int, 32> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    long long N;
    cin >> N;
    cout << vec[N - 1] << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    string b=a;
    reverse(b.begin(),b.end());
    for(int i=0;i<b.size();i++)
    {
        if(b[i]=='d')
            b[i]='b';
        else if(b[i]=='b')
            b[i]='d';
        if(b[i]=='p')
            b[i]='q';
        else if(b[i]=='q')
            b[i]='p';
    }
    if(a==b)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int n,a;
  cin>>n>>a;
  if(n%500>a)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}
  

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

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int dp[41][401][401] = {};
int main(){

  int n, M_a, M_b;
  scanf("%d %d %d", &n, &M_a, &M_b);

  vector<int> a(n), b(n), c(n);
  REP(i,n){
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
  }


  REP(i,41){
    REP(j,401){
      REP(k,401){
        dp[i][j][k] = INF;
      }
    }
  }
  dp[0][0][0] = 0;

  for(int i = 0; i < n; ++i){
    for(int j = 0; j <= 400; ++j){
      for(int k = 0; k <= 400; ++k){
        if(j - a[i] >= 0 && k - b[i] >= 0){
          dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a[i]][k-b[i]] + c[i]);
        }else{
          dp[i+1][j][k] = dp[i][j][k];
        }
      }
    }
  }

  int ans = INF;
  int max_M = max(M_a, M_b);
  for(int i = 1; i * max_M <= 400; ++i){
      ans = min(ans, dp[n][i*M_a][i*M_b]);
  }
  if(ans == INF){
    ans = -1;
  }
  printf("%d\n", ans);
  return 0;
}


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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<int,int> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}


string conv(char a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}


int main(){
	int H,  W; cin>> H >> W;
	int h, w; cin>> h >> w;
	cout<< W*H - (h*W + (H-h)*w);
	return 0;
}


//Problem A
/*
 int v[100010];
int x1[100010];
int x2[100010];

int main(){
	clr(x1,0);
	clr(x2,0);
	int n; cin>> n;
	rep(i,1,n)
		cin>> v[i];
	rep(i,1,n){
		if(v[i] == 2)
			x2[i] = x2[i-1] + 1;
	}
	per(i,n,1){
		if(v[i] == 1)
			x1[i] = x1[i+1] + 1;
	}
	int maxi = 0;
	rep(i,1,n-1){
		if(v[i] != v[i+1]){
			//~ cout<<i<<":"<<x2[i]<<" "<<i+1<<":"<<x1[i+1]<<endl;
			maxi = max(maxi, min(x2[i],x1[i+1]));
		}
	}
	//~ rep(i,1,n)
		//~ cout<<x2[i]<<" "; 
	//~ cout<< endl;
	//~ rep(i,1, n)
		//~ cout<<x1[i]<<" ";
	//~ cout<<endl;
	//~ cout<<endl;
	clr(x1,0);
	clr(x2,0);
	rep(i,1,n){
		if(v[i] == 1)
			x1[i] = x1[i-1] + 1;
	}
	per(i,n,1){
		if(v[i] == 2)
			x2[i] = x2[i+1] + 1;
	}
	
	rep(i,1,n-1){
		if(v[i] != v[i+1]){
			//~ cout<<i<<":"<<x2[i]<<" "<<i+1<<":"<<x1[i+1]<<endl;
			maxi = max(maxi, min(x1[i],x2[i+1]));
		}
	}
	
	//~ cout<< maxi<<endl;
	cout<<2*maxi<<endl;
	//~ rep(i,1,n)
		//~ cout<<x2[i]<<" "; 
	//~ cout<< endl;
	//~ rep(i,1, n)
		//~ cout<<x1[i]<<" ";
	//~ cout<<endl;
	return 0;
}

 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int a,b,c,d;cin >> a>> b>> c >>d;
 int e = a+b,f = c+d;
 if(e>f)cout << "Left" << endl;
 else if(e<f) cout << "Right" << endl;
 else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  for(int i=0;i<n;i++){
    string a;cin>>a;
    int aa=0;
    vector<int> aaa(8);
    for(int j=0;j<8;j++){
      aaa[j]=a[j]-'0';
    }
    sort(aaa.begin(),aaa.end());
    int m1=0;
    for(int j=0;j<8;j++){
      int ss=1;
      for(int k=j;k<7;k++)
	ss*=10;
      m1+=aaa[j]*ss;
    }
    sort(aaa.begin(),aaa.end(),greater<int>());
    int m2=0;
    for(int j=0;j<8;j++){
      int ss=1;
      for(int k=j;k<7;k++)
	ss*=10;
      m2+=aaa[j]*ss;
    }
    //cout<<m1<<" "<<m2<<endl;
    cout<<-m1+m2<<endl;
  }
  return 0;
}

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 1000000007;
// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main(){
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    vector<vll> bsum(n+1, vll(60));
    repr(i, n) rep(j, 60) {
        bsum[i][j] += bsum[i+1][j] + ((a[i]>>j)&1);
    }
    repr(i, n-1) rep(j, 60) {
        bsum[i+1][j] = llabs((ll)bsum[i+1][j]-((a[i]>>j)&1)*(n-1-i));
    }
    mint ans = 0;
    rep1(i, n-1) {
        mint two = 1;
        rep(j, 60) {
            ans += two * bsum[i][j];
            two *= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 157960
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt()*sc.nextInt(),b=sc.nextInt()*sc.nextInt();
		System.out.println((a<b)?b:a);
		sc.close();
	}
}

Measured memory_bytes: 23380
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int N = Integer.parseInt(sc.next());
        final int L = Integer.parseInt(sc.next());
        String[] ss = new String[N];
        for (int i = 0; i < N; i++) {
            ss[i] = sc.next();
        }
        
        Arrays.sort(ss);
        String ans = "";
        for (int i = 0; i < N; i++) {
            ans += ss[i];
        }
        
        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 25040
N,K=map(int,input().split())
A=list(map(int,input().split()))
MOD=10**9+7
count1=0
count2=0
for i in range(N):
    for j in range(N):
        if i==j:
            continue
        if A[i]>A[j]:
            if i<j:
                count1+=1
            else:
                count2+=1
ans=count1*K*(K+1)//2%MOD
ans=ans+count2*(K)*(K-1)//2
print(ans%MOD)

Measured memory_bytes: 3188
f2 e (z,z3) =
  let e' = e - z3
      y  = floor $ sqrt $ fromIntegral e'
      y2 = y^2
      x = e' - y2
  in
    (x+y+z)

f3 e =
  let y = takeWhile (\(_,z3) -> z3 <= e) $ map (\z -> (z,z^3)) $ [0..]
  in
    minimum $ map (f2 e) y

main = do
  c <- getContents
  let i = takeWhile (/= 0) $ map read $ lines c :: [Int]
      o = map f3 i
  mapM_ print o



Measured memory_bytes: 4956
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
using namespace std;
#define MAX 14
#define SMAX (1<<14)
#define QMAX 17000

class State{
    public:
    int used, n, size, cost, remain;
    State( int n=0, int size=0):n(n), size(size){
	used = cost = 0;
	remain = n;
    }
};

int n, m;
pair<int, int> F[MAX];

void rec(State &u, State &v, int pos, int fsize, queue<State> &Q, bool visited[SMAX]){
    if ( pos == n ){
	v.size += fsize;
	if ( !visited[v.used] ){
	    visited[v.used] = true;
	    v.cost = u.cost + 1;
	    Q.push(v);
	}
	return;
    }

    if ( !(v.used & (1<<pos)) && v.size >= F[pos].second) {
	State vv = v;
	vv.used |= (1<<pos);
	vv.remain--;
	vv.size -= F[pos].second;
	rec(u, vv, pos+1, fsize + F[pos].first, Q, visited );
    }

    rec(u, v, pos+1, fsize, Q, visited);
}

int bfs(){
    State s = State(n, m);
    queue<State> Q;
    bool visited[SMAX];
    Q.push(s);

    for ( int i = 0; i < (1<<n); i++ ) visited[i] = false;
    visited[s.used] = true;

    State u, v;
        while( !Q.empty() ){
	u = Q.front(); Q.pop();
	if ( u.remain == 0 ) return u.cost;
	rec(u, u, 0, 0, Q, visited);
	
    }

    return -1;
}

void compute(){
    int cost = bfs();
    if ( cost < 0 ) cout << "Impossible" << endl;
    else cout << cost << endl;
}

main(){
    while( cin >> n >> m && n ){
	for ( int i = 0; i < n; i++ ) cin >> F[i].first >> F[i].second;
	compute();
    }
}

Measured memory_bytes: 1224
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c1 = str.toCharArray();
        str = sc.next();
        char[] c2 = str.toCharArray();
        int n = c1.length;
        
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (c1[i] != c2[i]) count++;
        }
        System.out.println(count);
        
    }
}

Measured memory_bytes: 42084
#include <bits/stdc++.h>
#define r(i, n) for (int i=0;i<n;i++)
using namespace std;
int main() {
  int n;
  cin >> n;
  string a="Three";
  char s[n];
  r(i, n) { 
    cin >> s[i];
    if (s[i]=='Y') {
      a="Four";
      break;
    }
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m = map(int, readline().split())
p = list(map(int, readline().split()))
xy = [list(map(int, readline().split())) for _ in range(m)]
uf = UnionFind(n + 1)
cnt = 0
for x, y in xy:
    uf.union(x, y)
for i, check in enumerate(p):
    if uf.same(i + 1, check):
        cnt += 1
print(cnt)


Measured memory_bytes: 32340
N, Q = map(int, input().split())

tree = {}
for i in range(1, N + 1):
    tree[i] = []
for i in range(N - 1):
    a, b = map(int, input().split())
    tree[a] += [b]

count = [0] * (N + 1)
for i in range(Q):
    p, x = map(int, input().split())
    count[p] += x

stack = [1]
while stack:
    label = stack.pop()
    if tree[label] != []:
        for next_label in tree[label]:
            count[next_label] += count[label]
        stack += tree[label]

ans = count[1:]
print(*ans)


Measured memory_bytes: 100960
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#define ll long long
using namespace std;

int main(){
    long long x;
    long long p=100;
    cin>>x;
    long long count=0;
    while (p<x){
        p*=1.01;
        count+=1;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3636
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

bool isPrime(int64_t x) {
	if (x < 2) return false;
	else if (x == 2) return true;
	if (x % 2 == 0) return false;
	for (int64_t i = 3; i*i <= x; i += 2) {
		if (x % i  == 0) return false;
	}
	return true;
}

void solve()
{
    int64_t X;
	std::cin >> X;
	while(true) {
		if(isPrime(X)) {
			std::cout << X << std::endl;
			break;
		}
		X++;
	}
	return;
}

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


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

#define scl(x) scanf("%lld",&x)
#define sc(x)  scanf("%d",&x)
#define ll long long
#define lop(i,n) for(int i=0;i<n;++i)
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

const int mod=998244353,mN=3e5+100;

inline int add(int a,int b){
   a+=b;
   if(a<0)a+=mod;
   if(a>=mod)a-=mod;
   return a;
}
inline int mul(int a,int b){
   ll ret=1LL*a*b;
   if(ret>=mod)ret%=mod;
   return ret;
}
inline int pwm(int a,ll p){
   int m=a,ret=1;
   while(p){
      if(p&1)ret=mul(ret,m);
      m=mul(m,m);
      p>>=1;
   }
   return ret;
}
int fact[mN];
inline int nCr(int n,int r){
	if(r>n||r<0)return 0;
	return mul( mul( fact[n] , pwm(fact[n-r],mod-2) ) , pwm(fact[r], mod-2 )) ;
}

int n,a,b;
ll k;

int main() {
#ifndef ONLINE_JUDGE
   // freopen("i.txt", "r", stdin);
#endif
    fact[0]=1;
    for(int i=1;i<mN;i++)
    	fact[i]=mul(i,fact[i-1]);
    cin>>n>>a>>b>>k;
    int out = 0;
    for(int r=0;r<=n && 1LL*r*a<=k ;r++){
    	ll rem = k-1LL*r*a;
    	if(rem%b)continue;
    	ll B=rem/b;
    	if(B>n)continue;
    	out =add(out, mul(nCr(n,r),nCr(n,B)) );
    }
    cout<<out<<endl;
}


Measured memory_bytes: 1408
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{

     public static void main(String []args) throws Exception {
        Scanner sc = new Scanner(System.in);
        //BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
        int x = sc.nextInt();
        
        //String s = inp.readLine().trim();
        int ans = 0;
        int a = x ;
        int d = a/500;
            
            if(d > 0){
                ans = ans + d*1000;
                a = a - d*500;
            }
            int s = a/5;
            if(a > 0){
                ans = ans + s*5;
                a = a - s*5;
            }
        
        System.out.println(ans);
        
        
     }
}

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

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

    int ans=0,kazu=1;

    while (kazu<b) {
        kazu+=a-1;
        ans++;

    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define println(x) cout << x << endl
#define fi first
#define se second
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")
using pii = pair<int, int>;

int main()
{
    string s, t;
    cin >> s >> t;
    bool restorable = false;
    int cnt = s.size() - t.size();
    while (cnt >= 0)
    {
        string st = s;
        for (int i = t.size() - 1; i >= 0; i--)
        {
            if (t[i] == st[i+cnt])
            {
                if (i == 0)
                {
                    restorable = true;
                }
            }
            else if (st[i+cnt] == '?')
            {
                st[i+cnt] = t[i];
                if (i == 0)
                {
                    restorable = true;
                }
            }
            else break;
        }
        if (restorable)
        {
            s = st;
            break;
        }
        cnt--;
    }
    if (restorable) 
    {
        rep(i, s.size())
        {
            if (s[i] == '?') s[i] = 'a';
        }
        println(s);
    }
    else println("UNRESTORABLE");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)

int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};
int dxx[]={1,1,0,-1,-1,-1,0,1};
int dyy[]={0,-1,-1,-1,0,1,1,1};
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair<int,int> pii;
int n,i;
string str[105];
bool dev(string a){
  iFOR(j,1,i){
    if(a==str[j]) 
      return true;
    
  }
  return false;
}

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int dabl=0;
  cin >>n;
  for(i=1;i<=n;i++){
    cin >>str[i];
    int edn=str[i-1].length();
    if(dev(str[i])) dabl=1;
    if(i>1&&str[i-1][edn-1]!=str[i][0]) dabl=1;
  }
  if(dabl) cout <<"No\n";
  else cout <<"Yes\n";
                     
  
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	//static boolean isprime[n];
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		int cnt=0;
		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++){
			int tmp=scanner.nextInt();
			if(isprime(tmp)){
				cnt++;
			}
		}
		System.out.println(cnt);
	}

	private static boolean isprime(int x) {
		// TODO Auto-generated method stub
		if(x==2) return true;
		if(x<2||(x%2==0)) return false;
		for(int i=3;i<=Math.sqrt(x);i=i+2){
			if(x%i==0)
				return false;
		}
		return true;
	}

}



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


int main(){
    int n,m;
    cin >> n >> m;
    vector<int> v(n,-1);
    rep(i,m){
        int s,c;
        cin >> s >> c;
        if(v[n-s] != -1 && v[n-s] != c){
            cout << -1 << endl;
            return 0;
        }
        v[n-s] = c;
    }
    if(v[n-1]==0) {
        if(n==1){
            cout << 0 << endl;
            return 0;
        }
        cout << -1 << endl;
        return 0;
    }
    if(v[n-1]==-1){
        if(n==1) v[0] = 0;
        else v[n-1] = 1;
    }
    rep(i,n){
        if(v[i]==-1){
            v[i]=0;
        }
    }
    for(int i=n-1; i>=0; i--){
        cout << v[i];
    }
    cout << endl;
    return 0;
}

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

#define rep(i,n) for (int i = 0; i < int(n); i++)
#define loop(i,a,b) for (int i = a; int(a)<=int(b) ? i<=int(b) : i>=int(b); int(a)<=int(b) ? i++ : i--)

int N, A[100010];

int main() {
    cin >> N;
    loop (i,1,N) cin >> A[i];

    int sum = 0;
    loop (i,1,N+1) sum += abs(A[i]-A[i-1]);

    loop (i,1,N) cout << sum-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]) << endl;
}


Measured memory_bytes: 1664
#include <vector>
#include <iostream>
#include <algorithm>
#define INF (1LL << 60)
using namespace std;
int n, u[3], mode, tar; long long d, x[30], y[30], ret, seg[33554432], val[14348907]; pair<long long, long long> t[2][14348907];
inline void rec(int pos, long long a, long long b) {
	if (pos == tar) {
		if (b <= 0) t[mode][u[mode]++] = make_pair(a, b);
		return;
	}
	rec(pos + 1, a + x[pos], b + y[pos]);
	rec(pos + 1, a - x[pos], b - y[pos]);
	rec(pos + 1, a, b);
}
inline long long query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return INF;
	if (a <= l && r <= b) return seg[k];
	long long lch = query(a, b, k << 1, l, (l + r) >> 1);
	long long rch = query(a, b, (k << 1) + 1, (l + r) >> 1, r);
	return min(lch, rch);
}
int main() {
	scanf("%d%lld", &n, &d);
	for (int i = 0; i < n; i++) scanf("%lld%lld", &x[i], &y[i]);
	mode = 0; tar = n / 2; rec(0, 0, 0);
	mode = 1; tar = n; rec(n / 2, 0, 0);
	sort(t[1], t[1] + u[1]);
	for (u[2] = 1; u[2] <= u[1]; u[2] <<= 1);
	for (int i = 0; i < u[1]; i++) val[i] = t[1][i].first;
	for (int i = 0; i < u[1]; i++) seg[i + u[2]] = t[1][i].second;
	for (int i = u[1]; i < u[2]; i++) seg[i + u[2]] = INF;
	for (int i = u[2]; i >= 1; i--) seg[i] = min(seg[2 * i], seg[2 * i + 1]);
	for (int i = 0; i < u[0]; i++) {
		int pl = lower_bound(val, val + u[1], -t[0][i].first - d) - val;
		int pr = upper_bound(val, val + u[1], -t[0][i].first + d) - val;
		long long res = query(pl, pr, 1, 0, u[2]);
		ret = max(ret, -t[0][i].second - res);
	}
	printf("%lld\n", ret);
	return 0;
}

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

int main(void) {
  char s[3];
  
  cin >> s;
  
  for (int i = 0; i < 2; i++) {
    if (s[i] != s[i+1] ) {
      printf("Yes\n");
      return 0;
    }
  }
  
  printf("No\n");
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    map<ll, ll> a;
    rep(i, 0, n){
        ll tmp;
        cin >> tmp;
        a[tmp]++;
    }

    fore(i, a){
        if(i.second > 1){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

// 区間add, 区間min
struct LazySegTree{
    int n; vector<ll> dat,lazy;
    //初期化
    LazySegTree(int _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<ll>(2*n-1,0);
        lazy=vector<ll>(2*n-1,0);
    }

    void setLazy(int k, ll v){
        lazy[k] += v;
        dat[k] += v;
    }

    void push(int k, int l, int r){
        if(lazy[k]!=0){
            setLazy(2*k+1,lazy[k]);
            setLazy(2*k+2,lazy[k]);
        }
        lazy[k]=0;
    }

    void fix(int k, int l, int r){
        dat[k]=min(dat[2*k+1],dat[2*k+2]);
    }

    ll merge(ll x, ll y){
        return min(x,y);
    }

    //内部的に投げられるクエリ
    void _add(int a, int b, ll x, int k, int l, int r){
        if(r<=a || b<=l) return;
        if(a<=l && r<=b){
            setLazy(k,x);
            return;
        }

        push(k,l,r);
        _add(a,b,x,2*k+1,l,(l+r)/2);
        _add(a,b,x,2*k+2,(l+r)/2,r);

        fix(k,l,r);
    }
    //[a,b)に+x
    void add(int a, int b, ll x){
        return _add(a,b,x,0,0,n);
    }

    //内部的に投げられるクエリ
    ll _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return LLONG_MAX/2;
        if(a<=l && r<=b) return dat[k];

        push(k,l,r);
        ll vl=_query(a,b,2*k+1,l,(l+r)/2);
        ll vr=_query(a,b,2*k+2,(l+r)/2,r);
        return merge(vl,vr);
    }
    //[a,b)の最小値
    ll query(int a, int b){
        return _query(a,b,0,0,n);
    }
};

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

    int n,Q;
    string s;
    cin >>n >>Q >>s;

    LazySegTree st(n);

    vector<int> a(n);
    set<int> r;
    rep(i,n){
        if(s[i] == '(') a[i] = 1;
        else{
            a[i] = -1;
            r.insert(i);
        }
        st.add(i,n+1,a[i]);
    }

    rep(i,Q){
        int q;
        cin >>q;
        --q;

        int ans = -1;
        if(a[q] == 1){
            st.add(q,n+1,-2);

            r.insert(q);
            ans = *r.begin();
            r.erase(ans);

            st.add(ans,n+1,2);
        }
        else{
            st.add(q,n+1,2);

            int ok=n-1, ng=0;
            while(ok-ng>1){
                int mid = (ok+ng)/2;
                if(st.query(mid,n+1)>=2) ok = mid;
                else ng = mid;
            }
            ans = ok;

            r.erase(q);
            r.insert(ans);
            st.add(ans,n+1,-2);
        }

        a[q] *= -1;
        a[ans] *= -1;
        printf("%d\n", ans+1);
    }

    return 0;
}



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

int main(){
	int h,w;
	cin >> h >> w;
	char c[105][105];
	rep(i,h) rep(j,w) cin >> c[i][j];
	char ans[210][210];
	rep(i,2*h){
		rep(j, w){
			ans[i][j] = c[i/2][j];
		}
	}
	rep(i,2*h){
		rep(j,w){
			cout << ans[i][j];
		}
		cout << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N,K,a,b;
	cin>>N>>K;
	int dp[110][4]={};
	for(int i=0;i<K;i++){
		cin>>a>>b;
		dp[a][b]=1;
	}
	if(dp[1][1]==0 && dp[1][2]==0 && dp[1][3]==0){
		for(int i=1;i<=3;i++){
			dp[1][i]=1;
		}
	}

	for(int i=1;i<=N;i++){
		if(dp[i+1][1]==0 && dp[i+1][2]==0 && dp[i+1][3]==0){
			for(int j=1;j<=3;j++){
				if(dp[i+2][j]>0 && dp[i+3][j]>0){
					dp[i+1][j]=0;


				}

				else	if(dp[i][j]>0 && dp[i+2][j]>0){
					if(j==1){
						dp[i+1][j]=(dp[i][2]+dp[i][3])%10000;
					}
					else if(j==2){
						dp[i+1][j]=(dp[i][1]+dp[i][3])%10000;
					}
					else{
						dp[i+1][j]=(dp[i][1]+dp[i][2])%10000;
					}


				}
				else if(dp[i+2][j]>0 && dp[i+3][j]>0){
					dp[i+1][j]=0;


				}
				else if(dp[i-1][j]>0  && dp[i][j]>0){
					if(j==1){

						dp[i+1][j]=((+dp[i][2]+dp[i][3])%10000+(+dp[i-1][2]+dp[i-1][3])%10000)%10000;
					}
					else if(j==2){
						dp[i+1][j]=((+dp[i][1]+dp[i][3])%10000+(+dp[i-1][1]+dp[i-1][3])%10000)%10000;
					}
					else{
						dp[i+1][j]=((+dp[i][2]+dp[i][1])%10000+(+dp[i-1][2]+dp[i-1][1])%10000)%10000;
					}


				}

				else{
					dp[i+1][j]=((dp[i][1]+dp[i][2])%10000+dp[i][3])%10000;
				}
			}
		}
		else{
			for(int j=1;j<=3;j++){
				if(dp[i+1][j]==1){
					dp[i+1][j]=((dp[i][1]+dp[i][2])%10000+dp[i][3])%10000;
				}
			}
		}
	}
		
	cout<<(dp[N][1]+dp[N][2]+dp[N][3])%10000<<endl;
	return 0;
	

	}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a <= c && c <= b)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N;
ll L[4000];

void input() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> L[i];
}

void solve() {
    input();
    vector<ll> v(N);
    for(int i = 0; i < N; i++) v[i] = L[i+1];
    sort(v.begin(), v.end());
    ll ans = 0;
    for(ll mid = N - 1; mid >= 0; mid--) {
        for(ll low = mid - 1; low >= 0; low--) {
            auto itr = lower_bound(v.begin(), v.end(), v[mid] + v[low]);
            ll ng = distance(itr, v.end());
            ans += (N - 1 - mid) - ng;
            //cerr << v[mid] + v[low] << " " << ng << " " << (N-1-mid)-ng << endl;
        }
    }
    cout << ans << endl;
    return;
}

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

Measured memory_bytes: 256
import queue
N, M = map(int, input().split())
adj = [[]for i in range(N+1)]
parent = [-1] * (N+1)  # -1なら未訪問
for m in range(M):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)
q = queue.Queue()  # 自分の部屋番号、親の部屋番号
q.put((1, 0))  # 部屋1の親は部屋0と考える
while(not q.empty()):
    x, p = q.get()
    if parent[x] != -1:  # 訪問済み
        continue
    parent[x] = p
    for next in adj[x]:
        if parent[next] == -1:  # 未訪問なら
            q.put((next, x))  # 探索候補に追加
print('Yes')  # 必ず目標は達成できる
for p in parent[2:]:  # 部屋2以降の親（前の部屋）
    print(p)


Measured memory_bytes: 40080
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int i = scan.nextInt();
        int answer = N - i + 1;
        System.out.println(answer);
    }
}


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

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    auto p = min_element(a,a+n);
    int t = p-a;
    int ans;
    ans = t/(k-1) + (n-t-1)/(k-1);
    if((t%(k-1)+(n-t-1)%(k-1)) == 0) ;
    else if((t%(k-1)+(n-t-1)%(k-1)) < k) ans++;
    else ans += 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n,k,sum=0,ans=1,a[600],b[600];
bool check(int s){
	int tmp=0;
	for(int i=1;i<=n;i++) b[i]=a[i]%s;
	sort(b+1,b+n+1);
	int l=1;
	for(int i=n;i>=l;i--){
		while(s-b[i]>b[l]&&l<=i) b[i]+=b[l],tmp+=b[l],b[l]=0,l++;
		b[l]-=s-b[i],tmp+=s-b[i];
		if(!b[l]) l++;
	}
	return tmp<=k;
}
int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum+=a[i];
	for(int i=1;i*i<=sum;i++){
		if(!(sum%i)){
			if(check(i)) ans=max(ans,i);
			if(check(sum/i)) ans=max(ans,sum/i);
		}
	}
	printf("%d\n",ans);
} 

Measured memory_bytes: 256
red, green, blue = map(int, input().split())
k = int(input())

for i in range(k):
  if red < green and green < blue:
    break
  else:
    if red >= green:
      green *= 2
    elif green >= blue:
      blue *= 2
      
if red < green and green < blue:
  print("Yes")
else:
  print("No")

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265

#define MAX 100001
ll arr[MAX];
ll psum[MAX];


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

    ll n , m;
    cin >> n >> m;
    map<int , int> mp;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        psum[i + 1] = psum[i] + arr[i];
    }
    ll ans = 0;
    mp[0] = 1;
    mp[m] = 1;
    for (int i = 1; i <= n; i++) {
        int r = (psum[i] % m);

        if (mp.find(r) != mp.end()) ans += mp[r];
        mp[psum[i] % m]++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define ff first
#define ss second
#define pb push_back
#define vi vector<ll>
#define all(_x) _x.begin(), _x.end()
#define rep(i, s, e) for (ll i = s; i < e; i++)
#define lb(_x, _a) (lower_bound(all(_x), _a) - _x.begin())
#define ub(_x, _a) (upper_bound(all(_x), _a) - _x.begin())
ll n, tc;

int main()
{
  	// ll is int now
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    cin>>n>>k;
    vi arr(n); for(auto &x : arr) cin>>x;
    vi dp(n, 0);
   
    for(int i=1; i<n; i++)
    {
        int tem = INT_MAX;

        for(int j = i-1; j>=i-k and j>=0; j--){
            tem = min(tem, dp[j]+abs(arr[i]-arr[j]));
        }
        dp[i] = tem;
    }

    cout<<dp[n-1]<<'\n';
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int ans = 0, ab = 0, a = 0, b = 0;
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        for(int j = 0; j < s.length()-1; j++){
            if(s[j] == 'A' && s[j+1] == 'B') ans++;
        }
        if(s[0] == 'B' && s[s.length()-1] == 'A') ab++;
        else if(s[0] == 'B') b++;
        else if(s[s.length()-1] == 'A') a++;
    }
    if(ab == 0) ans += min(a, b);
    else{
        if(a+b > 0) ans += ab + min(a, b);
        else ans += ab-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;
    while(cin>>n&&n){
        int b=0;
        rep(i,0,9){
            int t;cin>>t;b+=t;
        }
        cout<<n-b<<endl;
    }
}


/*
abcdea

/root
a.txt
bunp.html
/desktop
r.txt
fsharp.cs
dp.cpp
/users
bison.txt

root r.txt
users r.txt
users a.txt

desktop/r.txt
../r.txt
../../a.txt
*/



Measured memory_bytes: 2952
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		for (int i = 0; i < 10; i++) {
			x = r * x - d;
			System.out.println(x);
		}
	}
}


Measured memory_bytes: 21844
N=int(input())
A=list(map(int,input().split()))

A_sum=0
a_start=0
for a in A:
    A_sum += abs(a_start-a)
    a_start=a
a=0
A_sum += abs(a_start-a)

A_=[0]
A_.extend(A)
A_.append(0)
for a_idx in range(1,len(A_)-1):
    a_before = A_[a_idx-1]
    a_ = A_[a_idx]
    a_after = A_[a_idx+1]
    print(A_sum-(abs(a_-a_before)+abs(a_-a_after)-abs(a_before-a_after)))

Measured memory_bytes: 85768
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
  string S[3];
  cin >> S[0] >> S[1] >> S[2];
  int turn = 0;
  int score[3] = {};
  char ans;
  while(1){
    if(score[turn] == S[turn].length()){
      ans = (char)(65+turn);
      break;
    }
    score[turn]++;
    turn = (int)S[turn][score[turn]-1] - 97;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
long long f(long long a){return a*a*a;}
int main(){
  long long a,b;
  scanf("%lld %lld",&a,&b);
  if(b%2==0)printf("%lld\n",f((a+b/2)/b)+f(a/b));
  else printf("%lld\n",f(a/b));
  return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i;
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int q = sc.nextInt();
			List<Queue<Integer>> array = new ArrayList<>();
			for(i = 0; i < n; i++) {
				array.add(new PriorityQueue<Integer>(1 ,Comparator.reverseOrder()));
			}
			for(i = 0; i < q; i++) {
				int order_number = sc.nextInt();
				int t = sc.nextInt();
				//命令1と2は配列が空なら処理しない
				if(array.get(t).isEmpty() && order_number != 0) {
					continue;
				}
				switch(order_number) {
				case 0 :
					array.get(t).add(sc.nextInt());
					break;
				case 1 :
					System.out.println(array.get(t).peek());
					break;
				case 2 :
					array.get(t).remove();
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 169000
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<ll,ll> Pi;
typedef pair<Pi,int> Pii;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n,m;
	ll p,y;
	Pii py[100001];
	cin>>n>>m;

	rep(i,m){
		cin>>p>>y;
		py[i].first.first=p;
		py[i].first.second=y;
		py[i].second=i;
	}
	sort(py,py+m);
	ll r[100001];
	ll o=0;
	ll mae=0;
	rep(i,m){
		o++;
		if(py[i].first.first!=mae){
			mae=py[i].first.first;
			o=1;
		}
		r[py[i].second]=mae*1000000+o;
	}
	rep(i,m){
		printf("%012lld\n",r[i]);
	}
	return 0;
}


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

  int N; cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);}
  
  int j=0, sum=0;
  while(sum<N){
    j = vec.at(j)-1;
    if(j == 1){break;}
    sum++;
  }
  if(sum < N){cout << sum+1 << endl;}
  else{cout << "-1" << endl;}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
const ll mod = (ll)1e9 + 7;
	
int main(){
	speed;
	map<char, int> m1;
	map<char, int> m2;
	string s1, s2; cin >> s1 >> s2;
	forn(s1.size()) {
		m1[s1[i]]++;
	}
	int res = 0;
	forn(s2.size()) {
		if(s2[i] != s1[i]) res++;
		m2[s2[i]]++;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3812