akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef  long long ll;


int main(){
  int D, G,ans=100000;
  vector<int> p(10), c(10);

  cin >> D >> G;
  for(int i =0; i < D; i++){
    cin >> p[i] >> c[i];
  }

  for(int b = 0; b < (1 << D); b++){
    int sum=0, cnt=0, max_index = -1;
    for(int i = 0; i < D; i++){
      if(b>>i & 1){
        sum += 100*(i+1)*p[i]+c[i];
        cnt += p[i];
      }
      else{
        max_index=i;
      }
    }
    if(sum < G){
      int s1 = 100*(max_index+1);
      int need = (G - sum + s1 - 1) / s1;
      if(need >= p[max_index])
        continue;
      cnt+=need;
    }

    ans = min(ans, cnt);
  }

  cout << ans << endl;

  
  return 0;
}




Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    w, h, n = list(map(int, input().split()))
    xya = [list(map(int, input().split())) for _ in range(n)]
    w_min = 0
    w_max = w
    h_min = 0
    h_max = h

    for x, y, a in xya:
        if (a == 1) and (x > w_min):
            w_min = x
        elif (a == 2) and (x < w_max):
            w_max = x
        elif (a == 3) and (y > h_min):
            h_min = y
        elif (a == 4) and (y < h_max):
            h_max = y

    print(max(w_max - w_min, 0) * max(h_max - h_min, 0))


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

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}


int n;
ll x[500];
ll cnt[500];
ll dp[401][401];

ll solve(int i,int j){
        if(i==j){
            return 0;
        }
        if(i==j-1){
            return x[i]+x[j];
        }

        ll &res=dp[i][j];
        if(res!=-1){
            return res;
        }

        res=INFINF;
        for(int k=i;k<j;k++){
            res=min(res, solve(i,k)+solve(k+1,j) +cnt[j]-cnt[i-1] );
        }

        return res;

}




int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);




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

    cnt[0]=0;
    for(int i=1;i<=n;i++){
        cnt[i]=cnt[i-1]+x[i];
    }

    mem(dp,-1);
    cout<<solve(1,n);






     return 0;

}


Measured memory_bytes: 1536
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    res = 0
    for i in range(1, N+1):
        res += N // i
        if N % i == 0:
            res -= 1
    print(res)
    
if __name__ == "__main__":
    main()

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

const int seki[4][4] = {{1, 1, 1, 1},
                        {1, -1, 1, -1},
                        {1, -1, -1, 1},
                        {1, 1, -1, -1}};

