akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int h,w,n;
vvb a;

int main(){
	while(1){
		cin>>h>>w>>n;
		if(!h) break;
		a=vvb(h,vb(w));
		for(int i=0;i<h;i++) for(int j=0;j<w;j++){
			int b;
			cin>>b;
			a[i][j]=b;
		}
		int x=0,y=0;
		vvi dp(h+1,vi(w+1));
		dp[0][0]=n;
		for(int i=0;i<h+w;i++) for(int j=0;j<=i;j++) if(i-j<h&&j<w){
			int DP=dp[i-j][j],b=a[i-j][j];
			dp[i-j][j+1]+=(DP+b)/2;
			dp[i-j+1][j]+=(DP+!b)/2;
			if(x==i-j&&y==j){
				if(b^DP%2==1) x++;
				else y++;
			}
		}
		cout<<x+1<<' '<<y+1<<endl;
	}
}

Measured memory_bytes: 6848
while True:
  n, x = map(int, input().split())
  if n == 0 and x == 0: break
  ans = 0
  for i in range(1,n-1):
    for j in range(i+1, n):
      for k in range(j+1, n+1):
        if i + j + k == x:
          ans += 1
  print(ans)



Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define MN 300005
#define MM 600005
int n,ans=1e9;
int a[MN],b[MN],f[MN],g[MN];
char s[MN];
int main(){
	scanf("%d%s",&n,s+1);
	F(i,1,n)a[i]=a[i-1]+(s[i]=='#');
	F(i,0,n)ans=min(ans,a[i]+n-i-a[n]+a[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2944
n =int(input())
a = list(map(int, input().split()))

def 割れる回数(a):
    回数 = 0
    while a % 2 == 0:
        回数 += 1
        a = a//2
    return 回数
割れる回数のリスト = [割れる回数(a_i) for a_i in a]
答え =min(割れる回数のリスト)
print(答え)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define F first
#define S second
#define pb push_back
#define all(c)  c.begin(), c.end()
#define vb vector<bool>
#define vll vector<ll>
#define vi vector<int>
#define vp vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define lb "\n"
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define INF 1000000007
#define MAX LLONG_MAX
#define PI 3.14159265358
ll max(ll x,ll y){if(x>y)return x;else return y;}
ll min(ll x,ll y){if(x>y)return y;else return x;}
ll dp[1000][1000];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
      #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
   ll i,j,k,h,w;
   cin>>h>>w;
   vector<string> s(h);
   rep(i,0,h)
   cin>>s[i];
   rep(i,0,w)
   {
       if(s[0][i]=='#')
       break;
        dp[0][i]=1;
   }
   rep(i,0,h)
   {
      if(s[i][0]=='#')
       break;
        dp[i][0]=1;
   }
   rep(i,1,h)
   rep(j,1,w)
   {
       if(s[i][j]=='.')
        dp[i][j]=(dp[i-1][j]+dp[i][j-1])%(INF);
   }
  cout<<dp[h-1][w-1];
}


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


using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e5 + 5;
bool isPrime[MAXN];



ll fastPow(ll x, ll b)
{
    if (b == 0)
        return 1;
    else if (!(b & 1))
    {
        return fastPow(x * x, b / 2);
    }
    else
        return x * fastPow(x * x, (b - 1) / 2);
}

//__builtin_popcount ();
bool isPrim(int n)
{
    if (n == 1 || n == 0)
        return false;
    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}



int main()
{
    FAST
    string h;
    cin>>h;
    ll ans=0;
    int c=0;
    for(int i=0;i<h.size();i++)
    {
        if(h[i]=='B')
            c++;
        else
            ans+=c;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,x,c=0,p=0,q=0;
q=0;
cin>>x>>n;
p=x;
q=x;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
while(1)
{
	int k=0;
	for(int i=0;i<n;i++)
	{
if(p==a[i])
{
k=1;
break;
}
}
if(k==0)
break;
else
p++;
}
while(1)
{
	int y=0;
	for(int i=n-1;i>=0;i--)
	{
if(q==a[i])
{
y=1;
break;
}
}
if(y==0)
break;
else
q--;
}
if(abs(x-q)>abs(x-p))
cout<<p<<endl;
else
cout<<q<<endl;

	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

#define NUM 1100000

using namespace std;

int table[NUM];

void func(int n,int budget){

	int tmp,max_prime = 0,food[n],index = 0;

	bool checkTable[budget+1],FLG;

	for(int i = 0; i < budget+1;i++)checkTable[i] = false;

	checkTable[0] = true;

	for(int i = 0; i < n; i++){
		scanf("%d",&tmp);
		FLG = true;

		for(int loop = 0; loop < index;loop++){
			if(food[loop] == tmp){
				FLG = false;
				break;
			}
		}

		if(FLG == true && tmp <= budget){
			food[index++] = tmp;

			for(int k = tmp; k <= budget; k++){
				if(checkTable[k-tmp] == true){
					checkTable[k] = true;
					if(table[k] == 1){
						max_prime = max(max_prime,k);
					}
				}
			}
		}
	}

	if(max_prime == 0)printf("NA\n");
	else{
		printf("%d\n",max_prime);
	}

}

int main(){
	int limit;

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int n,budget;

	while(true){
		scanf("%d %d",&n,&budget);
		if(n == 0 && budget == 0)break;

		func(n,budget);
	}
	return 0;
}

Measured memory_bytes: 7928
using System;

class Program
{
    static void Main(string[] args)
    {
        var xyz = Console.ReadLine().Split(' ');
        var x = int.Parse(xyz[0]);
        var y = int.Parse(xyz[1]);
        var z = int.Parse(xyz[2]);

        var ans = Math.Min(x * y, z);
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b)
{
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

ll modinv(ll a,ll m) {
    ll b=m,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b; swap(a,b);
        u-=t*v; swap(u,v);
    }
    u%=m;
    if (u<0) u+=m;
    return u;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin>>n>>k;
    ll key=n%k;
    if(abs(key-k)>=key){
        cout<<key<<endl;
    }else{
        cout<<abs(key-k)<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 500000
#define INFTY 2000000000


int L[MAX/2+2], R[MAX/2+2];
int count;

void merge(int A[], int n, int left, int mid,int right){
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i = 0;i < n1; i++){
	L[i] = A[left + i];
	}
	for(int i = 0;i < n2; i++){
	R[i] = A[mid + i];
	}
	L[n1] = R[n2] = INFTY;
	int i = 0,j = 0;
	for(int k = left; k < right; k++){
	count++;
	if(L[i] <= R[j]){
		A[k] = L[i++];
	}else{
		A[k] = R[j++];
	}
	}
	
}

void mergeSort(int A[], int n,int left,int right){
	if(left + 1 < right){
	int mid = (left + right) /2;
	mergeSort(A,n,left,mid);
	mergeSort(A,n,mid,right);
	merge(A,n,left,mid,right);
	}

}

int main(void){
	int A[MAX],n,i;
	count = 0;

	scanf("%d",&n);
	for(i = 0;i < n;i++){
	scanf("%d",&A[i]);
	}
	
	mergeSort(A,n,0,n);
	
	for(i = 0;i < n;i++){
	printf("%d",A[i]);
	if(i != n-1) printf(" ");
	}
	
	printf("\n");
	printf("%d\n",count);
	return 0;

}


Measured memory_bytes: 5640
/*0429??????????????§??£?§£???
 * 12??????????????????????¢???? ????????°??????????????????????????????????????????????????????????´???°????????????int ????????§????????????.?????????maxvalue???memory?¶??????????????????????
 * 
 * Created by SharpDevelop.
 * User: yog-sothoth
 * Date: 2017/04/23
 * Time: 17:25
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System.Collections.Generic;
using System;
using System.IO;

namespace Dictionary
{
	
	public class DictionaryList
	{
		
		
		public static void Main(string[] args)
		{		
			int num = int.Parse(Console.ReadLine());// the number of instructions
			
			
			bool[] table = new bool[68000000];
		
			var sw = new StreamWriter(Console.OpenStandardOutput())
	    	{ AutoFlush = false };
			
			Console.SetOut(sw);
			
			for (int i = 0; i < num; i++) {
				string iands = Console.ReadLine();//instruction and s tring
				string[] instAndStr = iands.Split();
			
				
				//Add list instAndStr[1]		
				if (instAndStr[0] == "insert") {//??????????????\???
					//??????????????°????????????????????????table[index]???????????°??????????????????????????¨????????????????????§????????????
					//????????°???????????????
					int index = 0;
					for (int j = 0; j < instAndStr[1].Length; j++) {
			
						index *= 4;
				
						switch (instAndStr[1][j]) {
							case 'A':
								index += 1;
								break;
							case 'C':
						
								index += 2;
						
								break;
							case 'G':
						
								index += 3;
								break;
							case 'T':
						
								index += 4;
								break;			
						}
						
		
					}
					table[index]=true;
		
					
				} else { //?????????find
					
					
					int index = 0;
					for (int k = 0; k < instAndStr[1].Length; k++) {
			
						index *= 4;
				
						switch (instAndStr[1][k]) {
							case 'A':
								index += 1;
								break;
							case 'C':
						
								index += 2;
						
								break;
							case 'G':
						
								index += 3;
								break;
							case 'T':
						
								index += 4;
								break;			
						}
						
		
					}
					if(table[index]!=true)
					{
						Console.WriteLine("no");
					}else
						Console.WriteLine("yes");
				}
				
			}
			Console.Out.Flush();
		}
		
	}
}

Measured memory_bytes: 117640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

// 最大公約数
ll gcd(ll m, ll n) {
  if (n==0) return abs(m);
  else return gcd(n, m%n);
}

// 最小公倍数
ll lcm(ll m, ll n) {
  return abs(m)/gcd(m, n)*abs(n);
}

int main() {
  ll A, B;
  cin >> A >> B;
  cout << lcm(A, B) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
#define MAXN 100100
#define ll long long
int n, m, cnt, a[MAXN], A, B, C, D;
int main()
{
	scanf("%d%d%d%d",&A,&B,&C,&D);
	n = (C+B-1)/B;
	m = (A+D-1)/D;
	if(n<=m) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 3764
def main():
    x1, y1, x2, y2 = map(int, input().split())
    dx, dy = x2-x1, y2-y1
    x3, y3 = x2-dy, y2+dx
    x4, y4 = x3-dx, y3-dy
    print(x3, y3, x4, y4)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a int
	fmt.Scan(&a)

	n := make([]int, a)

	for i := range n {
		fmt.Scan(&n[i])
	}

	sort.Ints(n)
	mid := len(n) / 2

	ans := n[mid] - n[mid-1]

	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include "bits/stdc++.h"

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, m, r;
	cin >> n >> m >> r;

	vi route(r);
	for (int i = 0; i < r; i++) {
		cin >> route[i];
		route[i]--;
	}
	sort(route.begin(), route.end());

	vvi g(n, vi(n, INF));
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;

		g[a][b] = g[b][a] = c;
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				g[i][j] = min(g[i][j], g[k][i] + g[k][j]);
			}
		}
	}

	int res = INF;
	do {
		int cnt = 0;
		for (int i = 1; i < r; i++) {
			cnt += g[route[i - 1]][route[i]];
		}

		res = min(res, cnt);
	} while (next_permutation(route.begin(), route.end()));

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int check = 0;
  for(int i = 0; i < s.size(); i+=2){
    if(s[i] != 'h'|| s[i+1] != 'i')check++;
  }
  if(check == 0)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
 


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace APC001A_TwoIntegers
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            int x = int.Parse(input[0]);
            int y = int.Parse(input[1]);

            int result = -1;

            if (x % y != 0)
            {
                for (int indexX = 1; indexX * x <= Math.Pow(10, 18); indexX++)
                {
                    int xx = indexX * x;
                    List<int> multipleY = new List<int>();
                    for (int indexY = 1; indexY * y <= xx; indexY++)
                    {
                        multipleY.Add(indexY * y);
                    }

                    if (!multipleY.Contains(xx))
                    {
                        result = xx;
                        break;
                    }
                }
            }

            //if (x != y)
            //{
            //    for (int indexX = 1; indexX * x <= Math.Pow(10, 18); indexX++)
            //    {
            //        int xx = indexX * x;
            //        List<int> multipleY = new List<int>();
            //        for (int indexY = 1; indexY * y <= xx; indexY++)
            //        {
            //            multipleY.Add(indexY * y);
            //        }

            //        if (!multipleY.Contains(xx))
            //        {
            //            result = xx;
            //            break;
            //        }
            //    }
            //}

            Console.WriteLine(result);


        }
    }
}


Measured memory_bytes: 13280
#include <cstdio>
#include <utility>
#define SENTINEL 2000000000
using namespace std;

struct Card {
    char suit;
    int value;
};

Card *L, *R;

int partition(Card A[], int p, int r) {
    int x = A[r].value;
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j].value <= x) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[r]);
    return i+1;
}

void quickSort(Card A[], int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
    }
}

void merge(Card A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].value = R[n2].value = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i].value < R[j].value) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(Card A[], int n, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main() {
    int n;
    scanf("%d", &n);

    L = new Card[int(n/2+1)];
    R = new Card[int((n+1)/2+1)];   
    
    Card A[n], B[n];
    for (int i = 0; i < n; i++) {
        scanf("%s %d", &A[i].suit, &A[i].value);
        B[i] = A[i];
    }

    quickSort(A, 0, n-1);
    mergeSort(B, n, 0, n);

    bool isStable = true;
    for (int i = 0; i < n; i++) {
        if (A[i].suit == B[i].suit) {
            isStable = false;
            printf("Not stable\n");
            break;
        }
    }
    if (isStable) printf("Stable\n");

    for (int i = 0; i < n; i++) {
        printf("%c %d\n", A[i].suit, A[i].value);
    }

    return 0;
}


Measured memory_bytes: 4920
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  vi trees;

  while (n--) {
    int h;
    cin >> h;
    trees.pb(h);
  }
  
  sort(trees.begin(), trees.end());

  int res = 1000000001;
  for (int i = 0; i+k-1 < trees.size(); ++i) {
    res = min(res, trees.at(i+k-1)-trees.at(i));
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 892
"""
素数を求める
素数以外の数 = 合成数
「合成数 x は p ≤ _√xを満たす素因子 p をもつ」
"""


def is_prime(x):
    if x == 2:
        return True
    if x % 2 == 0:
        return False
    i = 3
    while i <= int(x ** 0.5):
        if x % i == 0:
            return False
        i += 2
    return True


def main():
    cnt = 0
    N = int(input())
    for n in range(N):
        x = int(input())
        if is_prime(x):
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()



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

const int INF = ~(1 << 31);

//bridge
vector< vector< int > > edge;
vector< int > dfs, lw, pr;
vector< pair< int, int > > br;
int v, e, s, t, cnt;
int root = 0;

int rec(int v){
	
	dfs[v] = cnt;
	++cnt;
	
	int lmin = dfs[v];
	
	for(vector< int >::iterator it = edge[v].begin(); it != edge[v].end(); ++it){
		if(dfs[*it] == 0){
			pr[*it] = v;
			int l = rec(*it);
			
			lmin = min(lmin, l);
			
			if(l >= dfs[*it]) br.push_back(make_pair< int, int >(v, *it));
			
		}else if(*it != pr[v]){
			lmin = min(lmin, dfs[*it]);
		}
	}
	
	
	lw[v] = lmin;
	
	return lw[v];
}

void swap(int *a, int *b){
	if(*a != *b){
		*a ^= *b;
		*b ^= *a;
		*a ^= *b;
	}
}

int main(){
	
	cin >> v >> e;
	edge.resize(v);
	dfs.resize(v);
	lw.resize(v);
	pr.resize(v);
	br.clear();
	
	for(int i = 0; i < e; ++i){
		cin >> s >> t;
		edge[s].push_back(t);
		edge[t].push_back(s);
	}
	
	cnt = 1;
	rec(root);
	
	for(vector< pair< int, int > >::iterator it = br.begin(); it != br.end(); ++it){
		if(it->first >= it->second){
			swap(&(it->first), &(it->second));
		}
	}
	
	sort(br.begin(), br.end());
	
	for(vector< pair< int, int > >::iterator it = br.begin(); it != br.end(); ++it){
		cout << it->first << " " << it->second << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2856
import java.util.*;

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int resultA=0;
        int resultB=0;

        for (int i =0; i<n.length(); i++) {
           if (i%2==0 && n.charAt(i) == '0') {
               resultA++;
           } 
           if (i%2==1 && n.charAt(i) == '1') {
               resultA++;
           }
        }

        for (int i =0; i<n.length(); i++) {
           if (i%2==0 && n.charAt(i) == '1') {
               resultB++;
           } 
           if (i%2==1 && n.charAt(i) == '0') {
               resultB++;
           }
        }
        System.out.println(resultA > resultB?resultB:resultA);
        sc.close();
    }
}

Measured memory_bytes: 25528
N[]={ 6, 14, 18, 10,  2,  9, 22, 15,  1, 17, 23,  7,  3,  5, 21, 19,  0, 13, 20, 11,  4,  8, 16, 12};
E[]={13, 17,  9,  5,  8, 21, 14,  1, 16, 22,  6,  0,  4, 20, 18,  2, 12, 23, 10,  3, 11, 19, 15,  7};
R[]={ 3,  0,  1,  2,  7,  4,  5,  6, 11,  8,  9, 10, 15, 12, 13, 14, 19, 16, 17, 18, 23, 20, 21, 22};
a=-1;
d;
char s[9];
main(c)
{
	for(;c-48&&scanf("%s",s);)
	{
		if((c=*s)<60)
			~a&&printf("%d\n",a),
			a=d=0;
		if(c=='N')d=N[d];
		if(c=='E')d=E[d];
		if(c=='W')d=E[E[E[d]]];
		if(c=='S')d=N[N[N[d]]];
		if(c=='R')d=R[d];
		if(c=='L')d=R[R[R[d]]];
		a+=d/4+1;
	}
}

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

using namespace std;

typedef long long int ll;
const ll N=50+10,inf=1e18;
ll n,m=50,k,ans,re=0,t[N],a[N],b[N],dp[N][N];

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    t[0]=1;
    for(int i=1; i<=m; i++) t[i]=2*t[i-1];
    for(int i=0; i<=m; i++)
        for(int j=0; j<=m; j++)
        {
            if(i==j) dp[i][i]=0;
            else
                dp[i][j]=inf;
            //cout << "Start " << i << ' ' << j << endl;
            for(int k=1; k<=m; k++)
            {
                dp[i][j]=min(dp[i][j],dp[i%k][j]+t[k]);
                //cout << "ch: " << dp[i%k][j] << ' ' << t[k] << endl;
            }
            //cout << i << ' ' << j << ' ' << dp[i][j] << endl;
        }
    cin >> n;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    for(int i=1; i<=n; i++)
        cin >> b[i];
    for(int i=1; i<=n; i++)
    {
        if(dp[a[i]][b[i]]==inf)
        {
            cout << -1;
            return 0;
        }
        ans=max(ans,dp[a[i]][b[i]]);
    }
    while(ans>0)
    {
        k=0;
        //cout << "Start " << ans << ' ' << endl;
        for(int i=1; i<=50; i++)
            if(ans&t[i]) k=i;
        //cout << "so we find : " << k << endl;
        re+=t[k];
        t[k]=0;
        for(int i=0; i<=m; i++)
            for(int j=0; j<=m; j++)
            {
                if(i==j) dp[i][i]=0;
                else
                    dp[i][j]=inf;
                for(int k=1; k<=m; k++)
                    dp[i][j]=min(dp[i][j],dp[i%k][j]+t[k]);
            }
        ans=0;
        for(int i=1; i<=n; i++)
            ans=max(ans,dp[a[i]][b[i]]);
    }
    cout << re;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
//#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#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 LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}


constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(int a,int b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll A,B,C;
    cin >> A>>B>>C;
    //ll a[N];
    ll ans=0;
    //ll sum=0;
    //FOR(i,0,N-1){
    //  cin>>a[i];
    //}


if(A+B+1>=C){
      ans=B+C;
    }else {
      ans=A+B*2+1;
    }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long K, long long A, long long B) {
  rep(i, 1000) {
    if (A <= i * K && i * K <= B) {
      cout << "OK" << endl;
      return;
    }
  }
  cout << "NG" << endl;
}

signed main() {
  long long K;
  scanf("%lld", &K);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(K, A, B);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 3764
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		ArrayList<String> param = new ArrayList<String>();
		int system = 0; // 文字の空白区切り 0:ON 1:OFF

		while (sc.hasNext()) {
			if (sc.hasNextInt()) {
				num.add(sc.nextInt());
			} else {
				if (system == 0)
					param.add(sc.next());
				if (system == 1)
					param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}

	static void Method(ArrayList<Integer> num, ArrayList<String> param) {
		int[] n = new int[100];
		for(int i = 0; i <num.size(); i++){
			n[i] = num.get(i);
		}
		String[] p = new String[100];
		for(int i = 0; i <param.size(); i++){
			p[i] = param.get(i);
		}
		////////////////////////////////////////////////////////////////////
		int point = -1;
		boolean flag = false;
		
		for(int i = 0; i <= n[0] - n[1]; i++){
			//System.out.println(p[n[0]] + " " + p[i]);
			point = p[i].indexOf(p[n[0]],point+1);
			//System.out.println(point);
			if(point == -1) continue;
			if(n[1] == 1){
				flag = true;
				break;
			}
			for(int k = 1; k < n[1]; k++){
				//System.out.println((p[i + k]) + " " + p[n[0] + k]);
				if(point != (p[i + k]).indexOf(p[n[0] + k],point)) break;
				//System.out.println(point);
				if(k == n[1]-1) flag = true;
			}
		}
		if(flag){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
  ll n, k;
  cin >> n >> k;

  cout << n-k+1 << endl;
  


  
  return 0;
}


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

n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
mod = 10**9 + 7

memo = [-1] * (1 << n)
memo[0] = 1

def dfs(s, count):
    if memo[s] != -1:
        return memo[s]
    res = 0
    for i in range(n):
        if (s >> i) & 1 and a[count-1][i]:
            res += dfs(s ^ (1 << i), count-1)
    memo[s] = res % mod
    return memo[s]

print(dfs((1 << n) - 1, n))



Measured memory_bytes: 63836
n = int(input())
ans = ''
for i in range(1,n+1):
    if i%3==0:
        ans+=' '+str(i)
    else:
        x = i
        while x>0: 
            if x%10==3:
                ans+=' '+str(i)
                break
            x = x//10
        
print(ans)


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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define out(n) cout << (n) << endl;

__attribute__(())
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n, m, d[100001] = {0};
  cin >> n >> m;

  int a, b;
  rep(i, 0, m) {
    cin >> a >> b;
    d[a]++, d[b]++;
  }

  rep(i, 0, n + 1) {
    if(d[i] & 1) {
      out("NO")
      return 0;
    }
  }

  out("YES")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int fa[100010],A[100010],B[100010],s[100010];
ll dp[100010],sb[100010];
std::vector<int>G[100010];
int hd(int x){return fa[x]==x?x:fa[x]=hd(fa[x]);}
bool yes[100010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),m=gi(),a,b;
	for(int i=1;i<=n;++i)A[i]=gi(),B[i]=sb[i]=gi(),fa[i]=i,dp[i]=std::max(0,A[i]-B[i]),s[i]=i;
	std::sort(s+1,s+n+1,[&](int x,int y){return dp[x]<dp[y];});
	while(m--)a=gi(),b=gi(),G[a].push_back(b),G[b].push_back(a);
	for(int _=1,x;_<=n;++_){
		x=s[_];yes[x]=1;
		for(int i:G[x])
			if(hd(i)!=hd(x)&&yes[i]){
				int s=hd(i);
				fa[s]=x;
				sb[x]+=sb[s];
				dp[x]=std::min(dp[x],dp[s]+std::max(0ll,A[x]-B[x]-sb[s]-dp[s]));
			}
	}
	printf("%lld\n",dp[hd(1)]+sb[hd(1)]);
	return 0;
}


Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
struct M {
  using T = int;
  static T op(const T &a, const T &b) { return a + b; }
  static constexpr T e() { return 0; }
};
template<class M> struct ST {
  using T = typename M::T;
  int n; V<T> t;
  ST(int n) : n(n) { t.assign(2 * n, M::e()); }
  void build() { for (int i = n - 1; i; i--) t[i] = M::op(t[2 * i], t[2 * i + 1]); }
  void modify(int i, T v) { for (t[i += n] = v; i > 1; i >>= 1) t[i >> 1] = M::op(t[i], t[i ^ 1]); }
  T query(int l, int r) {
    T resl = M::e(), resr = M::e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = M::op(resl, t[l++]);
      if (r & 1) resr = M::op(t[--r], resr); 
    }
    return M::op(resl, resr);
  }
};
int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);  
  int n, q; cin >> n >> q;
  ST<M> st(n);
  for (int i = 0; i < q; i++) {
    int c, x, y; cin >> c >> x >> y, x--;
    if (c) cout << st.query(x, y) << '\n';
    else st.modify(x, st.t[x + n] + y);
  }
}


Measured memory_bytes: 3628
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Gabriel Carrillo
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        DKnapsack1 solver = new DKnapsack1();
        solver.solve(1, in, out);
        out.close();
    }

    static class DKnapsack1 {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt(), cap = in.nextInt();
            int[] w = new int[n];
            int[] c = new int[n];
            long[] dp = new long[cap + 1];
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
                c[i] = in.nextInt();
            }
            for (int i = 0; i < n; i++)
                for (int j = cap; j >= w[i]; j--)
                    dp[j] = Math.max(dp[j], dp[j - w[i]] + c[i]);
            out.println(dp[cap]);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(long i) {
            writer.println(i);
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;

	vector<vector<bool> > s(h, vector<bool>(w, false));

	for (int ih = 0; ih < h; ih++) {
		for (int iw = 0; iw < w; iw++) {
			char st;
			cin >> st;
			s[ih][iw] = st == '#';
		}
	}

	for (int ih = 0; ih < h; ih++) {
		for (int iw = 0; iw < w; iw++) {
			if (!s[ih][iw]) continue;
			if (ih > 0) {
				if (s[ih-1][iw] == s[ih][iw]) continue;
			}
			if (ih < h - 1) {
				if (s[ih][iw] == s[ih + 1][iw]) continue;
			}
			if (iw > 0) {
				if (s[ih][iw-1] == s[ih][iw]) continue;
			}
			if (iw < w - 1) {
				if (s[ih][iw] == s[ih][iw + 1]) continue;
			}

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

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


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

DICT = {k: 0 for k in range(1, 101)}


def solve(d):
    _max = max(d.values())
    for k, v in sorted(d.items()):
        if _max == v:
            print(k)

if __name__ == '__main__':
    while True:
        try:
            n = int(input())
            DICT[n] += 1
        except:
            break

    solve(DICT)

Measured memory_bytes: 7724
//#define LOCAL_DEBUG

#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

int main() {
#ifdef LOCAL_DEBUG
	freopen("input.txt","r", stdin);
#endif

	int x = 0; cin >> x;
	if (x < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl;

	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(s.hasNext()) {
			int c = s.nextInt();
			int ans = check(c);
			System.out.println(ans);
		}
	}
	static int check(int c) {
		int kk = 0;
		for(int i = 0; i < 10; i++) {
			for(int j = 0; j < 10; j++) {
				for(int k = 0; k < 10; k++) {
					for(int l = 0; l < 10; l++) {
						if(i + j + k + l == c) {
							kk++;
						}
					}
				}
			}
		}
		return kk;
	}
}

Measured memory_bytes: 19128
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){
  int a;
  char s[15];

  scanf("%d", &a);
  scanf("%s", s);

  if(a >= 3200) printf("%s\n", s);

  else printf("red\n");
  
  return 0;
}


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

flg = 0
counter = 0
ans = 0
while flg == 0:
    for i in range(N):
        if A[i]%2 == 0:
            A[i] = int(A[i]/2)
            counter += 1
        else:
            flg = 1
            break
    if counter == N:
        ans += 1
        counter = 0
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<cstdio>
#include<deque> 
using namespace std;
int main(){
int n;
scanf("%d",&n);
deque<int>Q;
for(int i=0;i<n;i++){
	int a;
	scanf("%d",&a);
	if(i%2==0){
		Q.push_back(a);
	}else{
		Q.push_front(a); 
	}
	}
	if(n%2==0){
		for(int i=0;i<n;i++)
		printf("%d%c",Q[i],i==n-1?'\n':' ');
	}else{
		for(int i=0;i<n;i++)
		printf("%d%c",Q[n-1-i],i==n-1?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N, M;
    cin >> N >> M;
    vec A(N);
    loop(i, N) cin >> A[i];
    map<ll, ll> modcount;
    vec S(N + 1);
    S[0] = 0;
    loop(i, N)
    {
        S[i + 1] = S[i] + A[i];
    }
    loop(i, N + 1)
    {
        modcount[S[i] % M]++;
    }
    ll ans = 0;
    loop(i, N)
    {
        ll now = S[i] % M;
        ans += modcount[now] * (modcount[now] - 1) / 2;
        modcount[now] = 0;
    }
    putout(ans);
    return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(d2 == 1){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

string alp="abcdefghijklmnopqrstuvwxyz";

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  ll n;
  cin>>n;
  string ans="";
  ll mask=1;
  while(n>0){
    mask*=26;
    ll x=n/mask, y=n%mask;
    ll tmp=y/(mask/26);
    if(tmp==0){
      ans+=alp[26-1];
      n-=mask;
    }
    else{
      ans+=alp[tmp-1];
      n-=y;
    }
    // DEBUG(n);
  }
  int m=ans.size();
  FORR(i, 0, m){
    cout<<ans[i];
  }
  cout<<'\n';
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200025,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,m,a[N],b[N],ans;
struct segment_tree{
	int mi[N<<2],ma[N<<2];
	void build(int x,int l,int r){
		if (l==r){mi[x]=ma[x]=a[l];return;}
		int mid=(l+r)>>1;
		build(x*2,l,mid);
		build(x*2+1,mid+1,r);
		mi[x]=min(mi[x*2],mi[x*2+1]);
		ma[x]=max(ma[x*2],ma[x*2+1]);
	}
	int getma(int x,int l,int r,int &fl,int &fr){
		if ((fl<=l)&&(fr>=r)) return ma[x];
		int mid=(l+r)>>1,t=-1;
		if (fl<=mid) t=max(t,getma(x*2,l,mid,fl,fr));
		if (fr>mid) t=max(t,getma(x*2+1,mid+1,r,fl,fr));
		return t;
	}
	int quema(int l,int r){return getma(1,1,n,l,r);}
	int getmi(int x,int l,int r,int &fl,int &fr){
		if ((fl<=l)&&(fr>=r)) return mi[x];
		int mid=(l+r)>>1,t=n+1;
		if (fl<=mid) t=min(t,getmi(x*2,l,mid,fl,fr));
		if (fr>mid) t=min(t,getmi(x*2+1,mid+1,r,fl,fr));
		return t;
	}
	int quemi(int l,int r){return getmi(1,1,n,l,r);}
}f;
int main(){
//	freopen("balance.in","r",stdin);
//	freopen("balance.out","w",stdout);
	n=read();m=read();
	for (int i=1;i<=n;i++) a[i]=read();
	ans=1;f.build(1,1,n);
	for (int i=1;i<=n;i++){
		if (a[i]>a[i-1]) b[i]=b[i-1]+1;
		else b[i]=1;
		if (b[i]>=m) ans=(b[m]!=m)+1;
	}
	for (int i=1;i+m<=n;i++)
	if (b[i+m]<m){
		ans++;
		if ((a[i]<f.quemi(i+1,i+m-1))&&(a[i+m]>f.quema(i+1,i+m-1))) ans--;
	}
	printf("%d\n",ans);
	return 0;
}

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

#define repeat(i, n) for(int i=0;i<(n);i++)

int main() {
    int M, N;
    cin >> M >> N;
    int max_solve = 0;
    repeat(i,M) {
        int count = 0;
        repeat(j,N) {
            int c; cin >> c;
            if (c == 1) count++;
        }
        max_solve = max(max_solve, count);
    }
    cout << max_solve << endl;
    return 0;
}

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

int main() {
    char c;

    cin >> c;
    switch (c)
    {
        case 'A'/* constant-expression */:
            cout << 'T' << endl;
            break;
        case 'C':
            cout << 'G' << endl;
            break;
        case 'G':
            cout << 'C' << endl;
            break;
        case 'T':
            cout << 'A' << endl;
        default:
            break; 
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp::{max, min};

fn read<T: FromStr> () -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_vec<T: std::str::FromStr> () -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let N: usize = read();
    let mut A: Vec<i64> = Vec::new();
    for i in 1..N+1 {
        A.push(read::<i64>()-(i as i64));
    }
    A.sort();
    let center: i64 = if (N-1) % 2 == 0 {
        A[(N-1)/2]
    } else {
        (A[(N-1)/2] + A[(N-1)/2+1]) / 2
    };
    let val = A.iter().fold(0, |acc, i| acc + ((i - center) as i64).abs());
    println!("{}", val);
}


Measured memory_bytes: 6396
#!/usr/bin/env python
#-*- coding: utf-8 -*-

# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_B

if __name__ == '__main__':
    a, b, c = map(int, raw_input().split())
    if a < b < c:
        print "Yes"
    else:
        print "No"


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

using namespace std;

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

  int a,b;cin>>a>>b;
  if(a==1&&b==1) cout<<"Draw"<<endl;
  else if(a==1) cout<<"Alice"<<endl;
  else if(b==1) cout<<"Bob"<<endl;
  else{
      if(a<b) cout<<"Bob"<<endl;
      else if(a>b) cout<<"Alice"<<endl;
      else cout<<"Draw"<<endl;
  }
}

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

def n2a(n):
    if n <= 26:
        return chr(96 + n)
    elif n % 26 == 0:
        return n2a(n // 26 - 1) + chr(122)
    else:
        return n2a(n // 26) + chr(96 + n % 26)

ans = n2a(N)
print(ans)

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

int main(int argc, char const *argv[])
{
	ll h; cin >> h;
	int cnt = 0;
	while (h > 1) {
		cnt++;
		h /= 2;
	}

	ll ans = 0;
	rep (i, cnt + 1) {
		ans += pow(2, i);
	}
	cout << ans << endl;
	return 0;
}


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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    cout << string(S.size(), 'x') << endl;
}

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

L = 0
R = 0
l = r = 0
while(l + r != N):
    if l==0 and r==0:
        L += A[l]
        l += 1
        R += A[-1 * (r + 1)]
        r += 1
    
    else:
        if L >= R:
            R += A[-1 * (r + 1)]
            r += 1

        else:
            L += A[l]
            l += 1

#print(L, R)

print(abs(L - R))

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	string p;
	vector<string>v;
	for(int i=0;i<n;i++)
	{
	    cin>>p;
	   v.push_back(p);
	}
	string s="AC";
	cout<<s<<" ";
	cout<<"x"<<" ";
	cout<<count(v.begin(),v.end(),s)<<"\n";
	 s="WA";
	 cout<<s<<" ";
	cout<<"x"<<" ";
	cout<<count(v.begin(),v.end(),s)<<"\n";
	 s="TLE";
	 cout<<s<<" ";
	cout<<"x"<<" ";
	cout<<count(v.begin(),v.end(),s)<<"\n";
	 s="RE";
	cout<<s<<" ";
	cout<<"x"<<" ";
	cout<<count(v.begin(),v.end(),s);
	cout<<"\n";
	
	
}


Measured memory_bytes: 7460
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  cout<<boolalpha;
  int n;
  cin>>n;
  vector<int> p(n);
  std::vector<bool> vec(n);
  for (int i = 0; i < n; ++i)
  {
    cin>>p[i];
    if(p[i]==i+1) vec[i]=true;
    else vec[i]=false;
  }
  int64_t cnt=0;
  for (int i = 0; i < n-1; ++i)
  {
    if(vec[i] && vec[i+1]){
      vec[i]=false;
      vec[i+1]=false;
      cnt++;
    }
  }
  for(auto&& e: vec) {
    if(e) cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 768