akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <cassert>
#include <functional>
#include <iterator>
using namespace std;
using VI = vector<long>;

VI ed[501];

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        ed[l].push_back(r);
    }
    for (int i = 0; i < 501; i++) {
        sort(ed[i].begin(), ed[i].end());
    }
    
    for (int i = 0; i < q; i++) {
        int p, q;
        cin >> p >> q;
        int ans = 0;
        for (int s = p; s <= q; s++) {
            ans += lower_bound(ed[s].begin(), ed[s].end(), q + 1) - ed[s].begin();
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3456
# Meet

def digitSum(a):
	s=0
	while a!=0:
		s+=a%10
		a//=10

	return s

n = int(input())
a = 1
b = n-1

m = 100000000000
while a<=b:
	s1 = digitSum(a)
	s2 = digitSum(b)

	if s1+s2 < m:
		m = s1+s2

	a+=1
	b-=1

print(m)

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

using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF 2e9
#define MOD 1e9+7
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(n))

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

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

template<class InputIterator>
InputIterator adv(InputIterator x, typename std::iterator_traits<InputIterator>::difference_type n) {
    advance(x, n);
    return x;
}

int ni() {
    int i;
    cin >> i;
    return i;
}

int main() {
    int N = ni();
    ll count[3] = {};
    REP(i, N) {
        ll a = ni();
        if ((a&3) == 0) count[2]++;
        else if ((a&1) == 0) count[1]++;
        else count[0]++;
    }

    if (count[1] > 0) {
        cout << (count[0] <= count[2] ? "Yes" : "No") << endl;
    } else {
        cout << (count[0]-1 <= count[2]  ? "Yes" : "No") << endl;
    }

    return 0;
}

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

int main () {
  int  N ;
  cin >> N ;
  long long Min = 10000 , Max = 0 ;
  long long line[N] ;
  for(int i = 0 ; i < N ; i++ ){
    cin >> line[i] ;
    Min = min(Min , line[i] );
    Max = max(Max , line[i] );
  }
  long long ans = 1000000000000;
  for(int i = Min ; i <= Max ; i++ ) {
    long long pre = 0 ;
    for(int j = 0 ; j < N ; j++ ){
      pre += pow((i-line[j]),2) ;
    }
    ans = min(ans , pre) ;
  }
  cout << ans << endl ;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
if x in A and y in A:
  print("Yes")
elif x in B and y in B:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int sosu(int s) {
  int i;
  double sq;
  if(s < 2) return 0;
  if(s == 2) return 1;
  if(s % 2 == 0) return 0;
  sq = sqrt(s);
  for(i = 3; i <= sq; i += 2) {
    if(s % i == 0) {
      return 0;
    }
  }
  return 1;
}

int main() {
  int x, z, z2;
  scanf("%d", &x);

  z2 = 2 * z;
  for(int z = x; 1; z++) {
    if(sosu(z)){
      printf("%d\n", z);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){

  char s1[200]={0};
  char s2[200]={0};
  char t1[200]={0};
  char t2[200]={0};
  char u1[200]={0};
  char u2[200]={0};

  int c=0,flag=0,j=0,k=0,l=0;

  for(int x=0;x<100;x++){


  cin>>s1;
  if(s1[0]=='.') break;               //input
  cin>>s2;


  for(int i=0;i<200;i++){           
    if(s1[i]=='"'){
      if(flag==0){
	flag=1;
	
      }else if(flag==1){
	flag=0;
	
      }
    }

    if(flag==1){                   //copy to u
      t1[j]=s1[i];
      j++;    
    }

    if(flag==0){                 //copy to t
      u1[l]=s1[i];
      l++;    
    }


  }
  j=0;
  l=0;
  flag=0;

  for(int i=0;i<200;i++){             

    if(s2[i]=='"'){
      if(flag==0){
	flag=1;
	
      }else if(flag==1){
	flag=0;
	
      }
    }

    if(flag==1){                       //copy to t

      t2[j]=s2[i];
      j++;
    }

 if(flag==0){                            //copy to u
      u2[l]=s2[i];
      l++;
    }

  }
 j=0;
 l=0;
 flag=0;

 
   
 for(int i=0;i<150;i++){           //check in " "


    if(flag==1){
    if(t1[j]!=t2[k]){
      c++;
      flag=0;
    }

    if(t1[j]=='"' && t2[k]!='"'){
      j--;
    }
    if(t2[k]=='"' && t1[j]!='"'){
      k--;
    }

    j++;
    k++;

    }

   if(t1[j]=='"' && t2[k]=='"'){
     flag=1;

    }


  }

    j=0;
    k=0;
    l=0;
    flag=0;


 for(int i=0;i<200;i++){               //check out " "
    if(u1[i]!=u2[i]){
      c=2;
    }
  }

    if(c==0){
      cout<<"IDENTICAL"<<endl;
    }else if(c==1){
      cout<<"CLOSE"<<endl;
    }else{
      cout<<"DIFFERENT"<<endl;
    }

    c=0;

   
    /*   cout<<t1<<endl;
    cout<<t2<<endl;
    cout<<u1<<endl;
    cout<<u2<<endl;*/
    for(int i=0;i<200;i++){
     s1[i]=0;
    s2[i]=0;
    t1[i]=0;
    t2[i]=0;
    u1[i]=0;
    u2[i]=0;
    }

  }

  return 0;
}



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

const int maxn = 15;

int main()
{
    char str[maxn];
    while(scanf("%s",str) != EOF)
    {
        int len = strlen(str);
        int n = 1 << (len - 1);
        long long ans = 0;
        for(int i = 0;i < n;i++)
        {
            long long t = str[0] - '0';
            for(int j = 0;j < n;j++)
            {
                if(j == len - 1 || i & 1 << j)
                {
                    ans += t;
                    t = 0;
                    if(j == len - 1)
                        break;
                }
                t = t * 10 + str[j + 1] - '0';
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
x,k,d = map(int, input().split())
lists = []
x = abs(x)

step = int(x/d) 

if step >= k:
  answer = x - k * d
elif step < k:
  k_left = k - int(step)
  if k_left % 2 == 0:
    answer = x % d
  if k_left % 2 == 1:
    answer = abs(x - step * d - d)

print(answer)

Measured memory_bytes: 9008
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,p[100010],cnt=0;
    cin>>n;
    rep(i,n) cin>>p[i];
    rep(i,n){
        if(p[i]!=i+1) cnt++;
    }
    if(cnt==0 || cnt==2){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    return 0;
}

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

int R, C, K;
int V[3010][3010];
int dp[3010][3010][5];
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> R >> C >> K;
    rep(i, K) {
        int r, c, v; cin >> r >> c >> v;
        V[r-1][c-1] = v;
    }
    dp[0][0][1] = V[0][0];
    rep(i, R) rep(j, C) {
        if (i-1>=0) {
            rep(k, 4) {
                dp[i][j][0] = max(dp[i][j][0], dp[i-1][j][k]);
                dp[i][j][1] = max(dp[i][j][1], dp[i-1][j][k]+V[i][j]);
            }
        }
        if (j-1>=0) {
            rep(k, 4) {
                dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k]);
                if (k+1<=3) dp[i][j][k+1] = max(dp[i][j][k+1], dp[i][j-1][k]+V[i][j]);
            }
        }
    }
    cout << max({dp[R-1][C-1][0], dp[R-1][C-1][1], dp[R-1][C-1][2], dp[R-1][C-1][3]}) << endl;
}

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

class BinaryTree
{
private:
        struct Node {
                int key;
                Node *parent, *left, *right;
                Node () : parent(nullptr), left(nullptr), right(nullptr) {}
                Node (int key) : key(key), parent(nullptr), left(nullptr), right(nullptr) {}
        };
public:
        BinaryTree () : root(nullptr) {}
        void insert(int k)
        {
                Node *data;
                Node **pos = findInsertPos(k, &root);
        
                data = new Node(k);
                *pos = data;
                data->parent = *pos;
        }
                
        bool find(int k) { return ( find(k, root) ); }
        void preorder() { preorder(root); }
        void inorder() { inorder(root); }
private:
        Node *root;

        Node **findInsertPos(int k, Node **node)
        {
                if ( *node == nullptr ) return ( node );
                if ( k < (*node)->key ) return ( findInsertPos(k, &((*node)->left)) );
                else return ( findInsertPos(k, &((*node)->right)) );
        }
        
        bool find(int k, Node *node)
        {
                if ( node == nullptr ) return ( false );
                if ( node->key == k ) return ( true );
                if ( k < node->key ) return ( find(k, node->left) );
                else return ( find(k, node->right) );
        }

        void preorder(Node *node)
        {
                if ( node == nullptr ) return;
                cout << " " << node->key;
                preorder(node->left);
                preorder(node->right);
        }

        void inorder(Node *node)
        {
                if ( node == nullptr ) return;
                inorder(node->left);
                cout << " " << node->key;
                inorder(node->right);
        }
};


int main()
{
        int n;
        BinaryTree tree;

        cin >> n;
        for ( int i = 0; i < n; i++ ) {
                string S;
                int k;
                cin >> S;
                if ( S == "insert" ) {
                        cin >> k;
                        tree.insert(k);
                } else if ( S == "print" ) {
                        tree.inorder(); cout << endl;
                        tree.preorder(); cout << endl;
                } else if ( S == "find" ) {
                        cin >> k;
                        if ( tree.find(k) ) cout << "yes" << endl;
                        else cout << "no" << endl;
                }
        }
        
        return ( 0 );
}



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

int main(){
  int N; cin >> N;
  vector<int> h(N);
  for(int i=0; i<N; i++)
    cin >> h.at(i);
  
  vector<int> dp(N);
  dp.at(0) = 0;
  dp.at(1) = abs(h.at(0)-h.at(1));
  
  for(int i=2; i<N; i++){
    dp.at(i) = min(abs(h.at(i)-h.at(i-1))+dp.at(i-1), abs(h.at(i)-h.at(i-2))+dp.at(i-2) );
  }
  
  cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
 int A[10000],B[10000],i,j;
 char O[10000];

 for(i=0;i>=0;i++){
  scanf("%d %c %d\n",&A[i],&O[i],&B[i]);

  if(O[i]=='?'){
   j=i;
   break;
  }
 }
 for(i=0;i<=j-1;i++){
  switch(O[i]){
   case '+':
    printf("%d\n",A[i]+B[i]);
    break;
   case '-':
    printf("%d\n",A[i]-B[i]);
    break;
   case '*':
    printf("%d\n",A[i]*B[i]);
    break;
   case '/':
    printf("%d\n",A[i]/B[i]);
    break;
   }
  }

return 0;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const int nax = 3007;
ll v[nax][nax];
ll dp[nax][nax][4];
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll r, c, k;
	cin >> r >> c >> k;
	// for (ll i = 0; i < r; i++) {
	// 	for (ll j = 0; j < c; j++) {
	// 		v[i][j] = 0;
	// 		dp[i][j][0] = 0;
	// 		dp[i][j][1] = 0;
	// 		dp[i][j][2] = 0;
	// 		dp[i][j][3] = 0;
	// 	}
	// }
	for (ll i = 0; i < k; i++) {
		ll x, y, val;
		cin >> x >> y >> val;
		--x, --y;
		v[x][y] = val;
	}
	dp[0][0][0] = 0, dp[0][0][1] = v[0][0];
	for (ll i = 0; i < r; i++) {
		for (ll j = 0; j < c; j++) {
			for (ll x = 0; x < 4; x++) {
				if (i + 1 < r) {
					dp[i + 1][j][0] = max(dp[i][j][x], dp[i + 1][j][0]);
					dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][x] + v[i + 1][j]);
				}
				if (j + 1 < c) {
					dp[i][j + 1][x] = max(dp[i][j][x], dp[i][j + 1][x]);
					if (x + 1 <= 3)dp[i][j + 1][x + 1] = max(dp[i][j + 1][x + 1], dp[i][j][x] + v[i][j + 1]);
				}
			}
		}
	}
	cout << max({dp[r - 1][c - 1][0], dp[r - 1][c - 1][1], dp[r - 1][c - 1][2], dp[r - 1][c - 1][3]}) << endl;
}


Measured memory_bytes: 355988
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

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

  vector<long long> v(5);
  for (auto &x : v) {
    cin >> x;
  }

  long long mn = *min_element(v.begin(), v.end());
  long long groups = (n + mn - 1) / mn;
  long long ans = 5 + groups - 1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as B
import qualified Data.Set              as S

main :: IO ()
main = do
  _ <- B.getLine
  a <- B.getLine
  b <- B.getLine
  c <- B.getLine
  print $ solve a b c

solve :: B.ByteString -> B.ByteString -> B.ByteString -> Int
solve a b c = go 0 a b c
  where
    go !k xs ys zs = case mapM B.uncons [xs, ys, zs] of
      Nothing                        -> k
      Just [(x,xs1),(y,ys1),(z,zs1)] -> go (k + l) xs1 ys1 zs1
        where
          l = pred $ S.size $ S.fromList [x, y, z]

Measured memory_bytes: 508
from collections import defaultdict
while True:
  n = int(input())
  if n == 0:
    break
  teams = []
  for _ in range(n):
    i, u, a, p = map(int, input().split())
    teams.append((-a, p, i, u))
  teams.sort()
  
  u_counter = defaultdict(int)
  all_counter = 0
  selected = []
  for _, _, i, u in teams:
    if all_counter < 10 and u_counter[u] < 3 or\
       all_counter < 20 and u_counter[u] < 2 or\
       all_counter < 26 and u_counter[u] < 1:
       u_counter[u] += 1
       all_counter += 1
       selected.append(i)
  
  [print(s) for s in selected]



Measured memory_bytes: 5996
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L=sc.nextInt();
        String[] A=new String[N];
        for(int i=0;i<N;i++){
            A[i]=sc.next();
        }
        Arrays.sort(A);
        for(int i=0;i<N;i++){
            System.out.print(A[i]);
        }
        System.out.println();
    }
}

Measured memory_bytes: 22996
K = int(input())
li = [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]
print(li[K-1])


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

int main () {
	
	int arr[5];
	int k=0;

	cin >> arr[0] >> arr[1] >> arr[2] >> arr[3] >> arr[4] >> k;

	for (int i=0; i<5; i++) {
		for (int j=i+1; j<5; j++) {

			if (abs(arr[j]-arr[i]) > k) {
				cout << ":(" << endl;
				return 0;
			}

		}
	}

	cout << "Yay!"  << endl;
	return 0;
}

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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n;
    ll r=0,g=0,b=0;
    string s;
    cin >> n >> s;
    rep(i, n) {
        if(s[i] == 'R')
            r++;
        else if(s[i] == 'G')
            g++;
        else if(s[i] == 'B')
            b++;
    }
    ll total = r * g * b;

    rep(j, n) rep(i, j) {
        int k = j + (j - i);
        if(k < n) {
            if(s[i] == s[j])
                continue;
            if(s[j] == s[k])
                continue;
            if(s[i] == s[k])
                continue;
            total--;
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define int long int
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    int c1,c2;
    c1=c2=0;
    for(int i=0;i<2*n;i++){
        if(i%2==0)
            cout<<s[c1++];
        else
            cout<<t[c2++];
    }
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

static const int MOD = 1e9 + 7;

int main() {

    int N;
    string S;
    cin >> N >> S;

    bool ans = false;
    if (N % 2 == 0) {
        string T1, T2;
        T1 = S.substr(0, N/2); T2 = S.substr(N/2, N/2);
        if (T1 == T2)ans = true;
    }

    if (ans)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());//int型
		int m = Integer.parseInt(sc.next());
		sc.close();
		System.out.println(n+1-m);
	}

}


Measured memory_bytes: 22228
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
//        int int3 = Integer.parseInt(scan.next());
//        int int4 = Integer.parseInt(scan.next());
//        double db = Double.parseDouble(scan.next());
        int ans_int = 0;
        String ans = "";
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;
//        String str1 = scan.next();
//        String str2 = scan.next();
//        String str3 = scan.next();
        if(int1<=(int2*2)){
        }else{
            ans_int = int1-int2*2;
        }

//        for (int i = 0; i < int1; i++){
//            int m = Integer.parseInt(scan.next());
//            if(m>=int2){
//                list.add(m);
//            }
//        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans_int);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
  int n, k, q;
  cin >> n >> k >> q;
  map<int, int> mp;
  rep(i, q){
    int a;
    cin >> a;
    mp[a]++;
  }

  for(int i = 1; i <= n; i++){
    cout << (k - (q - mp[i]) > 0 ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
 
int main (void) {
  string str;
  cin >> str;
  char* cstr = new char[str.size() + 1]; // メモリ確保
  std::strcpy(cstr, str.c_str());        // コピー
  int sum = 0;
  for (int i = 0; i < str.size(); i++){
    if(cstr[i] == '1'){
      sum += 1;
    }
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;


int main()
{
  ios::sync_with_stdio(0);

  int n;
  cin>>n;

  int d;

  int i;
  for(i=1;i<=9;i++)
  {


      float d=n*1.0/i;

      if(d>9) continue;
      //cout<<d<<endl;

      int m = ceil(d);
      int o = floor(d);

    //cout<<m<<o;
     if(m==o)
     {

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

  }

    cout<<"No"<<endl;


return 0;   }



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

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  int ans = 0;
  rep(si, h) rep(sj, w) {
    if (s[si][sj] == '#') continue;
    vector<vector<int>> dist(h, vector<int>(w, -1));
    queue<P> q;
    auto update = [&](int i, int j, int x) {
      if (dist[i][j] != -1) return;
      dist[i][j] = x;
      q.push(P(i, j));
      ans = max(ans, x);
    };

    update(si, sj, 0);
    while (q.size()) {
      int i = q.front().first;
      int j = q.front().second;
      q.pop();
      rep(dir, 4) {
        int ni = i + di[dir], nj = j + dj[dir];
        if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
        if (s[ni][nj] == '#') continue;
        update(ni, nj, dist[i][j] + 1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  int A,B,C,D[101];
  cin>>A>>B>>C;
  for(int i=0;i<n;i++)cin>>D[i];
  sort(D,D+n,greater<int>());  

  int ans=0;
  for(int i=1;i<=n;i++){
    int cost=A+B*i;
    int col=C;
    for(int j=0;j<i;j++)col+=D[j];
    ans=max(ans,col/cost);
  }
  cout <<ans<<endl;

  return 0;
}

Measured memory_bytes: 1176
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

//10^9 + 7
const ll MOD = 1000000007;

int main() {
	ll A, B, M;
	cin >> A >> B >> M;

	vector<ll> a, b;

	ll tmp, aMin = 1000000007, bMin = 1000000007;
	rep(i, A) {
		cin >> tmp;
		aMin = min(aMin, tmp);
		a.push_back(tmp);
	}
	rep(i, B) {
		cin >> tmp;
		bMin = min(bMin, tmp);
		b.push_back(tmp);
	}
	ll x, y, c, minSum = aMin + bMin;
	rep(i, M) {
		cin >> x >> y >> c;

		minSum = min(a[x - 1] + b[y - 1] - c, minSum);

	}
	cout << minSum << endl;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 998244353;

int gcd(ll x,ll y){
  if(x<y) swap(x,y);
  if(y==0) return x;
  return gcd(x%y,y);
}

int main(){
  ll n;
  cin >> n;
  vector<ll>a(n);
  for(int i=0; i<n; i++)cin >> a[i];
  vector<ll>r(n),l(n);
  r[0]=a[0],l[n-1]=a[n-1];
  for(int i=1; i<n; i++){
    r[i]=gcd(r[i-1],a[i]);
  }
  for(int i=n-2; i>=0; i--){
    l[i]=gcd(l[i+1],a[i]);
  }
  
  ll ans=0;
  for(int i=0; i<n; i++){
    
    ll x;
    if(i==0)x=l[1];
    else if(i==n-1)x=r[n-2];
    else x=gcd(r[i-1],l[i+1]);
    ans=max(ans,x);
  }
  cout << ans << endl;
}
  
  
  
  


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

const int MOD = (int) 1e9 + 7;

int main()
{
    int d, n;
    cin >> d >> n;
    if(d == 0) {
        if(n == 100) cout << 101 << endl;
        else cout << n << endl;
    }
    if(d == 1) {
        if(n == 100) cout << 10100 << endl;
        else cout << 100 * n << endl;
    }
    if(d == 2) {
        if(n == 100) cout << 1010000 << endl;
        else cout << 10000 * n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
while True:
    h,w = [int(x) for x in input().split()]
    if h == 0 and w == 0:
        break
    
    for i in range(h):
        if i%2 == 0:
            line = ["#" if j%2==0 else "." for j in range(w)]
        
        else:
            line = ["." if j%2==0 else "#" for j in range(w)]
        
        print("".join(line))
    print()
            


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

using namespace std;

int main()
{
    int N, R, T;
    cin >> N >> R >> T;
    vector<int> p(N), cur(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];        
    }
    
    int res = 0;
    vector<int> e(R), f(R); 
    for (int i = 0; i < T; i++) {
        for (int j = 0; j < N; j++) {
            cur[j] = (cur[j] + p[j]) % R;
            if (i != 0) e[cur[j]]++;
            if (f[cur[j]] > 0) {
                f[cur[j]]--;
            } else {
                res++;
            }
        }
        for (int j = 0; j < R; j++) {
            f[j] += e[j];
            e[j] = 0;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
bool f(string s)
{
       string ss = s;
       reverse(all(ss));
       return ss == s;
}
ll C2(ll n){
       return (n*(n-1))/2;
}
int main(){
       ll n;
       cin>>n;
       ll a[n];
       arrin(a,n);
       map<int,ll> mp;
       fri(i,0,n){mp[a[i]]++;}
       unordered_map<ll,ll> bg;
       tra(it,mp){
              bg[it->sc]++;
       }
       ll ans = 0;
       fri(i,0,n){
              ll ans = 0;
              bg[mp[a[i]]]--;
              bg[mp[a[i]]-1]++;
              tra(it,bg){
                     //cout<<i<<" "<<it->fr<<" "<<it->sc<<endl;
                     ll xx = it->sc;
                     ans += xx*((it->fr)*(it->fr-1))/2;
              }
              bg[mp[a[i]]]++;
              bg[mp[a[i]]-1]--;
              cout<<ans<<endl;
       }

}


Measured memory_bytes: 11136
S = list(input())
N = len(S)
flag = True
for i in range(N):
    if i%2 == 0 and S[i] == 'L':
        flag = False
        break
    elif i%2 == 1 and S[i] == 'R':
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')
        

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)


int main(){
    int N,K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i,N) cin >> h[i];
    sort(all(h));
    int ans = 1e9;
    rep(i,N-K+1) ans = min(ans,h[i+K-1] - h[i]);
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#define I 10000
int main(void)
{
    int i, j, x[I];
    i = 0;
    while(1) {
        scanf("%d", &x[i]);
        if(x[i]==0)
            break;
        i++;
        j = i;
    }
         
         
         
         
    for(i = 0; i < j; i++) {
        printf("Case %d: %d\n", i+1, x[i]);
    }
    
    return 0;
}
 

 

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var N = Read().ToInt32();
            var r = ReadSplit();
            var count = new int[N];
            for (int i = 0; i < N -1; i++)
            {
                var j = r[i].ToInt32();
                count[j - 1] += 1;
            }
            for (int i = 0; i < N; i++)
            {
                Write(count[i]);
            }
            Read();
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToInt64(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 38436
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;
int actionFunction(vector<vector<int>> &daysActivities) {
    if(daysActivities.size()<=0)return 0;
    vector<vector<int>> activityMax(daysActivities.size(),vector<int>(3));
    if(daysActivities.size()>0) {
        activityMax[0][0]=daysActivities[0][0];
        activityMax[0][1]=daysActivities[0][1];
        activityMax[0][2]=daysActivities[0][2];
    }
    for(int i=1;i<daysActivities.size();i++) {
        activityMax[i][0]=daysActivities[i][0]+max(activityMax[i-1][1],activityMax[i-1][2]);
        activityMax[i][1]=daysActivities[i][1]+max(activityMax[i-1][0],activityMax[i-1][2]);
        activityMax[i][2]=daysActivities[i][2]+max(activityMax[i-1][1],activityMax[i-1][0]);
    }
    return max(activityMax[daysActivities.size()-1][0],max(activityMax[daysActivities.size()-1][1],activityMax[daysActivities.size()-1][2]));
}
int main(void){
    vector<vector<int>> daysActivities;
    int n,tmp;
    cin>>n;
    for(int i=0;i<n;i++) {
        vector<int> tmpVector;
        for(int act=0;act<3;act++) {
            cin>>tmp;
            tmpVector.push_back(tmp);   
        }
        daysActivities.push_back(tmpVector);
    }
    cout<<actionFunction(daysActivities)<<endl;
    
}


Measured memory_bytes: 11824
#include<stdio.h>
#include<string.h>
#define MAXN 200005
char s[MAXN];
int a[MAXN], t[MAXN],c[MAXN],pow[MAXN];
int main(){
    long long cnt = 0; 
    int  i, len; 
    scanf("%s",s + 1);
    len = strlen(s + 1);
    pow[0] = 1;
    for(i = 1; i<=len;i++) pow[i] = (pow[i-1]*10) %2019;
    for(i = 1; i <=len; i++) a[i] = s[i] - '0';
    for(i = len; i>=1; i--){
    	t[i] = (a[i] * pow[len-i] + t[i+1])%2019;
	}
	c[0]++;
	for(i = len; i>=1; i--){
		if(c[t[i]]) cnt+=c[t[i]];
		c[t[i]]++;
	}
    printf("%lld\n",cnt);
    return 0;
}

Measured memory_bytes: 4188
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a = [int(i) for i in readline().split()]
a.sort()
print(sum(a[:2]))

Measured memory_bytes: 3060
import java.util.*;
public class Main{
    public static int twoStacks(int x, int[] a, int[] b) {
        int a_index = 0;
        int b_index = 0;
        int count = 0;
        int sum = 0;
        // move b_index to the position where if only take elements from B, last element it can take
        while (b_index < b.length && sum + b[b_index] <= x) {
            sum += b[b_index];
            b_index++;
        }
        // loop exits only when b_index reaches end or sum > x; in both case b_index should decrease
        b_index--;
        count = b_index + 1;
 
        while (a_index < a.length && b_index < b.length) {
            sum += a[a_index];
            if (sum > x) {
                while (b_index >= 0) {
                    sum -= b[b_index];
                    b_index--;
                    if (sum <= x) break;
                }
                // if even no elements taken from B, but still sum greater than x, then a[a_index] should not be chosen
                // and loop terminates
                if (sum > x && b_index < 0) {
                    a_index--;
                    break;
                }
            }
            count = Math.max(a_index + b_index + 2, count);
            a_index++;
        }
 
        return count;
    }
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int k = sc.nextInt();
      int[] arr1 = new int[n];
      int[] arr2 = new int[m];
      for(int i=0;i<n;i++){
        arr1[i]=sc.nextInt();
      }
      for(int j=0;j<m;j++){
        arr2[j]=sc.nextInt();
      }
      System.out.println(twoStacks(k,arr1,arr2));
      }
  }


Measured memory_bytes: 60980
import math
a, b, C = map(float, input().split())
print('{0:.8f}'.format(0.5*a*b*math.sin(math.radians(C))))
print('{0:.8f}'.format(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(C)))))
print('{0:.8f}'.format(b*math.sin(math.radians(C))))

Measured memory_bytes: 7720
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int k;
	cin >> k;
	if (k % 2 == 0) {
		cout << k * k / 4 << endl;
	}
	else {
		cout << (k + 1) / 2 * (k / 2) << endl;
	}

}

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

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

    int gcd1[100000], gcd2[100000];
    gcd1[0] = A[0];
    for(int i=1;i<N;i++){
        gcd1[i] = __gcd(gcd1[i-1], A[i]);
    }
    gcd2[N-1] = A[N-1];
    for(int i=N-2;i>=0;i--){
        gcd2[i] = __gcd(gcd2[i+1], A[i]);
    }

    // 選ばないもの
    int g, ans = 0;
    for(int i=1;i<N-1;i++){
        g = __gcd(gcd1[i-1], gcd2[i+1]); 
        if(g > ans)
            ans = g;
    }

    cout << max ({ gcd1[N-2] , gcd2[1] , ans }) << endl;
    

}

Measured memory_bytes: 1408
S = input()
N = len(S)

ans = 0
for i in range(2 ** (N - 1)):
    signs = bin(i)[2:].zfill(N - 1).replace('0', '+').replace('1', '-')

    tmp_s = S[0]
    for j, sign in enumerate(signs):
        tmp_s += sign + S[j + 1]

    if eval(tmp_s) == 7:
        print(tmp_s + '=7')
        exit()


Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x;

		for(int i=1;i<=n;i++) {
			x =i;
			if(CHECK_NUM(x)) continue;
			if(INCLUDE3(x,i)) continue;
		}
		System.out.println();
		scan.close();
	}

	static boolean CHECK_NUM(int n) {
		if(n%3 == 0) {
			System.out.print(" "+n);
			return true;
		}
		return false;
	}

	static boolean INCLUDE3(int n,int i) {
		if(n%10 == 3) {
			System.out.print(" "+i);
			return true;
		}
		n/=10;
		if(n!=0) INCLUDE3(n,i);
		return false;
	}
}


Measured memory_bytes: 32748
package main

import (
	"fmt"
)

func gcd(a,b int)int{
	if b == 0{
		return a
	}
	return gcd(b, a%b)
}

func main() {
	var a,b,c,d int
	fmt.Scan(&a,&b,&c,&d)

	bc := b / c
	bd := b / d
	be := gcd(c,d)
	bf := c*d/be
	bg := b/bf
	
	A := a-1
	ac :=  A/ c
	ad := A / d
	ae := gcd(c,d)
	af := c*d/ae
	ag := A/af
	

	ans := b - bc-bd+bg -(A-ac-ad+ag)
	fmt.Println(ans)
}

Measured memory_bytes: 512
N,K=gets.split.map(&:to_i)
P=gets.split.map(&:to_i)
dp=Array.new(N+1){1e9}
dp[0]=0
P.each do |i|
  (K-1).downto(0) do |j|
    dp[j+1]=[dp[j+1],dp[j]+i].min
  end
end
p dp[K]

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

long long n, l;
vector<long long> a;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}
string po = "Possible";
string im = "Impossible";

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> l;
	readVector(n, a);
/*	if(a[0] + a[1] >= l){
		cout << po << "\n";
		for(int i=n-1; i>0; --i)
			cout << i << "\n";
	}else if(a[n-1] + a[n-2] >= l){
		cout << po << "\n";
		for(int i=1; i<n; ++i)
			cout << i << "\n";
	}else{
		cout << im << "\n";
	}
*/
	long long ma = -1e18;
	int k = -1;
	for(int i=1; i<n; ++i){
		if(a[i-1] + a[i] > ma){
			ma = a[i-1] + a[i];
			k = i;
		}
	}
	if(ma >= l){
		cout << po << "\n";
		for(int i=1; i<k; ++i)
			cout << i << "\n";
		for(int i=n-1; i>k; --i)
			cout << i << "\n";
		cout << k << "\n";
	}else{
		cout << im << "\n";
	}
}

Measured memory_bytes: 1780
# https://atcoder.jp/contests/abc047/tasks/arc063_a
# 連長圧縮すれば簡単
# 圧縮後の文字列長-1となる


def run_length_encoding(s):
    '''連長圧縮を行う
    s ... iterable object e.g. list, str
    return
    ----------
    s_composed,s_num,s_idx
    それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
    s_composed, s_sum = [], []
    s_idx = [0]
    pre = s[0]
    cnt = 1
    for i, ss in enumerate(s[1:], start=1):
        if pre == ss:
            cnt += 1
        else:
            s_sum.append(cnt)
            s_composed.append(pre)
            s_idx.append(i)
            cnt = 1
            pre = ss
    s_sum.append(cnt)
    s_composed.append(pre)
    # assert len(s_sum) == len(s_composed)
    return s_composed, s_sum, s_idx


# def run_length_encoding(s):
#     '''連長圧縮を行う
#     s ... iterable object e.g. list, str
#     return
#     ----------
#     s_composed,s_num,s_idx
#     それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
#     from itertools import groupby
#     s_composed, s_sum = [], []
#     s_idx = [0]
#     for k, v in groupby(s):
#         s_composed.append(k)
#         n = len(list(v))
#         s_sum.append(n)
#         s_idx.append(s_idx[-1] + n)

#     # assert len(s_sum) == len(s_composed)
#     return s_composed, s_sum, s_idx


S_composed, _, _ = run_length_encoding(input())
print(len(S_composed) - 1)


Measured memory_bytes: 14380
N, K = map(int, input().split())
*A, = map(int, input().split())
A.sort()

S = sum(A)
candidates = []
for i in range(1, int(S**0.5)+1):
    if S%i:continue
    a, b = i, S//i
    
    candidates.append(a)
    if a!=b:
        candidates.append(b)
candidates.sort()

ans = 0
for d in candidates:
    rems = []
    rems_size, rems_sum = 0, 0

    for i in A:
        if i%d:
            rems.append(i%d)
            rems_size += 1
            rems_sum += i%d

    rems.sort()

    a = 0
    for i, j in enumerate(rems[:-1], start=1):
        a += j
        b = d*(rems_size-i)-(rems_sum-a)
        if max(a, b)<=K:
            ans = max(ans, d)
    if not rems:
        ans = max(ans, d)

print(ans)

Measured memory_bytes: 3064
H,W=map(int,input().split())
S=[]
for i in range(H):
    S.append(input())

L = [[0 for i in range(W)] for j in range(H)]
R = [[0 for i in range(W)] for j in range(H)]
U = [[0 for i in range(W)] for j in range(H)]
D = [[0 for i in range(W)] for j in range(H)]

ans=0

for i in range(H):
    for j in range(W):
        if S[i][j]=='.':
            if j==0:
                L[i][j]=1
            else:
                L[i][j]=L[i][j-1]+1
        if S[i][-j-1]=='.':
            if j==0:
                R[i][-j-1]=1
            else:
                R[i][-j-1]=R[i][-j]+1
        if S[i][j]=='.':
            if i==0:
                U[i][j]=1
            else:
                U[i][j]=U[i-1][j]+1
        if S[-i-1][j]=='.':
            if i==0:
                D[-i-1][j]=1
            else:
                D[-i-1][j]=D[-i][j]+1
for i in range(H):
    for j in range(W):
        ans = max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
print(ans)


Measured memory_bytes: 184196
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end(), l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}

signed main(){
  int n,k,a[100000];
  cin>>n>>k;
  for(int i=0;i<n;i++) cin>>a[i];
  cout<<(n+k-3)/(k-1)<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<string>
#include<bitset>
#include<queue>
using namespace std;


int main() {
	int N;
	cin >> N;
	long long pickup_sum = 0;
	vector<int> cnt(N, 0);
	int A[200050];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		pickup_sum += cnt[A[i]];
		cnt[A[i]]++;
	}
	for (int i = 0; i < N; i++) {
		long long ans = pickup_sum - cnt[A[i]] + 1;
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 4364
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2014

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

#define MAX 52

char area[MAX][MAX];
int ans[MAX][MAX];
int visit[MAX][MAX];
int W,H;

void init()
{
	fill_n((char *)area, sizeof(area) / sizeof(char), '.');
	fill_n((int *)ans, sizeof(ans) / sizeof(int), 0);
	fill_n((int *)visit, sizeof(visit) / sizeof(int), 0);
}

void clear(){
	fill_n((int *)visit, sizeof(visit) / sizeof(int), 0);
}

void dfs(int x, int y, char color)
{
	int mark = (color == 'W') ? 1 : 2;
	char rival  = (color == 'W') ? 'B':'W';

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

	if(x < 0 || x >= W || y < 0 || y >= H){ return; }
	if(area[y][x] == rival){ return; }

	if(!visit[y][x])
	{
		visit[y][x] = 1;
		if(area[y][x] != 'W' && area[y][x] != 'B'){ ans[y][x] |= mark; }

		rep(i,4){ dfs(x+dx[i], y+dy[i], color); }
	}

	return;
}

int main()
{

	while(cin >> W >> H && W)
	{
		int black=0, white=0;
		init();

		rep(h,H){
			rep(w,W){
				cin >> area[h][w];
			}
		}

		rep(h,H){
			rep(w,W){
				if(area[h][w] != '.'){ 
					clear();
					dfs(w,h,area[h][w]); 
				}
			}
		}
		
		rep(h,H){
			rep(w,W)
			{
				int num = ans[h][w];
				if(num == 1){ white++; }
				if(num == 2){ black++; }
			}
		}

		cout << black << " " << white << endl;

	}
	return 0;
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
using namespace std;
//char型から数値型に変換する関数（z.at(i)などに使用）
int ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
int main() {
  int64_t d;
  cin>>d;
  if(d==22){
    cout<<"Christmas"<<" "<<"Eve"<<" "<<"Eve"<<" "<<"Eve";
  }
  if(d==23){
    cout<<"Christmas"<<" "<<"Eve"<<" "<<"Eve";
  }
  if(d==24){
    cout<<"Christmas"<<" "<<"Eve";
  }
  if(d==25){
    cout<<"Christmas";
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long X[] = new long[N];
		HashMap<Long, Long> a = new HashMap<Long, Long>(), //番号が何個
				b = new HashMap<Long, Long>();//番号とその組み合わせ
		for (int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
			if (!a.containsKey(X[i])) {
				a.put(X[i], (long)1);
			} else {
				a.put(X[i], a.get(X[i]) + 1);
			}
		}
		long sum = 0, ans = 0;
		for (long i : a.keySet()) {
			b.put(i, a.get(i) * (a.get(i) - 1) / 2);
			sum += a.get(i) * (a.get(i) - 1) / 2;
		}
		for (int i = 0;i<N;i++) {
			ans = sum - b.get(X[i]) + (a.get(X[i]) - 1) * (a.get(X[i]) - 2) / 2;
			System.out.println(ans);
		}
		//System.out.println();
		sc.close();

	}

}

Measured memory_bytes: 82024
#include<bits/stdc++.h>
#define int long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define REP_sz(i,s) for(int i=0;i<s.size();i++)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define pb push_back
#define sz(a) a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define msit1(a) map<string,int>::iterator a
#define miit(a) map<int,int>::iterator a
#define msit2(a) map<int,string>::iterator a
#define IT iterator
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define B(s) s.back()
#define all(a) a.begin(),a.end()
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
using namespace std;
signed main(){
    int n,m;
    cin>>n>>m;
    V<pii>a(m);
    REP(i,0,m){
    	cin>>a[i].second>>a[i].first; 
	}
	SO(a);
	int ans=0,t=0;
	REP(i,0,m){
		if(a[i].second>=t){
			ans++;
			t=a[i].first;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4848
#include<stdio.h>
#include<math.h>

int isprime(int x){
	int i;
	if(x == 2){
		return 1;
	}
	if(x < 2 || x%2 == 0){
		return 0;
	}
	i = 3;
	while(i <= sqrt(x)){
		if(x%i == 0){
			return 0;
		}
		i += 2;
	}
	return 1;
}

int main(void){
	int a;
	int b=0, n, i;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &a);
		if(isprime(a) == 1){
			b++;
		}
	}
	printf("%d\n", b);
	return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<double,ll> P;


int main(){
	int a,b;cin >> a >> b;cout << a - b + 1<< endl;
	return 0;
}


Measured memory_bytes: 256