akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(1000000)

a =int(input())
B =list(input())

def dfs(x):
    
    C =B[x]
    B[x] = "."
    nx = x + 1
    if nx >= 0 and nx <= a-1 and B[nx] == C:
        dfs(nx)

res = 0
for i in range(a):
        if B[i] != ".":
            # Wが残っているならそこから dfs をはじめる
            dfs(i)
            res += 1
print(res)

Measured memory_bytes: 89724
#include<stdio.h>

int main()
{
    //FAST;

    char s[1];
    gets(s);
    if(s[0]>='a' && s[0]<='z')
    {
        //cout<<"a"<<endl;
        printf("a\n");
    }

    else
    {
       // cout<<"A"<<endl;
        printf("A\n");
    }


    return 0;
}



Measured memory_bytes: 1516
#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pii pair<int,int>

using namespace std;
const int N=2e5+10;

int main()
{
    int n, p[N], ans=1;
	LL K;

	cin>>n;
	vector<int> flag(n+1,0);
	
	rep(i,n) {
		int x;
		cin>>x;
		if(x==1) {flag[1]=1;continue;}
		flag[x]=flag[x-1]+1;
		ans=max(ans,flag[x]);
	}
	
	cout<<n-ans;
		
	rt0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>


using namespace std;


using ll = long long;


ll search(vector<ll> &v, ll k)
{
    ll l, r, m;
    l = 0;
    r = v.size();

    while (l < r) {
        m = (l + r) / 2;
        if (v[m] == k) {
            return m;
        }
        if (k < v[m]) {
            r = m;
        } else {
            l = m + 1;
        }
    }
    return -1;
}


int main()
{
    ll n, q;
    cin >> n;
    vector<ll> S(n);

    for (ll i = 0; i < n; i++)
        cin >> S[i];

    cin >> q;
    ll ans = 0;
    for (ll i = 0; i < q; i++) {
        ll tmp;
        cin >> tmp;

        if (search(S, tmp) >= 0) {
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3540
N,X,M=map(int, input().split())
m=[0]*M
t={}

def f(x,y):
    return x*x % y
a = X
s=0
for i in range(N):
    if a in t:
        x = t[a]
        nn = N - x
        q,r = divmod(nn,i-x)
        s = m[x-1] + (m[i-1] - m[x-1])*q + m[x-1+r] - m[x-1]
        break
    t[a]=i
    s += a
    m[i] = s
    a = f(a,M)
print(s)

Measured memory_bytes: 17948
#include<iostream>
using namespace std;
int main(){
  int A,B,C;
  int sum=0;
  int count=0;
  cin >> A >> B >> C;
  if(C<=A){
    cout << 1 << endl;
  }else{
      while(C>0){
        count++;
        if(count%7!=0){
          //sum+=A;
          C=C-A;
        }else{
          //sum+=B+A;
          C=C-(A+B);
        }
      }
      cout << count << endl;
  }
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, N) for(int i{};i<N;i++)
using namespace std;
int M = 1e9+7;
int p[100001][13];
string S;
int d(int n){
  return (13 + n%13)%13;
}
void f(int &i, int j, int &l){
  int k{};
  k = l + d(j*(i%3==0?1:i%3==1?10:100)) * (1-i/3%2*2);
  (p[i+1][d(k)] += p[i][l]) %= M;
}
int main(){
  cin >> S;
  reverse(S.begin(), S.end());
  p[0][0] = 1;
  rep(i, S.size()) rep(l, 13){
    if(S[i] == '?') rep(j, 10) f(i, j, l);
    else f(i, S[i] - '0', l);
  }
  cout<<p[S.size()][5]<<"\n";
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;



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

    int h,w;
    cin >> h >> w;

    int sx,sy,gx,gy;
    cin >> sy >> sx >> gy >> gx;
    sx--;sy--;gx--;gy--;

    pair<int,int> s = make_pair(sx,sy), g = make_pair(gx,gy); 
    vector<vector<int>> ans(h,vector<int>(w,mod));
    string sur[h];

    for(int i = 0; i < h; i++) cin >> sur[i];

    auto inout = [&](int x,int y){
        if(0 <= x && x < w && 0 <= y && y < h) return true;
        else return false;
    };

    auto add = [&](pair<int,int> now,int dx,int dy){
        pair<int,int> ret = make_pair(now.first+dx,now.second+dy);
        return ret;
    };

    auto answer = [&](pair<int,int> now){
        if(now == g){
            cout << ans[now.second][now.first] << endl;
            return true;
        } else return false;
    };

    queue<pair<int,int>> p,q;

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

    p.push(s);
    ans[s.second][s.first] = 0;

    int can = 0;

    while(!p.empty()){
        while(!p.empty()){
            pair<int,int> now = p.front();
            p.pop();
            q.push(now);
            bool first = true;
            for(int i = 0; i < 4; i++){
                pair<int,int> nxt = add(now,dx[i],dy[i]);
                if(inout(nxt.first,nxt.second)){
                    if(sur[nxt.second][nxt.first] == '.'){
                        ans[nxt.second][nxt.first] = can;
                        if(answer(nxt)) return 0;
                        p.push(nxt);
                        sur[nxt.second][nxt.first] = '#';
                    }
                }
            }
        }
        can++;
        while(!q.empty()){
            pair<int,int> now = q.front();
            q.pop();
            for(int i = -2; i < 3; i++){
                for(int j = -2; j < 3; j++){
                    pair<int,int> nxt = make_pair(now.first+i,now.second+j);
                    if(inout(nxt.first,nxt.second)){
                        if(sur[nxt.second][nxt.first] == '.'){
                            ans[nxt.second][nxt.first] = can;
                            p.push(nxt);
                            sur[nxt.second][nxt.first] = '#';
                            if(answer(nxt)) return 0;
                        }
                    }
                }
            }
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 8660
#include<bits/stdc++.h>
using namespace std; 
#define IOS ios::sync_with_stdio(0);
signed main()
{
	//IOS
	double d;
	while(cin>>d)
	{
		printf("%.10lf\n",(d/3)*(d/3)*(d/3));
	}
 } 

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

int main(){
  string S1,S2;
  cin >> S1;

  int count=0;
  for(int i=0;i<S1.size();i++){
    S2 +=S1.at(S1.size()-1-i);
    if(S1.at(i)!=S2.at(i)){
      count++;
    }
  }
  cout << count/2 << endl;
}


Measured memory_bytes: 256
from sys import stdin
h,w,b,a = map(int,stdin.readline().rstrip().split())
li = []
for i in range(a):
    s = "0"*b+"1"*(w-b)
    li.append(s)
for j in range(h-a):
    s = "1"*b+"0"*(w-b)
    li.append(s)
for i in li:
    print(i)

Measured memory_bytes: 4980
import unittest


class TestA(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think('oder', 'atc'), 'atcoder')

    def test_2(self):
        self.assertEqual(think('humu', 'humu'), 'humuhumu')


def solve():
    s, t = read()
    result = think(s, t)
    write(result)


def read():
    return read_line().split()


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(s, t):
    return t + s


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()


Measured memory_bytes: 6092
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end() 
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define forn(i, n) for(int i=0;i<(n);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
template<class _Tp>
class fenwick {
	vector<_Tp> v;
	int size;
	public:
	class iterator {
		int pos;
		fenwick<_Tp>* p;
		public:
		iterator(fenwick<_Tp>* p_, int pos_) : p(p_), pos(pos_) {}
		iterator operator+=(const _Tp value) { p->update(value, pos); return *this;}
		iterator operator=(const _Tp value) {p->update(p->sum(pos-1)-p->sum(pos), pos); p->update(value, pos); return *this;}
		operator _Tp() const {return p->sum(pos)-p->sum(pos-1);}
	};
	void assign(int size_) {
		size = size_;
		v.assign(size+1, 0);
	}
	fenwick(int size_=0) : size(size_) { assign(size_); }
	void update(_Tp value, int i) {
		assert(i<size);
		for(++i;i<=size;i+=i&-i) v[i] += value;
	}
	_Tp sum(int i) {
		assert(i<size);
		if(i <= -1) return 0;
		if(i >= size) i = size-1;
		_Tp psum = 0;
		for(++i;i>0;i-=i&-i) psum += v[i];
		return psum;
	}
	fenwick<_Tp>::iterator operator[](int pos) {
		assert(pos<size);
		return fenwick<_Tp>::iterator(this, pos);
	} 
};

int main() {
	fastio;
	int n; string s;
	cin >> n >> s;
	s = '#'+s;
	fenwick<int> cnt[26];
	forn(i, 26) cnt[i].assign(n+1);
	
	for(int i=1;i<=n;i++) {
		cnt[ s[i] - 'a' ][i] += 1;
	}
	int q; cin >> q;
	while(q--) {
		int a;
		cin >> a;
		if(a == 1) {
			int i; char c;
			cin >> i >> c;
			cnt[s[i] - 'a'][i] += -1;
			s[i] = c;
			cnt[s[i] - 'a'][i] += 1;
		} else {
			int l, r;
			cin >> l >> r;
			int count = 0;
			forn(i, 26) if(cnt[i].sum(r) - cnt[i].sum(l-1) > 0) count++;
			cout << count << endl;
		}
	}
}

Measured memory_bytes: 51760
#include <iostream>

using namespace std;

int main()
{
	char a[3];
  	char b[3];
  	cin >> a >> b;
  	for (int i = 0; i < 3; i++){
    	if (a[i] != b[2 - i]){
        	cout << "NO";
          	return 0;
        }
    }
  	cout << "YES";
}


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

int main() {
    int N, x;
    cin >> N >> x;
    if(x == 1 || x == 2 * N - 1) cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        int a = x - N + 1;
        if(a <= 0) a += (2 * N - 1);
        rep(i, 0, 2 * N - 1) {
            if(a == 2 * N) a = 1;
            cout << a++ << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int x;
    cin >> x;
    int count500 = 0;
    int count50 = 0;
    while (x >= 500) {
        x -= 500;
        count500++;
    }
    while (x >= 5) {
        x -= 5;
        count50++;
    }
    cout << count500 * 1000 + count50 * 5 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

struct edge_t {
	int from;
	int to;
	int c;
};

typedef struct edge_t Edge;

int main(void) {
	int num,i,m,from,to,c,up;
  int nedge = 0;
	int dis[10000];
	Edge *edges, *p;

	edges = malloc(sizeof(Edge)*500000);

	scanf("%d", &num);

	for (i=0; i<num; i++) {
		scanf("%d %d", &from, &m);

		while (m--) {

			scanf("%d %d", &to, &c);

			p = &edges[nedge++];
			p->from = from;
			p->to = to;
			p->c = c;
		}

		dis[i] = INT_MAX;
	}
	dis[0] = 0;

	up = 1;
	while (up) {
		up = 0;
		for (i = 0; i < nedge; i++) {
			from = edges[i].from;
			to = edges[i].to;
			c = edges[i].c;
			if (dis[from] < INT_MAX && dis[to] > c + dis[from]) {
				dis[to] = c + dis[from];
				up = 1;
			}
		}
	}

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

  return 0;
  
}




Measured memory_bytes: 7580
#include <iostream>
using namespace std;
    
int main (){
     int a;
    
    cin >> a;
    if (a<1200){
        cout << "ABC" << endl;
        }  
    if (a>=1200&&a<2800){
        cout << "ARC" << endl;
        }
    if (a>=2800){
        cout << "AGC" << endl;
        }
    
    }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  int yakusu=0;

  cin >> a >> b >> c;

  while(a <= b){

    if(c%a == 0){

      yakusu++;

    }

    a++;
  }

  cout << yakusu << "\n";
}

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

const ll int INF = 1e18 + 5;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n,m;
    cin>>n>>m;
    ll int dp[n][m] = {0};
    ll int mod = 1e9 + 7;
    dp[0][0] = 1;
    for(ll int i=0;i<n;i++){
    	for(ll int j=0;j<m;j++){
    		char x;
    		cin>>x;
    		if(i==0&&j>0)
    			dp[i][j] = dp[i][j-1];
    		if(i>0&&j==0)
    			dp[i][j] = dp[i-1][j];
    		else if(i>0 && j>0)
    			dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
    		if(x == '#')
    			dp[i][j] = 0;
    		// cout<<dp[i][j]<<" ";
    	}
    	// cout<<endl;
    }
    cout<<dp[n-1][m-1];
	return 0;
}

Measured memory_bytes: 8064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

x=I()
pr=100
for i in range(100000):
    pr=(pr*101)//100
    if pr>=x:
        print(i+1)
        sys.exit()

Measured memory_bytes: 67848
#include<stdio.h>

int main(void)
{

 int x, y, z, tmp;

 scanf("%d %d", &x, &y);

 if(x < y){

  tmp = x;

  x = y;

  y = tmp;

 }

 z = x % y;

 while(z!=0){

  x = y;

  y = z;

  z = x % y;

 }

 printf("%d\n", y);

 return 0;

}

Measured memory_bytes: 1800
#!/usr/bin/env python3
import sys


def solve(N: int, S: str, T: str):
    result = ""
    for i in range(N):
        result += S[i]+T[i]
    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(N, S, T)


if __name__ == '__main__':
    main()


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

struct Node {
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = new Node;
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x-> key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

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

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

int main() {
  int n;cin>>n;
  Node T[n];

  rep(i, n) {
    string cmd; cin>> cmd;
    if (cmd == "insert") {
      int key; cin >> key;
      insert(key);
    } else {
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 26584
#include <bits/stdc++.h>
using namespace std ;
#define An setprecision(16) 
int main(){
    int  N;
    cin >> N;
    if(N%2==0){
        double Ans = 1.0/2;
        cout << An << Ans <<endl;
    }else{
        double Ans = (((double)N+1.0)/2)/(double)N;
        cout << An << Ans <<endl;
    }
}

Measured memory_bytes: 3812
/**
 *    author: Behradm
 *    Created: 14.06.2020 16:35:47
 *    In the Name of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  set<int> p;
  int x, n;
  cin >> x >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    p.insert(a);
  }

  for (int i = 0; i <= 100; i++) {
    int v = x - i;
    if (p.find(v) == p.end()) {
      cout << v << '\n';
      return 0;
    }

    v = x + i;
    if (p.find(v) == p.end()) {
      cout << v << '\n';
      return 0;
    }
  }
  return 0;
}




Measured memory_bytes: 3656
N=int(input())
s=input()
t=input()
ans=2*N
for i in reversed(range(1,N+1)):
    sl=s[-i:];tf=t[:i]
#    print(f'sl={sl},tf={tf}')
    if sl==tf:
        ans=2*N-i
        break
print(ans)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dp[5005][5005];

void Main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    rep(i, N) {
        rep(j, N) {
            if (S[i] == S[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
        }
    }
    ll ans = 0;
    rep(i, N + 1) {
        rep(j, N + 1) {
            if (i + dp[i][j] - 1 < j) {
                ans = max(ans, dp[i][j]);
            }
        }
    }
    cout << ans << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 195840
s = input()
ans = 0
cnt1, cnt2 = 0, 0
a = []
if s[0] == '>':
    a.append(0)
for c in s:
    if c == '<':
        if cnt2:
            a.append(cnt2)
            cnt2 = 0
        cnt1 += 1
    else:
        if cnt1:
            a.append(cnt1)
            cnt1 = 0
        cnt2 += 1
if cnt1:
    a.append(cnt1)
else:
    a.append(cnt2)
if len(a) % 2:
    a.append(0)
for i in range(1, len(a), 2):
    ans += ((a[i] - 1) * a[i] + (a[i - 1] - 1) *
            a[i - 1]) // 2 + max(a[i], a[i - 1])
print(ans)


Measured memory_bytes: 6300
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		scan.close();

		if(a < b && b < c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 17296
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n,i,k,j;
  cin>>n>>k;int a[n+1],dp[n+1];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  dp[0]=0;dp[1]=abs(a[1]-a[0]);
  for(i=2;i<n;i++)
  {
    j=2;
    dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
    while(i-j>=0&&j<k+1){
    dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
    j++;
    }
  }
  cout<<dp[n-1];
  return 0;
}
    

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

using namespace std;

typedef long long ll;

int check_connection(vector<vector<int>> &s, int i, int j) {
    int count = 0;
    if(i >= 1) count += s[i-1][j];
    if(i <= s.size() - 2)  count += s[i+1][j];
    if(j >= 1) count += s[i][j-1];
    if(j <= s.size() - 2)  count += s[i][j+1];
    return count;
}

int main() {
    int H, W;
    cin >> H >> W;

    string str;
    vector<vector<int>> s(H, vector<int>(W, 0));
    for(int i = 0; i < H; i++) {
        cin >> str;
        for(int j = 0; j < W; j++) {
            s[i][j] = str[j] == '#' ? 1 : 0;
        }
    }

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(s[i][j] == 0) continue;
            if(check_connection(s, i, j) == 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

}

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

using namespace std;
int A[1<<20];
int main() {
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cin>>A[i];

    int counter = 0;

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

            if(A[i] > i and A[A[i]] == i) counter++;



        }  cout<<counter;
   return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> L(N);

    int D = 0;
    int count = 1;
    rep(i,N){
        cin >> L[i];
        D += L[i];
        if(D <= X){
            count++;
        }else{
            break;
        }
    }

    cout << count << endl;

}

Measured memory_bytes: 256
N = int(input())

if 400 <= N <= 599:
    print(8)
elif 600 <= N <= 799:
    print(7)
elif 800 <= N <= 999:
    print(6)
elif 1000 <= N <= 1199:
    print(5)
elif 1200 <= N <= 1399:
    print(4)
elif 1400 <= N <= 1599:
    print(3)
elif 1600 <= N <= 1799:
    print(2)
elif 1800 <= N <= 1999:
    print(1)


Measured memory_bytes: 9116
extern crate proconio;
use proconio::input;

fn main() {
    input! {
        mut x: i64,
        k: i64,
        d: i64,
    }
    if x < 0 {
        x = x * (-1);
    }
    if x / d >= k {
        println!("{}", x - k * d);
        return;
    }
    let y = x % d;
    println!("{}", if (k - x / d) % 2 == 0 { y } else { d - y });
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int a,b,c; cin>>a>>b>>c;
  cout << min({a+b,a+c,b+c}) << endl;
}

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


Measured memory_bytes: 256
#!/usr/bin/pypy
import math
a, b, x = map(float, raw_input().split())

V= a * a * b

if x > V/2:
    print(math.degrees(math.atan(2.0 * (V - x) /a/a/a)))
else:
    print(math.degrees(math.atan(a*b*b/2.0/x)))

Measured memory_bytes: 27884
#include <cstdio>

int main()
{
	int a = 0;
	int n = 0;
	while (scanf("%d", &a) != EOF) {

		n = a % 39;
		if (n == 0) {
			n = 39;
		}
 
		if (n < 10) {
			printf("3C0%d\n", n);
		}
		else {
			printf("3C%d\n", n);
		}
	}
    return 0;
}

Measured memory_bytes: 2648
#include<iostream>
using namespace std;
int main()
{
	int x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	cout<<(x2-(y2-y1))<<" "<<(y2+(x2-x1))<<" "<<(x1-(y2-y1))<<" "<<(y1+(x2-x1))<<endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll c;
    cin >> c;
    vector<ll> dp(n), h(n);
    rep(i, 0, n) cin >> h[i];
    vector<pair<ll, ll>> dq = {{-h[0] * 2, h[0] * h[0]}};
    int s = 0, t = 1;  // t = dq.size();
    rep(i, 1, n) {
        dp[i] = h[i] * h[i] + c;
        while (s < t - 1 && dq[s + 1].first * h[i] + dq[s + 1].second <= dq[s].first * h[i] + dq[s].second) {
            s++;
        }
        dp[i] += dq[s].first * h[i] + dq[s].second;
        pair<ll, ll> p = {-h[i] * 2, h[i] * h[i] + dp[i]};
        while (t > 1 && (dq[t - 1].first - p.first) * (dq[t - 2].second - p.second) <= (p.first - dq[t - 2].first) * (p.second - dq[t - 1].second)) {
            dq.pop_back();
            t--;
        }
        t++;
        dq.emplace_back(p);
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 9328
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

using namespace std;

#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

typedef long long ll;
const int Mod = static_cast<int>(1e9 + 7);

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int ns[10];
	rep(i, n)  ns[i] = s[i] - '0';

	ll ans = 0;
	for (int bit = 0; bit < (1 << (n - 1)); bit++) {
		ll t = ns[0];
		ll tsum = 0;
		for (int i = 0; i < n - 1; i++) {
			if (bit & (1 << i)) {
				tsum += t;
				t = ns[i + 1];
			}
			else {
				t = t * 10 + ns[i + 1];
			}
		}
		tsum += t;
		ans += tsum;
	}
	cout << ans << endl;
}

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

int isPrime(int);

int main(){
  int i,j;

  int n,cnt=0;


  scanf("%10000d",&n);
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]<2 || A[i]>100000000){
      continue;
    }


    
    cnt += isPrime(A[i]);

  


  }
 
  //output
  printf("%d\n",cnt);


  return 0;
}
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 = i + 2;
    }
    return 1;
    }



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

int main(){ 
  int k;
  cin >> k;
  string s;
  cin >> s;
  int n = s.length();
  if (n <= k) {
    cout << s << endl;
  } else {
    cout << s.substr(0, k);
    cout << "..." << endl;
  }
  return 0;
} 

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    int a[n], b[m];
    rep(n) cin >> a[i];
    rep(m) cin >> b[i];

    bool war = true;
    for(int i=*max_element(a, a+n)+1; i<=*min_element(b, b+m); i++){
        if(x < i && i<= y){
            war = false;
            break;
        }
    }

    if(!war){
        cout << "No ";
    }
    cout << "War\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  int ans = 0;

  int n; cin >> n;
  vector<int> seq0(n / 2), seq1(n / 2);
  rep(i, n / 2) cin >> seq0[i], cin >> seq1[i];

  int max0 = 0, max2, max1 = 0, max3, hmt0 = 0, hmt2, hmt1 = 0, hmt3;
  map<int, int> app0, app1;
  rep(i, n / 2) app0[seq0[i]]++, app1[seq1[i]]++;
  set<int> sseq0, sseq1;
  rep(i, n / 2) sseq0.insert(seq0[i]), sseq1.insert(seq1[i]);
  for (auto x : sseq0){
    if (hmt0 <= app0[x]) hmt2 = hmt0, max2 = max0, hmt0 = app0[x], max0 = x;
    else if (hmt2 <= app0[x]) hmt2 = app0[x], max2 = x;
  }
  for (auto x : sseq1){
    if (hmt1 <= app1[x]) hmt3 = hmt1, max3 = max1, hmt1 = app1[x], max1 = x;
    else if (hmt3 <= app1[x]) hmt3 = app1[x], max3 = x;
  }
  if (max0 != max1) ans = n - hmt0 - hmt1;
  if (max0 == max1){
    if (hmt2 >= hmt3) ans = n - hmt1 - hmt2;
    if (hmt2 < hmt3) ans = n - hmt0 - hmt3;
  }
  
  cout << ans << endl;
  return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;

  int N = (int)S.length();
  REP(i, N / 2) {
    if (S[i] != S[N - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  REP(i, (N - 1) / 2) {
    if (S[i] != S[(N - 1) / 2 - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  REPI(i, 3, N) {
    if (S[i] != S[N - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

struct HeavyLight {
  vector<vector<int> > len, tree;
  int pathCount,n;
  vector<int>size,parent,in,out,path,pathSize,pathPos,pathRoot;

  HeavyLight(vector<vector<int> >tree)
    :tree(tree),n(tree.size()),size(n),parent(n),in(n),out(n),
     path(n),pathSize(n),pathPos(n),pathRoot(n){
    int time=0;
    dfs(0,-1,time);
    buildPaths(0,newPath(0));
    //len.resize(pathCount);
    /*
    REP(i,pathCount){
      int m=pathSize[i];
      len[i].resize(2*m);
      fill(ALL(len[i]),0);
      fill(len[i].begin()+m,len[i].begin()+2*m,1);
      for(int j=2*m-1;j>1;j-=2)len[i][j>>1]=len[i][j]+len[i][j^1];
    }
    */
  }

  void dfs(int u, int p, int &k){
    in[u]=k++, parent[u]=p, size[u]=1;
    EACH(v,tree[u])if(*v!=p)dfs(*v, u, k),size[u]+=size[*v];
    out[u]=k++;
  }

  int newPath(int u){ pathRoot[pathCount]=u; return pathCount++; }

  void buildPaths(int u, int pt){
    path[u]=pt, pathPos[u]=pathSize[pt]++;
    EACH(v,tree[u])if(*v != parent[u])
      buildPaths(*v, 2*size[*v] >= size[u] ? pt : newPath(*v));
  }

  bool isAncestor(int p, int ch){
    return in[p] <= in[ch] && out[ch] <= out[p];
  }

  int lca(int a,int b){
    for(int root; !isAncestor(root=pathRoot[path[a]],b);a=parent[root]);
    for(int root; !isAncestor(root=pathRoot[path[b]],a);b=parent[root]);
    return isAncestor(a,b)?a:b;
  }
};


int main(void){
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<vector<int> >tree(n);
  
  REP(i,n){
    int k;
    cin >> k;
    REP(j,k){
      int ch;
      cin >> ch;
      tree[i].push_back(ch);
    }
  }

  HeavyLight hl = HeavyLight(tree);

  int q;
  cin >> q;
  while(q--){
    int u,v;
    cin >> u >> v;
    cout << hl.lca(u,v) << "\n";
  }
  
  return 0;
}

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

int main(){
    int N; cin >> N;
    int sum=0;
    vector<int> a(N), n(N);
    
    for(int i=0; i<N; i++) cin >> a.at(i);
    
    while(1){
        int flag=0;
        for(int i=0; i<N; i++){
            if(a.at(i)/2 != 0 && a.at(i)%2 == 0){
                a.at(i) /= 2;
                n.at(i)++;
                flag++;
            }
        }
        if(flag==0) break;
    }
    for(int i=0; i<N; i++) sum += n.at(i);
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 384
import sys
import itertools
import math
from heapq import heapify, heappop, heappush
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
xy = [IL() for i in range(N)]

ans = 0
for i in itertools.permutations(xy):
  for j in range(N-1):
    x1, y1 = i[j]
    x2, y2 = i[j + 1]
    ans += math.sqrt( (x1 - x2)**2 + (y1 - y2)**2 )
num = 1
for i in range(1, N+1):
  num *= i
print(ans/num)

Measured memory_bytes: 42092
s = input()

n = len(s)
a = "10" * (n // 2) + "1" * (n % 2)
b = "01" * (n // 2) + "0" * (n % 2)

print(min(bin(int(s, 2) ^ int(a, 2)).count("1"), bin(int(s, 2) ^ int(b, 2)).count("1")))

Measured memory_bytes: 3444
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{n:i64};
    let mut ans:i64 = 1;
    loop {
        if ans*2 > n {
            println!("{}", ans);
            return();
        }
        ans *= 2;
    }
}


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

int main(){
  long long n,k,s;
  cin >> n >> k;
  s=(0-((n+1)*(n+2)*(2*n+3)/6)%1000000007+((n+1)*(n+1)*(n+2)/2)%1000000007+n+1)%1000000007;
  s=(s+((k-1)*k*(2*k-1)/6)%1000000007-((n+1)*k*(k-1)/2)%1000000007-k+1)%1000000007;
  
  if(s<0){
    s=s+1000000007;
  }
  cout << s << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
 
 
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007

int main(){


    int n;
    while(cin >> n,n){
        ll count = 0;
        vector<ll> a(n),b(n,0);

        REP(i,n){
            cin >> a[i];
        }
        VSORT(a);

        b[0] = 0;
        for(int i = 1;i < n;i++){
            b[i] = b[i-1]+a[i-1];
        }
        REP(i,n){
            count += b[i];
        }
        cout << count << endl;
    }
    return 0;
}



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

int main() {
	string a , b;
	cin >> a >> b;
	if ( a == "H" && b == "H") cout << "H";
	if ( a == "H" && b == "D") cout << "D";
	if ( a == "D" && b == "H") cout << "D";
	if ( a == "D" && b == "D") cout << "H";
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/


int main(){
    string s; cin >> s;
    vector<int> a(4);
    for(int i=0; i<4; i++) a[i] = stoi(s.substr(i, 1));

    for(int bit = 0; bit<(1<<3); bit++){
        int tmp = a[0];
        string ans = to_string(a[0]);

        for(int i=0; i<3; i++){
            if(bit&(1<<i)){
                tmp += a[i+1];
                ans += '+';
                ans += to_string(a[i+1]);
            }
            else{
                tmp -= a[i+1];
                ans += '-';
                ans += to_string(a[i+1]);
            }
        }

        if(tmp == 7){
            cout << ans << "=7" << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>data(N);
  for(int i=0;i<N;i++)cin>>data[i];
  vector<int>ans(N);
  for(int i=0;i<N;i++){
    ans[data[i]-1]=i+1;
  }
  for(int i=0;i<N;i++)cout<<ans[i]<<" ";
  

}

Measured memory_bytes: 1536
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int a = int.Parse(Console.ReadLine());
		string s = Console.ReadLine();
		if(a >= 3200) Console.WriteLine(s);
    else Console.WriteLine("red");
	}
}

Measured memory_bytes: 11092
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
//string str;
long long L[1001],R[1001];
int N;
int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>L[i]>>R[i];
	}
	int A=0;
	for(int i=0;i<N;i++){
		A+=(R[i]-L[i]+1);
	}

	cout<<A<<endl;





	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int a[100];
bool solve(int i,int m){
    if(m == 0){
        return true;
    }
    if(i < 0){
        return false;
    }
    bool ret = solve(i - 1, m - a[i]) || solve(i - 1, m);
    return ret;
}

int main(){
    int n,q,b;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    cin >> q;
    for(int i = 0;i < q;i++){
        cin >> b;
        if(solve(n - 1,b)){
            cout << "yes" << endl;
        }
        else{
            cout << "no" << endl;
        }
    }
}



Measured memory_bytes: 3112
#include<stdio.h>
int main(){
	int M,D,Y;
	
	for(;;){
		scanf("%d%d", &M, &D);
		if(M==0 && D==0)break;
		for(;M>1;M--){
			D+=31;
			if(M==12 || M==10 || M==7 || M==5){
				D-=1;
			}
			if(M==3){
				D-=2;
			}
		}
		D%=7;
		switch(D){
			case 0:
				puts("Wednesday");
				break;
			case 1:
				puts("Thursday");
				break;
			case 2:
				puts("Friday");
				break;
			case 3:
				puts("Saturday");
				break;
			case 4:
				puts("Sunday");
				break;
			case 5:
				puts("Monday");
				break;
			case 6:
				puts("Tuesday");
				break;
		}
			
	}
	return 0;
}

Measured memory_bytes: 0
n , q =  list(map(int, input().split()))

Q = []
for i in range(n):
    Q.append([])

for i  in range(q):
    query = list(map(int, input().split()))
    if query[0] == 0:
        Q[query[1]].append(query[2])
    elif query[0] == 1:
        if bool(Q[query[1]]):
            print(Q[query[1]][0])
    elif query[0] == 2:
        if bool(Q[query[1]]):
            del Q[query[1]][0]


Measured memory_bytes: 13700
import java.util.*;
 
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int w = sc.nextInt();
		if(w>=s){
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}
	}
}


Measured memory_bytes: 27032
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

bool ok(const vector<int> &v) {
  int d = v[1]-v[0];
  for (int i=1; i<v.size()-1; ++i) {
    if (v[i+1]-v[i] != d) return 0;
  }
  return 1;
}

int a[10000];

int main() {
  int n;
  while(cin >> n, n) {
    REP(i,n+1) cin >> a[i];
    REP(i,n+1) {
      vector<int> v;
      REP(j,n+1) {
        if (i == j) continue;
        v.push_back(a[j]);
      }
      if (ok(v)) {
        cout << a[i] << endl;
        break;
      }
    }
  }
}

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

#define mod 1000000007
#define MAX_N 200010
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void GetInv(){
    for (int i = 1; i < MAX_N; i++) {
        if (i == 1) inv[i] = 1;
        else {
            inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
            if (inv[i] < 0) inv[i] += mod;
        }
    }
}
void GetFactorial(){
    factorial[0] = 1; inv_factorial[0] = 1;
    for (int i = 1; i < MAX_N; i++) {
        factorial[i] = factorial[i-1] * i;
        factorial[i] %= mod;
        inv_factorial[i] = inv_factorial[i-1] * inv[i];
        inv_factorial[i] %= mod;
    }
}

long long combination(int n, int r) {
    long long ret = factorial[n] * inv_factorial[r];
    ret %= mod;
    ret *= inv_factorial[n-r];
    return ret % mod;
}

long long modpow(int n, int r) {
    long long ret = 1; long long tmp = (long long) n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp; tmp %= mod; ret %= mod;
        r /= 2;
    }
    return ret;
}

int main() {
    GetInv(); GetFactorial();
    int h, w; cin >> h >> w;
    int n; cin >> n;
    vector<pair<int, int>> v = {{1, 1}};
    for (int i = 0; i < n; i++) {
        int r, c; cin >> r >> c;
        v.push_back({r, c});
    }
    v.push_back({h, w});
    sort(v.begin(), v.end());
    long long dp[n+2][2];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 1; i <= n+1; i++) {
        for (int j = 0; j < i; j++) {
            if (v[i].first < v[j].first || v[i].second < v[j].second) continue;
            int r = v[i].first - v[j].first;
            int c = v[i].second - v[j].second;
            for (int k = 0; k < 2; k++) {
                dp[i][k] = (dp[i][k] + (dp[j][!k] * combination(r+c, r)) % mod) % mod;
            }
        }
    }
    cout << (mod + dp[n+1][1] - dp[n+1][0]) % mod << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100001
#define FI freopen("input.txt","r",stdin)
#define FO freopen("output.txt","w",stdout)
#define sc(a) scanf("%d",&a);
#define sc2(a,b) scanf("d",&a,&b);
#define fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
vector<string>v;
int cnt[MAX];

int main()
{
    int n;
    map<string,int>mp;
    //stack<string>stck;
    vector<string>win;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    int mx = 0;
    string winner;
    for(auto &str:v)
    {
        mp[str]++;
    }
    int val,f;
    string ans2;
    for(auto &vt:mp)
    {
        string a = vt.first;
        val = vt.second;
        if(val>=mx)
        {
            mx = val;
            winner = a;
            f = 0;
        }
    }
    for(auto &vt:mp)
    {
        if(vt.second==mx)
            win.push_back(vt.first);
    }
    sort(win.begin(),win.end());
    for(auto x:win)
    {
        cout<<x<<"\n";
    }
    return 0;
}




Measured memory_bytes: 28400
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
char str[200000];
int cou[200];

int main()
{

    int i,j,k,l,m,n;
    cin>>n;
    scanf("%s",str);
    for(int i=0;str[i];i++)
    {
        cou[str[i]]++;
    }
    long long mul=1;
    for(int i=97;i<=122;i++)
    {
      mul=mul*(cou[i]+1);
      mul%=mod;
    }
    mul=mul-1;
    if(mul<0)mul=(mul+mod)%mod;
    cout<<mul<<endl;


}



Measured memory_bytes: 384
V=0
E=0
edge=[]
p=[]
rank=[]
answer=0
count=0

def makeset(x):
    p[x] = x
    rank[x] = 0
    
def union(x,y):
    link(findset(x),findset(y))
    
def link(x,y):
    if rank[x] > rank[y]:
        p[y] = x
    else:
        p[x] = y
        if rank[x] == rank[y]:
            rank[y] = rank[y] + 1
            
def findset(x):
    if x != p[x]:
        p[x] = findset(p[x])
    return p[x]
            
def takeThird(elem):
    return elem[2]
v,e = map(int,input().split())
V=v
E=e
while True:
    try:
        s,t,w = map(int,input().split())
    except:
        break
    else:
        edge.append([s,t,w])
        
edge.sort(key=takeThird)
for i in range(V):
    p.append(None)
    rank.append(None)
for i in range(V):
    makeset(i)
for i in range(len(edge)):
    if count == V-1:
        break
    if findset(edge[i][0]) == findset(edge[i][1]):
        continue
    union(edge[i][0],edge[i][1])
    answer+=edge[i][2]
    count+=1
    
print(answer)


Measured memory_bytes: 25804
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;
constexpr int MOD = 1e9 + 7;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;
int k;

vector<int> a;

void input() {
  cin >> n >> k;

  a.resize(n);
  for (auto&& i : a) {
    cin >> i;
  }
}

void solve() {
  sort(a.begin(), a.end());

  int ans = INF;

  for (int i = 0; i < n - k + 1; ++i) {
    ans = min(ans, a[i + k - 1] - a[i]);
  }

  cout << ans << '\n';
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve();
}


Measured memory_bytes: 768