int main(void){
  int n;
  while(cin >> n, n){
    while(n--){
    int a[4], b[4];
    int ans[4];
    for(int i=0;  i< 4; i++){
      ans[i] = 0;
    }
    for(int i=0; i < 4; i++){
      cin >> a[i];
    }
    for(int i=0; i < 4; i++){
      cin >> b[i];
    }
    ans[0] = a[0]*b[0] -a[1]*b[1] -a[2]*b[2]-a[3]*b[3];
    ans[1] = a[0]*b[1]+a[1]*b[0]+a[2]*b[3]-a[3]*b[2];
    ans[2] = a[0]*b[2]-a[1]*b[3]+a[2]*b[0]+a[3]*b[1];
    ans[3] = a[0]*b[3]+a[1]*b[2]-a[2]*b[1]+a[3]*b[0];
    cout << ans[0] << " " << ans[1] << " " << ans[2] << " " << ans[3] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #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>
     
    #define ff first
    #define ss second
    #define sz size()
    #define mp make_pair
     
    #define pb push_back
    #define endl "\n"
     
    #define int long long int
    #define double long double
     
    #define bp __builtin_popcountll
    #define inf 1e17
    const int N=2e5+6;
    const int M=998244353;
    vector<int> v;
    signed main()
    {
        FAST
        int a,b,k;
        cin>>a>>b>>k;
        int tt=min(a,k);
        a-=tt;
        k-=tt;
        int pp=min(b,k);
        b-=pp;
        cout<<a<<" "<<b;
        
    }


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n,m=map(int, input().split())
a=list(map(int, input().split()))
a.sort()
v=sum(a)
cnt=0
#print(a,v)
for i in range(n):
    if a[i]>=v/(4*m):
        cnt+=1
if cnt>=m:
    print("Yes")
else:
    print("No")

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

using namespace std; 

int main(){
	
	int d; 
	
	cin >> d; 
	
	string ans = d==25?"Christmas":d==24?"Christmas Eve":d==23?"Christmas Eve Eve":"Christmas Eve Eve Eve"; 
	
	cout << ans << endl;
	
    return 0;
}


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

int main(){
	int N;
	cin >> N;
	int a[2][N];
	int ans = 0;
	for(int i = 0; i < N; i++)
		cin >> a[0][i];
	for(int i = 0; i < N; i++)
		cin >> a[1][i];
	for(int i = 1; i < N; i++){
		a[0][i] += a[0][i-1];
		a[1][N-i-1] += a[1][N-i];
	}
	for(int i = 0; i < N; i++){
		int tmp = a[0][i] + a[1][i];
		ans = max(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    const int MAX = 20000;
    vint ans(MAX, 0);
    rep2(i, 100) rep2(j, 100) rep2(k, 100) {
        ll tmp = i*i+j*j+k*k+i*j+j*k+k*i;
        if (tmp < MAX) ans[tmp]++;
    }
    rep(i, n) cout << ans[i+1] << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int n;
  cin>>n;
  int out=0;
  int ans=0;
  std::vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=1;i<n;i++)if(v[i]!=v[i-1]+1)ans+=v[i-1];
  if(v[0]!=0)out++;
  for(int i=1;i<n;i++)if(v[i]>v[i-1]+1)out++;
  ans+=v[n-1];
  if(out)cout<<-1<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 1792
import re
if re.compile(r'(\A.*keyence\Z|\Ak.*eyence\Z|\Ake.*yence\Z|\Akey.*ence\Z|\Akeye.*nce\Z|\Akeyen.*ce\Z|\Akeyenc.*e\Z|\Akeyence.*\Z)').search(input()):
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3188
from fractions import gcd
import math
 
def get_prime_numbers(n):
  prime_nums = {}
  for i in range(2, int(math.sqrt(n)) + 1):
    while n % i == 0:
      if i in prime_nums.keys():
        prime_nums[i] += 1
      else:
        prime_nums[i] = 1
      n //= i
  if n != 1:
    if n in prime_nums.keys():
      prime_nums[n] += 1
    else:
      prime_nums[n] = 1
  return prime_nums
 
a, b = map(int, input().split())
gcd_n = gcd(a, b)
prime_nums = get_prime_numbers(gcd_n)
print(len(prime_nums.keys())+1)

Measured memory_bytes: 5344
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

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

  stack<char> s;
  char c;

  while (~scanf("%c", &c)){
    s.push(c);
    if (s.size() < 2) continue;

    char c1 = s.top();
    s.pop();
    char c2 = s.top();

    if (c2 == 'S' && c1 == 'T'){
      s.pop();
    }
    else {
      s.push(c1);
    }
  }

  cout << s.size() - 1 << endl;
}



Measured memory_bytes: 512
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a, b, c = map(int, input().split())
if a==b:
    print(c)
elif b==c:
    print(a)
else:
    print(b)

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

void DFS(const Graph &G,int v,vector<bool> &seen,vector<int> &first_order,vector<int> &last_order,int &ptr){//深さ優先探索。
//引数は順にグラフ、始点(注目点)、探索済みかどうか、行きがけでの順番配列、帰りがけでの順番配列、順番カウンタ
//タイムスタンプ型のため、firstとlastでカウンタを共有
  first_order[v]=ptr++;//行きがけのカウント

  seen[v]=true;

  for(auto next_v : G[v]){
    if(seen[next_v]) continue;
    DFS(G,next_v,seen,first_order,last_order,ptr);
  }
  
  last_order[v]=ptr++;//帰りがけのカウント

  return ;

}

 
int main() {

  int n;  cin >> n ;

  Graph G(n+1);//頂点はn個。今回は数値にそのまま対応させるために+1した

  rep(i,n){
    int u,k;
    cin >> u >> k;
    if(k==0) continue;

    rep(j,k){
    int v;
    cin >> v;
    G[u].push_back(v);
    }
  }//入力終了

  vector<bool> seen(n+1,false);
  vector<int> first_order(n+1),last_order(n+1);
  int ptr=1;//今回はカウント1スタート
  for(int i=1;i<=n;i++){
  if(seen[i]) continue;
  DFS(G,i,seen,first_order,last_order,ptr);
  }

  for(int i=1;i<=n;i++){
    cout << i <<' '<< first_order[i] << ' ' << last_order[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3172
#include<iostream>
#include<vector>
using namespace std;
int main(void){
int a,b,c;
while(1){
int ans=0;
cin>>a>>b>>c;
if(a==0)break;
for(int i=1;i<c/2+1;i++){
	int d=1,sum;
	while(1){
		d++;
		 sum=i*(100+a)/100+d*(100+a)/100;
		if(sum>=c)break;
	}
if(sum==c)ans=max(ans,i*(100+b)/100+d*(100+b)/100);
}
cout<<ans<<endl;
}
	return 0;
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define puts(i) cout<<i
int main(){
	int h,w;
	cin>>h>>w;
	char ans[h+2][w+2];
	rep(i,h+2)rep(j,w+2){if(i==0||i==h+1||j==0||j==w+1)ans[i][j]='#';else cin>>ans[i][j];}
	rep(i,h+2){rep(j,w+2){cout<<ans[i][j];}cout<<endl;}
}


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

int main() {
    int N,L;
    string S[100];
    cin >> N >> L;
    for (int i = 0; i < N; ++i) cin >> S[i];

    sort(S, S + N);
    for (int i = 0; i < N; ++i) cout << S[i]; 
    cout  << endl;
}

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

int main() {
    string s;
    cin >> s;
    int price = 700;
    for(int i = 0; i < 3; i++){
        if(s.at(i) == 'o'){
            price = price+100;
        }
    }
    cout << price;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    string s; cin >> s;
    int count = 1;
    string prest = "";
    prest = s[0];
    for(int i = 1; i < s.size();){
        if(i==s.size()-1 && s[i]==prest[0]) i++;
        else{
            if(prest.size()==1){
                if(s[i]==prest[0]){
                    prest = s[i] + s[i+1];
                    i += 2;
                }else{
                    prest = s[i];
                    i += 1;
                }
            }else{
                prest = s[i];
                i++;
            }
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String input = br.readLine();
		
		int len = input.length();
		
		int xarray[];
		
		String[] splitAlpha = input.split("[a-z&&[^x]]", -1);
//		for(int i = 0; i < splitAlpha.length ; i++){
//			System.out.println(splitAlpha[i]);
//		}
		
		xarray = new int[len + 1];
		
		StringBuffer sb = new StringBuffer();
		int numOfX = 0;
		for(int i = 0; i < len ; i++){
			char c = input.charAt(i);
			
			if(c != 'x'){
				sb.append(c);
			}
			else {
				numOfX++;
			}
		}
		
		String eraseX = sb.toString();
		
		//そもそもx抜きで回文か
		int len2 = eraseX.length();
		for(int i = 0; i < len2 / 2; i++){
			if(eraseX.charAt(i) != eraseX.charAt(len2 - i - 1)){
				System.out.println(-1);
				return;
			}
		}
		
//		//左右のxの個数を調べる
		int result = 0;
		for(int i = 0; i < splitAlpha.length/2 ; i++){
			result += Math.abs(splitAlpha[i].length() - splitAlpha[splitAlpha.length - i - 1].length());
		}
		
		System.out.println(result);
//		int leftX = 0;
//		int rightX = 0;
//		int mid = len2 / 2;
//		for(int i = 0; mid > 0 ; i++){
//			char c = input.charAt(i);
//			
//			if(c == 'x'){
//				leftX++;
//			}
//			else {
//				mid--;
//			}
//		}
//		System.out.println("L "+leftX+" R "+rightX);
	}

}


Measured memory_bytes: 28244
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

const int MX = 32;

long long pt2[MX];

int check(long long x, long long y, int k) {
    return llabs(x) + llabs(y) <= pt2[k] - 1;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int n; cin >> n;
	vector<long long> x(n), y(n);
	int ok = 1;
	for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        ok &= ((abs(x[i]) + abs(y[i])) % 2 == (abs(x[0]) + abs(y[0])) % 2);
	}
    if (!ok) {cout << -1 << endl; return 0; }
    int even = (abs(x[0]) + abs(y[0])) % 2 == 0;
    for (int i = 0; i < MX; i++)
        pt2[i] = (1LL << i);
    cout << MX + even << endl;
    if (even) cout << 1 << " ";
    for (int i = MX - 1; i >= 0; i--)
        cout << pt2[i] << " ";
    cout << endl;
    for (int j = 0; j < n; j++) {
        string ans;
        long long cx = x[j], cy = y[j];
        if (even) {
            ans.push_back('R');
            cx--;
        }
        for (int i = MX - 1; i >= 0; i--) {
            if (check(cx, cy + pt2[i], i)) {
                ans.push_back('D');
                cy += pt2[i];
            } else if (check(cx + pt2[i], cy, i)) {
                ans.push_back('L');
                cx += pt2[i];
            } else if (check(cx, cy - pt2[i], i)) {
                ans.push_back('U');
                cy -= pt2[i];
            } else if (check(cx - pt2[i], cy, i)) {
                ans.push_back('R');
                cx -= pt2[i];
            } else {
                assert(false);
            }
        }
        cout << ans << endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)


bool is_integer(double x) {
    return floor(x)==x;
}

int main()
{
    int x, y;
    cin >> x >> y;
    int a, b;
    string ans = "No";
    rep(i, x+1) {
        a = i;
        b = x - a;
        if (y == 2*a + 4*b) {
            ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
int a[100010],b[100010],c[100010],d[100010];
int num[100010],num2[100010];
pair<int,int> p[100010],q[100010];
set<pair<int,int>> s;
int par[100010],sz[100010];
void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i; sz[i] = 1;
	}
}

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

void unite(int x, int y){
	x = find(x); y = find(y);
	if(x==y) return;
	if(sz[x]<sz[y]) swap(x,y);
	sz[x] += sz[y]; par[y] = x;
}

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

int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
		c[i] = a[i];
	}
	for(i=0;i<n;i++){
		cin >> b[i];
		d[i] = b[i];
	}
	sort(c,c + n); sort(d,d + n);
	for(i=0;i<n;i++){
		s.insert({c[i],d[i]});
		if(c[i]>d[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	int cnt = 0;
	for(i=0;i<n;i++){
		if(s.count({a[i],b[i]})) cnt++;
	}
	if(cnt>=1){
		cout << "Yes" << endl;
	}else{
		for(i=0;i<n - 1;i++){
			if(c[i + 1]<=d[i] && c[i - 1]<=d[i + 1]){
				cout << "Yes" << endl;
				return 0;
			}
		}
		for(i=0;i<n - 1;i++){
			if(c[i]==c[i + 1] || d[i]==d[i + 1]){
				cout << "Yes" << endl;
				return 0;
			}
		}
		init(n);
		for(i=0;i<n;i++){
			p[i] = {a[i],i}; q[i] = {b[i],i};
		}
		sort(p,p + n); sort(q,q + n);
		for(i=0;i<n;i++){
			num[q[i].second] = i; num2[p[i].second] = i;
		}
		for(i=0;i<n;i++){
			unite(num2[i],num[i]);
		}
		for(i=0;i<n;i++){
			if(par[i]==i){
				if(sz[find(i)]==n){
					cout << "No" << endl;
					return 0;
				}
			}
		}
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		s = s.replaceAll("A", "");
		
		if (s.length() == 0 || s.length() == 3) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		
	}
}	

Measured memory_bytes: 22868
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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


	READV(N);
	ll ans=0;
	FORI(i,1,N+1)
	{
		ll z=i;
		ll d=0;
		while(z>0)
		{
			d++;
			z=z/10;
		}
		if (d%2==1)
		{
			ans++;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> A >> B;
	ans = max(A + A - 1, B + B - 1);
	ans = max(A + B, ans);

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
void swap(int *a,int *b){
    int x = *a;
    *a = *b;
    *b = x;
}

int main(){
    int N,M;
    scanf("%d %d",&N,&M);
    int num[N];
    int sum=0;
    for(int i=0;i<N;i++){
        scanf("%d",num+i);
        sum += num[i];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<i;j++){
        if(num[j]<num[i]) {swap(&num[i],&num[j]);}
        }
    }
    if(num[M-1]*4*M < sum)printf("No");
    else printf("Yes");
    return 0;   
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
 
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define sqr(x) ((x)*(x))
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define y1 asdfghjkl
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
const ll N = 2e5;
const ll INF = 1e18 + 7;
 
void boost() {
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}
void file() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}
ll fast_pow(ll a, ll b){
	ll res = a, ret = 1;
	while(b){
		if(b&1)
			ret = (ret*res)%mod;
		res = (res*res)%mod;
		b>>=1;
	}
	return ret;
}

int n, d[200][2]; 

int main() {
	boost();
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> d[i][0] >> d[i][1];
	}
	for(int i = 1; i <= n-2; i++) {
		if(d[i][1] == d[i][0] && d[i+1][1] == d[i+1][0] && d[i+2][1] == d[i+2][0]){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3672
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

constexpr ll MOD = 1000000007;

class Enumeration {
public:
  explicit Enumeration(int n, uint64_t m) : mod(m), fact(n), inv(n), finv(n) {
    fact[0] = finv[0] = inv[1] = 1;
    for (int i = 2; i < n; ++i) inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    for (int i = 1; i < n; ++i) {
      fact[i] = fact[i - 1] * i % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }
  uint64_t operator()(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return fact[n] * finv[n - k] % mod * finv[k] % mod;
  }
  uint64_t modpow(uint64_t x, uint64_t e) {
    uint64_t res = 1;
    while (e > 0) {
      if (e & 1) res = res * x % mod;
      x = x * x % mod;
      e >>= 1;
    }
    return res;
  }

private:
  uint64_t mod;
  vector<uint64_t> fact, inv, finv;
};

int main() {
#ifdef LOCAL
  freopen("in.txt", "rt", stdin);
#endif

  ll n, m, k;
  cin >> n >> m >> k;

  Enumeration e(n * m, MOD);
  ll ans = 0;
  // x
  for (ll i = 1; i < m; ++i) {
    // 距離iとなる2個の選び方: 通り数 横 * 縦
    ll j = (m - i) * n * n % MOD;
    // 総和 距離iが
    ans += i * j * e(n * m - 2, k - 2) % MOD;
    ans %= MOD;
  }
  for (ll i = 1; i < n; ++i) {
    ll j = (n - i) * m * m % MOD;
    ans += i * j * e(n * m - 2, k - 2) % MOD;
    ans %= MOD;
  }
  cout << ans << '\n';

#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> B(N+10),A(N+10, 1e16),C(N+10,1e10),D(N+10);
    rep(i,N+1){
        cin >> B[i];
    }
    /*
    A[0] = 1;
    C[0] = A[0] - B[0];
    if(C[0] < 0){
        cout << -1 << endl;
        return 0;
    }
    A[1] = C[0]*2;
    */
   if(N == 0){
       if(B[0] != 1){
           cout << -1 << endl;
           return 0;
       }else{
           cout << 1 << endl;
           return 0;
       }
   }
   
    A[0] = 1;
    rep(i,N+1){
        C[i] = A[i] - B[i];
        if(C[i] < 0){
            cout << -1 << endl;
            return 0;
        }
        A[i+1] = C[i]*2;
        if(A[i+1] >= 1e16){
            break;
        }
    }
    //PR(A,N+1);
    /*ll ans = 0;
    rep(i,N+1){
        ans += A[i];
    }*/
    C[N] = 0;
    D[N] = B[N];
    for(ll i=N-1;i>=0;i--){
        D[i] = B[i] + D[i+1];
        /*
        if(D[i+1] > (D[i]-B[i])*2){
            D[i] = B[i] + D[i+1]/2;
            //cout << -1 << endl;
            //return 0;
        }*/
        /*if(D[i+1] > A[i]*2){
            cout << -1 << endl;
            return 0;
        }*/
        if(D[i] > A[i]){
            //if(A[i] == 1e17)continue;
            D[i] = A[i];
        }
        //C[i] = D[i] - B[i];
    }
    ll ans = 0;
    rep(i,N+1){
        ans += D[i];
    }
    cout << ans << endl;
}


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

int main()
{
ll h , w , k ;
cin >> h >> w >> k ;
string s[h];
rep(i,h){
  cin >> s[i];
}
ll c=0;
vector<vector<ll>> v(h, vector<ll>(w,0) );
rep(i,h){
  bool a=0;
  rep(j,w){
    if(s[i][j]=='#'){a=1;c++;v[i][j]=c;}
    else if(a)v[i][j]=c;
  }
}
rep(i,h){
  rep(j,w-1){
    if(v[i][w-j-2]==0)v[i][w-j-2]=v[i][w-j-1];
  }
}
rep(i,w){
  rep(j,h-1){
    if(v[j+1][i]==0)v[j+1][i]=v[j][i];
  }
}
rep(i,w){
  rep(j,h-1){
    if(v[h-j-2][i]==0)v[h-j-2][i]=v[h-j-1][i];
  }
}

rep(i,h){
  rep(j,w){
    cout << v[i][j] << ' ';
    
  }
  cout << endl;
}
return 0;
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;


string* ClearBomb(string s[],int x,int y)
{
	s[x][y] = '0';
	REP(i,-3,4)
	{
		if(-1 < x+i && x+i < 8)
		{
			if(s[x+i][y] == '1')
			{
				ClearBomb(s,x+i,y);
			}
		}

		if(-1 < y+i && y+i < 8)
		{
			if(s[x][y+i] == '1')
			{
				ClearBomb(s,x,y+i);
			}
		}
	}
	return s;
}

int main()
{
	int n,count = 0;
	cin >> n;

	rep(i,n)
	{
		string s[8];
		rep(j,8)
		{
			cin >> s[j];
		}

		int x,y;
		cin >> x >> y;

		ClearBomb(s,y-1,x-1);

		count++;
		cout << "Data " << count << ":" << endl;

		rep(i,8)
		{
			cout << s[i] << endl;
		}
	}

	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
  double W, H, a, b;
  cin >> W >> H >> a >> b;
  if(a == W/2.0 && b == H/2.0) cout << setprecision(6) << W*H/2.0 << ' ' << 1 << endl;
  else cout << setprecision(6) << W*H/2.0 << ' ' << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    int[] ps = {6, 8, 10, 12, 14, 16, 0};
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      int n = scanner.nextInt();
      if (n == 0) {
        break;
      }
      int p = 0;
      for (int ii = 0; ii < n; ii++) {
        int xyh = scanner.nextInt() + scanner.nextInt() + scanner.nextInt();
        int w = scanner.nextInt();
        int xyhp = 0;
        int wp = 0;
        if (xyh <= 60) {
          xyhp = ps[0];
        } else if (xyh <= 80) {
          xyhp = ps[1];
        } else if (xyh <= 100) {
          xyhp = ps[2];
        } else if (xyh <= 120) {
          xyhp = ps[3];
        } else if (xyh <= 140) {
          xyhp = ps[4];
        } else if (xyh <= 160) {
          xyhp = ps[5];
        } else {
          xyhp = 0;
        }
        if (w <= 2) {
          wp = ps[0];
        } else if (w <= 5) {
          wp = ps[1];
        } else if (w <= 10) {
          wp = ps[2];
        } else if (w <= 15) {
          wp = ps[3];
        } else if (w <= 20) {
          wp = ps[4];
        } else if (w <= 25) {
          wp = ps[5];
        } else {
          wp = 0;
        }
        if (xyhp == 0 || wp == 0) {
          continue;
        }
        if (xyhp > wp) {
          p += xyhp;
        } else {
          p += wp;
        }
      }
      System.out.println(p * 100);
    }
  }
}

Measured memory_bytes: 56356
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	ll h,n;
	cin >> h >> n;
	ll a[1010],b[1010];
	FOR(i,n){
		cin >> a[i] >> b[i];
	}
	ll dp[20010];
	FOR(i,20010)dp[i]=MOD;
	dp[0]=0;
	for(int i=0;i<h;i++){
		FOR(j,n){
			chmin(dp[i+a[j]],dp[i]+b[j]);
		}

	}

	ll ans=MOD;
	for(int i=h;i<20010;i++){
		chmin(ans,dp[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
from collections import deque

H,W=map(int,input().split())
S=[]
for i in range(H):
  S.append(input())
  
def bfs(s):
  seen = [[0 for i in range(W)] for j in range(H)]
  total = [[0 for i in range(W)] for j in range(H)]
  todo = deque([])
  now = s
  if S[now[0]][now[1]]=='#':return 0
  seen[now[0]][now[1]],total[now[0]][now[1]] = 1,0
  todo.append(now)
  while 1:
    if len(todo)==0:break
    now = todo.popleft()
    for d in [(1,0),(-1,0),(0,1),(0,-1)]:
      new = (now[0]+d[0], now[1]+d[1])
      if new[0]<0 or new[0]>=H:continue
      if new[1]<0 or new[1]>=W:continue
      if seen[new[0]][new[1]]==1:continue
      if S[new[0]][new[1]]=='#':continue
      seen[new[0]][new[1]] = 1
      todo.append(new)
      total[new[0]][new[1]] = total[now[0]][now[1]] + 1
  return max(map(max, total))

MAX=0
for i in range(H):
  for j in range(W):
    s = (i,j)
    max_ = bfs(s)
    if MAX < max_:MAX=max_

print(MAX)

Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
char str[15];
void dfs(int l,int t,int n)
{
    if(l==n)
    {
        printf("%s\n",str);
        return;
    }
    for(int i=0;i<=t+1;i++)
    {
        str[l]='a'+i;
        dfs(l+1,max(t,i),n);
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    dfs(0,-1,n);
    return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
#include<limits.h>
using namespace std;

const int N=1e5+5;
typedef pair<int,int> pii;
int n;
pair<long long,int> a[N];
long long sz[N];
long long dp[N];
vector<pii> vp;
map<long long,int> mp;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i].first);
		a[i].second=i;
	}
	sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	for(int i=1;i<=n;i++) mp[a[i].first]=i;
	for(int i=1;i<=n;i++) sz[i]=1ll;
	for(int i=1;i<n;i++){
		long long fnd=a[i].first-1ll*n+2*sz[i];
		if(mp.find(fnd)==mp.end()){
			puts("-1");
			return 0;
		}
		int nxt=mp[fnd];
		dp[nxt]+=dp[i]+sz[i];
		sz[nxt]+=sz[i];
		vp.push_back(make_pair(a[i].second,a[nxt].second));
	}
	if(vp.size()!=n-1||dp[n]!=a[n].first) puts("-1");
	else for(int i=0;i<vp.size();i++) printf("%d %d\n",vp[i].first,vp[i].second);
	return 0;
}

/*
数据不清空，爆零两行泪
读题不认真，爆零两行泪
分析不仔细，爆零两行泪
建树不构造，爆零两行泪
变量不统一，爆零两行泪
边界不算清，爆零两行泪
数组不开大，爆零两行泪
*/

Measured memory_bytes: 11640
from bisect import *
def solve():
    ans = 0
    N = int(input())
    A = [-int(input()) for _ in range(N)]
    lis = [A[0]]
    for i in range(1,N):
        if A[i]>=lis[-1]:
            lis.append(A[i])
        else:
            ind = bisect_right(lis,A[i])
            lis[ind] = A[i]
    ans = len(lis)
    return ans
print(solve())

Measured memory_bytes: 13724
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

X = ri()

if X <= 6:
    print(1)
    exit()
q, r = divmod(X, 11)
answer = 2 * q
if r > 0:
    answer += 1
if r > 6:
    answer += 1
print(answer)

Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input!{
        s:String
    }
    let ans = match s.as_str() {
        "RRR" => 3,
        "RRS" | "SRR" => 2,
        "RSR" | "SRS" | "SSR" | "RSS" => 1,
        _ => 0
    };
    println!("{}", ans);
}


Measured memory_bytes: 2084
#include<iostream>

using namespace std;

int main()
{
	int H, W;

	while (true)
	{
		cin >> H >> W;

		if (H == 0 || W == 0)
			break;

		for (int i = 0; i < H; i++)
		{
			if ((i % 2) == 0)
			{
				for (int j = 0; j < W; j++)
				{
					if ((j % 2) == 0)
						cout << '#';
					else
						cout << '.';
				}
			}
			else
			{
				for (int j = 0; j < W; j++)
				{
					if ((j % 2) == 0)
						cout << '.';
					else
						cout << '#';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3100
from collections import defaultdict

N = int(input())
S = [input() for i in range(N)]
ans = defaultdict(list)
for s in S:
    count = [0] * 26
    for c in s:
        count[ord(c)-ord('a')] += 1
    ans[tuple(count)].append(s)

ret = 0
l = 0
for a in ans.keys():
    l = len(ans[a])
    ret += l*(l-1)//2

print(ret)





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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef set<int> si;
typedef set<ll, ll> sll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<int, int> mii;
typedef map<int, ll> mil;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;

#define FOR(i, a, b) for(int i = (a), loop_end_##i=(b); i < (loop_end_##i); i++)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort((c).begin(),(c).end())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define PB push_back

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

int main(){
	int sum = 0;
	REP(i, 10) sum+=read<int>();
	cout << sum << endl;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n>>m;
      map<ll,ll> mp;
      rep(i,n)cin>>a[i];
      rrep(i,1,n){
        a[i]+=a[i-1];
      }
      rep(i,n){
        mp[a[i]%m]++;
        if(a[i]%m==0)ans++;
      }
      rep(i,n){
        pos=a[i]%m;
        mp[pos]--;
        ans+=mp[pos];
      }
      Cout(ans);

     

       
return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int x, m;
   cin >> x;
   if(x>=400 && x<=599)
   {
     m = 8;
   }
   else if(x>=600 && x<=799)
   {
       m = 7;
   }
   else if(x>=800 && x<=999)
   {
       m = 6;
   }
   else if(x>=1000 && x<=1199)
   {
       m = 5;
   }
   else if(x>=1200 && x<=1399)
   {
       m = 4;
   }
   else if(x>=1400 && x<=1599)
   {
       m = 3;
   }
   else if(x>=1600 && x<=1799)
   {
       m = 2;
   }
   else if(x>=1800 && x<=1999)
   {
       m = 1;
   }
   
   cout << m << endl;
   
   return 0;
    
    
    
}


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

int main(){
  int n;
  cin >> n;
  n %= 10;
  if(n==2||n==4||n==5||n==7||n==9){
    cout << "hon" << endl;
  }
  else if(n==3){
    cout << "bon" << endl;
  }
  else cout << "pon" << endl;

}


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

int main() {
    char a[3],b[3];
    int ans=0;
	for(int i=0;i<3;i++){
	cin >> a[i];
	}
  	for(int i=0;i<3;i++){
	cin >> b[i];
      if(a[i]==b[i]){
        ans++;
      }
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define sqr(x) ((x)*(x))
typedef pair<long long,int> pli;
priority_queue<pli> pq;
int n,k;
int t;
long long d;
vector<pli> re;
map<int,int> mp;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>t>>d;
		pq.push(pli(d,t));
	}
	long long num=0;
	for(int i=1;i<=k;i++){
		pli cur=pq.top();
		pq.pop();
		mp[cur.second]++;
		num+=cur.first;
		re.push_back(cur);
	}
	reverse(re.begin(),re.end());
	long long sz=mp.size();
	long long res=num+sqr(sz);
	for(int i=0;i<k;i++){
		if(mp[re[i].second]==1)
			continue;
		while(!pq.empty()){
			pli cur=pq.top();
			pq.pop();
			if(mp[cur.second]==0){
				num-=re[i].first;
				num+=cur.first;
				sz++;
				res=max(res,num+sqr(sz));
				mp[re[i].second]--;
				mp[cur.second]++;
				re[i]=cur;
				break;
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


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

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

    vector<pair<int, int>> as(n);
    vector<pair<int, int>> bs(m);

    for (auto &p: as)
        cin >> p.first >> p.second;
    for (auto &p: bs)
        cin >> p.first >> p.second;

    for (int i = 0; i < n; i++) {
        int ans = 0;
        int min_d = 0x7fffffff;

        for (int j = 0; j < m; j++) {
            int d = abs(as[i].first - bs[j].first) + abs(as[i].second - bs[j].second);
            if (d < min_d) {
                ans = j;
                min_d = d;
            }
        }

        cout << ans + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string input_h = input.Substring(0, 2); // 0-99
            string input_l = input.Substring(2, 2); // 0-99
            int H = int.Parse(input_h);
            int L = int.Parse(input_l);
            bool MML = false, MMH = false;
            // Check if low / high is MM ?
            if (L > 0 && L <= 12) { MML = true; }
            if (H > 0 && H <= 12) { MMH = true; }
            if (MML && MMH){ Console.WriteLine("AMBIGUOUS"); }
            else if (MML) { Console.WriteLine("YYMM"); }
            else if (MMH) { Console.WriteLine("MMYY"); }
            else { Console.WriteLine("NA"); }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for (auto &&i : v) scanf("%d %d", &i.first, &i.second);
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int a, b; scanf("%d %d", &a, &b);
        v.emplace_back(a, b);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    for (int i = 0; i < v.size(); ++i) {
        if(i) printf(" ");
        printf("%d:%02d", v[i].first, v[i].second);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 3228
N = int(input())
A = list(map(int,input().split()))
f = 0
t = 0

for count in A :
    if count % 2 == 0:
        if count % 3 != 0 and count %5 != 0:
            f = 1
            break

        else:
            t = 1

if f:
    print("DENIED")

elif t and not f:
    print("APPROVED")

else:
    print("APPROVED")


Measured memory_bytes: 3060
import java.util.Scanner;

class Main{
  static char[] s1,s2;
  static int[][] arr;
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

    int count = scan.nextInt();
    for(int loop = 0; loop < count; loop++) {
      s1 = scan.next().toCharArray();
      s2 = scan.next().toCharArray();
      arr = new int[s1.length][s2.length];
      for(int i = 0; i < arr.length; i++) for(int j = 0; j < arr[i].length; j++) arr[i][j]=-1;
      System.out.println(calc(0,0));
    }
  }

  public static int calc(int x, int y) {
    if(x==s1.length||y==s2.length)  return 0;
    if(arr[x][y]>=0) return arr[x][y];
    if(s1[x]==s2[y]) {
      arr[x][y] = 1 + calc(x+1,y+1);
      return arr[x][y];
    }else {
      arr[x][y] = Math.max(calc(x,y+1),calc(x+1,y));
      return arr[x][y];
    }
  }
}

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

int main()
{
    int H, W;
    while (true)
    {
        cin >> H >> W;
        if (H == 0 && W == 0)
        {
            break;
        }
        for (int i = 1; i < H + 1; i++)
        {
            if (i % 2 == 1)
            {
                if (W % 2 == 0)
                {
                    for (int j = 0; j < W / 2; j++)
                    {
                        cout << "#.";
                    }
                }
                else
                {
                    for (int j = 0; j < (W - 1) / 2; j++)
                    {
                        cout << "#.";
                    }
                    cout << "#";
                }
                cout << endl;
            }
            else
            {
                if (W % 2 == 0)
                {
                    for (int j = 0; j < W / 2; j++)
                    {
                        cout << ".#";
                    }
                }
                else
                {
                    for (int j = 0; j < (W - 1) / 2; j++)
                    {
                        cout << ".#";
                    }
                    cout << ".";
                }
                cout << endl;
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
const double pi=2*acos(0.0);
double inff=1.0/0.0;
#define ll           long long int
#define inf          1000000000000000008
#define MOD          1000000007
#define pb           push_back
#define sz(x)        (int)x.size()
#define mp           make_pair
#define lbd          lower_bound
#define ubd          upper_bound
#define ipair        pair<ll,ll> 
#define all(v)       v.begin(),v.end()
#define watch(x)     cout<<(#x)<<" is "<<(x)<<endl;
#define rep(a,b,c)   for(a=(int)b;a<(int)c;a++)
#define rep2(a,b,c)  for(a=(int)b;a<(int)c;a+=2)  
#define bac(a,b,c)   for(a=(int)b;a>=(int)c;a--)
#define se           second
#define f            first
#define ios          ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
#define mem(a,val)   memset(a,val,sizeof a)
#define endl         "\n"
#define mxn          200001
#define vi           vector<ll>
#define vii          vector<ipair> 
#define si           set<ll> 
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*Variables Start*/
ll x,y,n,i,z,j,k,w,u,q,m,t;
/*Variables End*/
void solve()
{
 	cin>>x>>y;
 	if((x+y)&1)
 	{
 		cout<<"IMPOSSIBLE"<<endl;
 	} 
 	else cout<<(x+y)/2<<endl;
}
int main() 
{ 
  int TESTS=1;
  ios;  
  while(TESTS--)
  {
    solve();
  }  
}

Measured memory_bytes: 256