akhauriyash/Code-Regression huggingface dataset:
//#define India

#ifndef India
#include <bits/stdc++.h>
#else
#include "total.h"
#endif
#define fori(n) for(long long i=0;i<n;i++)
#define forr(i,x,y) for(long long i=x;i<y;i++)
#define forj(n) for(long long j=0;j<n;j++)
#define ll long long
#define d7 1000000007
#define en cout<<"\n";

using namespace std;

ll x=-1,kk=-1;
bool jpo=false;
void dfs(ll s, vector<bool> &v, vector<ll> &pr, vector<ll> adj[]){
    if(v[s]) return;
    v[s]=true;
    //cout<<s+1<<" ";
    for(auto u: adj[s]){
        if(!v[u]){
            pr[u]=s;
            //cout<<u<<" ";
            dfs(u,v,pr,adj);}
        else{
            if(!jpo&&pr[s]!=u){jpo=true;x=u;kk=s;}
        }
    }
}
ll binomialCoeff(ll n, ll k){
   ll C[n + 1][k + 1];ll i, j;
   for (i = 0; i <= n; i++){
       for (j = 0; j <= min(i, k); j++){
           if (j == 0 || j == i){C[i][j] = 1;}
           else{C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}}
   return C[n][k];
}
void bfs(vector<ll> &dis, vector<ll> adj[], ll s, vector<ll> &parent){
    dis[s]=0;
    //parent[s]=-1;
    queue<ll> q;
    q.push(s);
    while(!q.empty()){
        ll z=q.front();
        //cout<<z<<" ";
        q.pop();
        for(auto v:adj[z]){
            if(dis[v]==0){
            q.push(v);
            dis[v]=dis[z]+1;
                parent[v]=z;
            }
        }
    }
}

ll modexp(ll x, ll n,ll m){
    if(n==0) return 1%m;
    ll u=modexp(x,n/2,m);
    u=(u*u)%m;
    if(n%2==1) u=(u*x)%m;
    return u;
}

ll modinv(ll x, ll mod) { return modexp(x, mod - 2, mod); }
const int Nx=1e6+5;
ll fact[Nx];
void factorial(){fact[0]=1;
    for(int i=1;i<Nx;i++)
    {
        fact[i]=(fact[i-1]*i)%d7;
    }
    return ;}
ll binomial(ll a,ll b,ll mod){
    return ((fact[a]*modinv(fact[b],mod))%mod*modinv(fact[a-b],mod))%mod;}

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

tuple<ll,ll,ll,ll> expA(tuple<ll,ll,ll,ll> v, ll n){
    if(n==0){return {1,0,1,0};}
    if(n==1){return v;}
        ll x1,y1,z1,w1;
        ll x2,y2,z2,w2;
        tie(x1,y1,z1,w1) = expA(v, n/2);
        x2=(x1*x1+y1*z1)%d7;
        y2=(x1*y1+y1*w1)%d7;
        z2=(z1*x1+w1*z1)%d7;
        w2=(z1*y1+w1*w1)%d7;
    if(n%2==0){
        return {x2,y2,z2,w2};
    }
    else{
        return {x2+z2,y2+w2,x2,y2};
    }
}

//ll st[200010][30];
//ll loge2[200001];
//void logify(){
//loge2[1] = 0;
//for (ll i = 2; i <= 200001; i++)
//    loge2[i] = loge2[i/2] + 1;
//}

int main(){
    
    
    ll n;
    cin>>n;
    double s=6.28318530717958623200*n;
    cout<<setprecision(15)<<s;
    
    return 0;
}


Measured memory_bytes: 3708
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

  private void solve(Scanner in, PrintWriter out) {
    int N = in.nextInt();
    TreeSet<Integer> set = new TreeSet<>();
    for (int i = 0; i < N; i++) {
      set.add(in.nextInt());
    }

    int lost = N - set.size();
    if (lost % 2 == 1) {
      lost++;
    }
    out.println(N - lost);
  }

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(in, out);
    in.close();
    out.close();
  }
}


Measured memory_bytes: 51724
#include <iostream>
#include <stdio.h>

int main()
{
using namespace std;
string S;
cin >> S;
int flag = 0;
for(int i=0;i<(S.size());i++)
{
if(S.substr(i,2) == "AC")
{
flag = 1;
}
}
if(flag == 1)
{
cout << "Yes" << endl;
}else{
cout << "No" << endl;
}
}


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

int main(){
  int N,a[100000][3];
  cin>>N;
  for (int i(0);i<N;i++) cin>>a[i][0]>>a[i][1]>>a[i][2];
  int dp[100000][3]={0};
  dp[0][0]=a[0][0];
  dp[0][1]=a[0][1];
  dp[0][2]=a[0][2];
  for (int i(0);i<N;i++){
    for (int j(0);j<3;j++){
       for (int k(0);k<3;k++){
         if (j!=k){
           dp[i+1][k]=max(dp[i+1][k],dp[i][j]+a[i+1][k]);
         }
       }
    }
  }
  cout << max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2])) << endl;
  return 0;
}


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

namespace _20190309_03 {
    class Program {
        static void Main(string[] args) {
            var line0 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var n = line0[0];
            var m = line0[1];
            var list = new List<long[]>();
            for (int i = 0; i < n; i++) {
                var line = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                list.Add(new long[] { line[0], line[1] });
            }
            list = list.OrderBy(x => x[0]).ToList();
            long sum = 0;
            for (int i = 0; i < n; i++) {
                if (m < list[i][1]) {
                    sum += m * list[i][0];
                    break;
                }
                sum += list[i][1] * list[i][0];
                m -= (int)list[i][1];
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 29872
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/

int gcd(int n, int m) {
	if (n < m)std::swap(n, m);
	if (m == 0)return n;
	if (n % m == 0)return m;
	return gcd(m, n % m);
}



void proc() {
	LOAD(int, N);
	std::vector<int>A(N), L(N + 2), R(N + 2);
	L[0] = 0;
	R[N + 1] = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < N; ++i) {
		L[i + 1] = gcd(L[i], A[i]);
		R[N - i] = gcd(R[N + 1 - i], A[N - 1 - i]);
	}
	int m = -INF;
	for (int i = 0; i < N ; ++i) {
		int tmp = gcd(L[i], R[i + 2]);
		if (m < tmp)m = tmp;
	}
	cout << m << endl;
}


#endif


Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,gcd
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter

from functools import reduce
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n=ii()
def gcd_list(numbers):
    return reduce(gcd, numbers)
ans=0
for i in range(1,n+1):
    for j in range(i,n+1):
        for k in range(j,n+1):
            temp=0
            if len(list(set([i,j,k])))==1:
                temp=1
            elif len(list(set([i,j,k])))==2:
                temp=3
            else:
                temp=6
            ans+=gcd(gcd(i,j),k)*temp
print(ans)

Measured memory_bytes: 9760
N = gets.chomp.to_i
multiple_array, zero_array = N.times.map { gets.split.map(&:to_i) }.partition { |array| array[2] != 0 }
ans_array = Array.new
ans = nil
(0..100).to_a.repeated_permutation(2) do |cx, cy|
  ch = nil
  is_ans = multiple_array.all? do |array|
    h = (cx - array[0]).abs + (cy - array[1]).abs + array[2]
    ch ||= h
    ch == h
  end
  ans_array.push([cx, cy, ch]) if is_ans
end

ans_array.each do |ans_candidate|
  ans = ans_candidate if zero_array.all? do |array| 
    ans_candidate[2] <= (ans_candidate[0] - array[0]).abs + (ans_candidate[1] - array[1]).abs + array[2]
  end
end

puts ans.join(" ")


Measured memory_bytes: 3836
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val A, B = sc.nextLong
    val startA = if (A >= 4) ((A - 1) / 4) * 4 else 0
    val startB = if (B >= 4) (B / 4) * 4 else 0
    val zero = Array.fill[Char](B.toBinaryString.length)('0')
    val xorA = Array.fill[Char](B.toBinaryString.length)('0')
    for (i <- startA to A - 1) {
      val b = (zero ++ i.toBinaryString).takeRight(xorA.length)
      for (j <- xorA.length - 1 to 0 by -1) {
        xorA(j) = if (b(j) == xorA(j)) '0' else '1'
      }
    }
    val xorB = Array.fill[Char](B.toBinaryString.length)('0')
    for (i <- startB to B) {
      val b = (zero ++ i.toBinaryString).takeRight(xorA.length)
      for (j <- xorB.length - 1 to 0 by -1) {
        xorB(j) = if (b(j) == xorB(j)) '0' else '1'
      }
    }
    val resultXor = Array.fill[Char](B.toBinaryString.length)('0')
    for (i <- resultXor.indices) {
      resultXor(i) = if (xorA(i) == xorB(i)) '0' else '1'
    }
    var result = 0L
    for (i <- resultXor.indices) {
      if (resultXor(i) == '1')
        result += Math.pow(2, resultXor.length - i - 1).toLong
    }

    println(result)
  }
}

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

using namespace std;

typedef long long int ll;

const int MAXN = 1e5 + 5;

vector < vector < int > > adj(MAXN, vector < int > ());

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

  int n, m;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  queue < int > q;
  q.push(1);
  vector < bool > used(n + 1, false);
  used[1] = true;
  vector < int > p(n + 1, -1);
  while(!q.empty()){
    int u = q.front(); q.pop();
    for(auto to : adj[u]){
      if(!used[to]){
        p[to] = u;
        used[to] = true;
        q.push(to);
      }
    }
  }

  cout << "Yes" << '\n';
  for(int i = 2; i <= n; i++) cout << p[i] << '\n';
}


Measured memory_bytes: 10104
#include <stdio.h>

int main(void){

	int r,c,i,ii;
	int h[101][101]={0};

	scanf("%d %d",&r,&c);
	for(i=0;i<r;i++){
		for(ii=0;ii<c;ii++){
			scanf("%d",&h[i][ii]);
			h[i][c]+=h[i][ii];
			h[r][ii]+=h[i][ii];
			h[r][c]+=h[i][ii];
		}
	}

	for(i=0;i<=r;i++){
		for(ii=0;ii<=c;ii++){
			printf("%d",h[i][ii]);
			if(ii<c)printf(" ");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 652
#include <stdio.h>

int main(void) {
	int i;
	int ch;
	int cnt[128] = {0}, ok;

	while ((ch = getchar()) != '\n')
		cnt[ch]++;

	ok = 1;
	for (i = 'a'; i <= 'z'; i++)
		ok &= ~cnt[i] & 1;

	puts(ok ? "Yes" : "No");

	return 0;
}


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

int getLCS(char*, char*);
int C[1001][1001];

main(){
	char x[1001], y[1001];
	int q, i;

	scanf("%d", &q);
	for (i = 0; i < q; i++){
		scanf("%s%s", x, y);
		printf("%d\n", getLCS(x, y));
	}
	return 0;
}

int getLCS(char *x, char *y){
	int i, j, lenX, lenY;

	lenX = strlen(x);
	lenY = strlen(y);

	for (i = 0; i < lenX; i++){
		for (j = 0; j < lenY; j++){
			if (x[i] == y[j]) C[i + 1][j + 1] = C[i][j] + 1;
			else C[i + 1][j + 1] = ((C[i][j+1] >=  C[i+1][j])?  C[i][j+1] : C[i+1][j]);
		}
	}

	return C[lenX][lenY];
}

Measured memory_bytes: 4524
passengers,bus,limit = (int(n) for n in input().split(" "))
target = []
for p in range(passengers):
    target.append(int(input()))
target.sort()
answer = 0
temp_bus = []
now_time = 0
for p in target:
    # print(temp_bus,answer)
    now_time = p
    if len(temp_bus) == 0:
        temp_bus.append(p)
    elif len(temp_bus) < bus and now_time - temp_bus[0] <= limit:
        temp_bus.append(p)
    elif now_time - temp_bus[0] > limit or len(temp_bus) >= bus:
        temp_bus = []
        answer += 1
        temp_bus.append(p)
else:
    answer += 1
print(answer)


Measured memory_bytes: 51288
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,h[100];
  int mx=0;
  int ans=0;
  cin>>n;
  rep(i,n){
    cin>>h[i];
    mx=max(mx,h[i]);
    if(mx==h[i]) ans++;
  }
  cout<<ans<<endl;
  

  return 0;
}








Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	for {
		a, op, b := nextInt(), next(), nextInt()
		if op == "+" {
			fmt.Fprintln(out, a+b)
		} else if op == "-" {
			fmt.Fprintln(out, a-b)
		} else if op == "*" {
			fmt.Fprintln(out, a*b)
		} else if op == "/" {
			fmt.Fprintln(out, a/b)
		} else if op == "?" {
			break
		} else {
			fmt.Fprintln(out, "error")
		}
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}



Measured memory_bytes: 1192
/*Run length*/

#include <iostream>
#include <string>

using namespace std;

int main(){

	string str;
	int num;
	while(cin>>str){
		for(int i=0;i<str.size();i++){
			if(str[i] == '@'){
				int length = str[i+1] - '0';
				for(int j=0;j<length;j++) cout<<str[i+2];
				i+=2;
			}else cout<<str[i];
		}
		cout<<endl;
	}

	return 0;
}

/*
Sample Input
ab@5C1@8050
@99+1=1@90
Output for the Sample Input
abCCCCC10000000050
999999999+1=1000000000
*/

Measured memory_bytes: 1172
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type card struct {
	q int
	a int
}

type sortByA []card

func (c sortByA) Len() int           { return len(c) }
func (c sortByA) Swap(i, j int)      { c[i], c[j] = c[j], c[i] }
func (c sortByA) Less(i, j int) bool { return c[i].a > c[j].a }

func main() {
	n := getInt()
	m := getInt()

	cards := make([]card, n+m)
	for i := 0; i < n; i++ {
		cards[i].q = 1
		cards[i].a = getInt()
	}
	for i := n; i < n+m; i++ {
		cards[i].q = getInt()
		cards[i].a = getInt()
	}

	sort.Sort(sortByA(cards))

	ans := 0
	count := 0
	for i := 0; count < n; {
		ans += cards[i].a
		cards[i].q--
		count++
		if cards[i].q == 0 {
			i++
		}
	}

	fmt.Println(ans)
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


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

int main() {
  int N; cin >> N;
  map<int, int> m;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (m.count(a)) m[a]++;
    else m[a] = 1;
  }
  if (m.size() > 3) cout << "No" << endl;
  else if (m.size() == 3) {
    vector<pair<int, int>> v;
    for (auto p : m) v.push_back(p);
    bool ok = true;
    int tmp = v.at(0).first ^ v.at(1).first ^ v.at(2).first;
    if (tmp != 0) ok = false;
    if (!(v.at(0).second == v.at(1).second && v.at(1).second == v.at(2).second)) ok = false;
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else if (m.size() == 2) {
    vector<pair<int, int>> v;
    for (auto p : m) v.push_back(p);
    if (v.at(0).first == 0 && v.at(0).second * 2 == v.at(1).second) {
      cout << "Yes" << endl;
    }
    else cout << "No" << endl;
  }
  else {
    if (m.count(0)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 3840
#include<iostream>
#include<string>
using namespace std;
int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string s, ss = ""; cin>>s;
	for(int i : s){
		if(i == '0')
			ss += i;
		else if(i == '1')
			ss += i;
		else if(i == 'B')
			if(!ss.empty())
				ss.pop_back();		
	}
	cout<<ss;
	
	return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s = scan.next();
		
		int ans = 0;
		for (int i = 1; i < n; i++) {
			int count = 0;
			for (char c = 'a'; c <= 'z'; c++) {
				if (s.substring(0, i).contains(String.valueOf(c)) && s.substring(i).contains(String.valueOf(c))) {
					count++;
				}
			}
			ans = Math.max(ans, count);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

int main(){
    int n, l;
    cin >> n >> l;
    ll sum = 0;
    if(l >= 0)
    REP(i, n){
        sum += i+l;
    }
    else if(l + n <= 0)
    rep(i, n-1){
        sum += i+l;
    }
    else
    rep(i, n){
        sum += i+l;
    }
    cout << sum << endl;
    return 0;
}

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

#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

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

template<typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template<typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << "\n";
    }
}

void solve() {
    ll n;
    cin >> n;
    v a = ga(n);

    vector<pair<pll, ll>> elements;
    map<ll, ll> freq, leftmostindex;

    for (auto x : a) {
        freq[x]++;
        leftmostindex[x] = n + 1;
    }

    for (ll i = 0; i < n; i++) {
        amin(leftmostindex[a[i]], i);
    }

    elements.reserve(freq.size());
    for (auto x : freq) {
        elements.emplace_back(x, leftmostindex[x.first]);
    }

    sort(all(elements));

    ll sum = 0, idx = sz(elements) - 1;
    v printed(n, 0);

    while (true) {
        sum += elements[idx].first.second;

        ll next = idx - 1;
        while (next >= 0 && elements[next].second > elements[idx].second) {
            next--;
        }
        if (next == -1)break;

        ll val1 = elements[idx].first.first;
        ll val2 = elements[next].first.first;
        ll diff = val1 - val2;
        ll add = sum * diff;

        for (ll k = next + 1; k < idx; k++) {
            sum += elements[k].first.second;
            add += elements[k].first.second * (elements[k].first.first - val2);
        }

        printed[leftmostindex[val1]] = add;
        idx = next;
    }

    ll val1 = elements[idx].first.first;
    ll add = sum * val1;

    for (ll k = 0; k < idx; k++) {
        add += elements[k].first.second * (elements[k].first.first - 0);
    }
    printed[leftmostindex[val1]] = add;

    pa(printed);
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 17408
# Problem https://atcoder.jp/contests/abc095/tasks/abc095_a
# Python 1st Try


def addCost(infoTicket):
    result = 0
    if infoTicket[0] == 'o':
        result = result + 100
    if infoTicket[1] == 'o':
        result = result + 100
    if infoTicket[2] == 'o':
        result = result + 100
    return result


def solver(inputstr):
    result = 0
    result = 700 + addCost(inputstr)
    return result


if __name__ == "__main__":
    answer = 0
    answer = solver(input())
    print(answer)


Measured memory_bytes: 3060
/* 
 * Project: AtCoder Beginners Contest 152
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/10
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
using namespace std;


int n, m;

void solve() {

    if (n == m)
        printf("Yes\n");
    else
        printf("No\n");
}

int main() {

    scanf("%d", &n);
    scanf("%d", &m);

    solve();

}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(int)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(), x.end()
#define uni(x) x.erase(unique(all(x)), x.end());
#define BUG(x) cout << #x << " = " << x << endl
#define BUGP(x) cout << #x << " = " << x._1 << ", " << x._2 << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto _i:x) cout << _i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 1e-7
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

int n, ans, lis[100005];

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  FOR (i, 1, n) cin >> lis[i];
  FOR (i, 1, n - 1) if (lis[i] == i) swap(lis[i], lis[i + 1]), ans++;
  if (n == lis[n]) ans++;
  cout << ans;
}

Measured memory_bytes: 640
import sys
import os

def file_input():
    f = open('../Beginner_Contest_166/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()

    N,K=map(int, input().split())
    has_k=[False]*N
    count=0

    for i in range(K):
        d=int(input())
        A=list(map(int,input().split()))
        for a in A:
            if not has_k[a-1]:
                # print(a)
                has_k[a-1]=True
                count+=1

    print(N-count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
N = int(input())
a = list(map(int, input().split()))

c = [0,0,0,0]
for x in a:
    c[x % 4] += 1

if (c[1]==0) and (c[3]==0):
    print('Yes')
elif c[1] + c[3] < c[0] + 1:
    print('Yes')
elif (c[1] + c[3] == c[0] + 1)and(c[2] == 0):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;

vector<vector<int> > g;  // to
vector<ll> pt;
ll sum;
vector<ll> ans;

void dfs(int par, int curr)
{
	int siz = (int)g[curr].size();
	int i;
	sum += pt[curr];
	ans[curr] = sum;
	for (i = 0; i < siz; i++) {
		int next = g[curr][i];
		if (next == par) continue;
		dfs(curr, next);
	}
	sum -= pt[curr];

	return;
}

void solve()
{
	int n, Q;
	scanf("%d%d", &n, &Q);
	g.resize(n);
	pt.resize(n);
	ans.resize(n);
	int i;
	for (i = 0; i < n - 1; i++) {
		int a, b;
		scanf("%d%d", &a, &b); a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (i = 0; i < Q; i++) {
		int p, x;
		scanf("%d%d", &p, &x); p--;
		pt[p] += x;
	}
	sum = 0;
	dfs(-1, 0);

	for (i = 0; i < n; i++) {
		printf("%lld", ans[i]);
		if (i < n - 1) printf(" ");
	}
	printf("\n");
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 28928
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N;
  cin >> N;

  vector<long long> a(3*N);
  for(int i = 0;i < 3*N;i++) {
    cin >> a.at(i);
  }

  sort(a.begin(),a.end());
  long long sum = 0;
  for(int i = N;i < 3*N;i+=2) {
    sum += a.at(i);
  }

  cout << sum << endl;
}


Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if (b==c) printf("%d\n",a);
  else if (c==a) printf("%d\n",b);
  else printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  long x=0,y=0;
  for(long i=0;i<N;i++){
    long t,a;cin>>t>>a;
    long c=max(max(x/t,y/a),1L);while(t*c<x||a*c<y)c++;
    x=t*c;y=a*c;
  }
  cout<<x+y;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map as Map
import Data.Map (Map)
import qualified Data.Maybe as Maybe

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

fs :: [Int]
fs = [2 * (5 ^ n) | n <- [1..100], 2 * (5 ^ n) <= 1000000000000000000]

-- dfacto100 :: Int -> Int
-- dfacto100 n
-- 	| n == 0    = 12
-- 	| n < 50    = n `div` 10
-- 	| otherwise = n `div` 10 + 1
--
dfacto :: Int -> Int
dfacto n
	| n `mod` 2 /= 0 = 0
	| otherwise = sum $ map (n `div`) fs

main :: IO ()
main = do
	n <- readLn
	print $ dfacto n


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

int main() {
    int N;

    cin >> N;

    int number = N;
    int sum = 0;
    while (true) {
        sum += N % 10;
        N /= 10;
        if (N == 0) {
            break;
        }
    }

    if (number % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <map>
#include <tuple>
using namespace std;


int main()
{
    long n, x, total = 1000;
    cin >> n;
    vector<long> a(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[i] = x;
    }
    for (int i = 0; i < n - 1; i++) {
        if (a[i] < a[i + 1]) {
            total = total % a[i] + (total / a[i]) * a[i + 1];
        }
    }
    cout << total;
    return 0;
}

Measured memory_bytes: 3192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_126
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nk = ReadInts();
            int n = nk[0];
            int k = nk[1];
            double res = 0;
            for(int i = 1; i <= n; i++)
            {
                int tmp = i;
                int cnt = 0;
                while (tmp < k)
                {
                    cnt++;
                    tmp *= 2;
                }
                res += 1.0 / n / Pow(2, cnt);
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    char c; cin >> c;
    if(c >= 'A' && c <= 'Z') cout << 'A' << endl;
    else cout << 'a' << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <cmath>
using namespace std;
#pragma warning (disale: 4996)

long long N, L, cnt; string S[100009]; pair<long long, long long> I[400009]; vector<long long>dep;

void dfs(long long pos, long long depth) {
	if (I[pos].first == -1 && I[pos].second == -1)return;
	if (I[pos].first == -1)dep.push_back(L + 1 - (depth + 1)); else dfs(I[pos].first, depth + 1);
	if (I[pos].second == -1)dep.push_back(L + 1 - (depth + 1)); else dfs(I[pos].second, depth + 1);
}
int main() {
	cin >> N >> L; I[0] = make_pair(-1, -1); cnt = 1;
	for (int i = 0; i < N; i++) {
		cin >> S[i]; long long cx = 0;
		for (int j = 0; j < S[i].size(); j++) {
			if (S[i][j] == '0') {
				if (I[cx].first == -1) { I[cnt] = make_pair(-1, -1); I[cx].first = cnt; cx = cnt; cnt++; }
				else { cx = I[cx].first; }
			}
			if (S[i][j] == '1') {
				if (I[cx].second == -1) { I[cnt] = make_pair(-1, -1); I[cx].second = cnt; cx = cnt; cnt++; }
				else { cx = I[cx].second; }
			}
		}
	}
	dfs(0, 0);
	long long grundy = 0;
	for (int i = 0; i < dep.size(); i++) {
		long long U = dep[i], V = 1;
		while (U % 2 == 0) { U /= 2; V *= 2; }
		grundy ^= V;
	}
	if (grundy == 0)cout << "Bob" << endl;
	else cout << "Alice" << endl;
	return 0;
}

Measured memory_bytes: 8568
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> a(N);
    ll cnt = 0;
    rep(i, N)
    {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            while (a[i] % 2 == 0) {
                a[i] /= 2;
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.

// x 以下の自然数でdで割り切れるものの個数
int64 f(int64 x, int64 d) {
    return x / d;
}

int64 gcd(int64 a, int64 b) {
    if (a < b) return gcd(b, a);
    int64 r;
    while((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

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

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

    int64 a, b, c, d;
    cin >> a >> b >> c >> d;

    a--;
    int64 y = b - ( f(b, c) + f(b, d) - f(b, lcm(c, d)) );
    int64 x = a - ( f(a, c) + f(a, d) - f(a, lcm(c, d)) );
    print(y - x);

    return 0;
}



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

int main() {
	string S;
	int K;
	cin >> K >> S;
	if (S.size()<=K) {
		cout << S << endl;
	}
	else {
		cout << (S.substr(0,K)+"...") << endl;
	}
	return 0;
}


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

using namespace std;

int GCD(int a, int b)
{
    if(a == 0)
        return b;
    return GCD(b %a,a);
}

int main()
{

    int n;
    int arr[100005];
    cin >> n;
    for(int i =0;i<n;i++)
        cin >> arr[i];
    //cout << GCD(80,10);

    int ans = arr[0];
    for(int i = 1;i<n;++i)
    {
        ans = GCD(ans, arr[i]);
    }

    cout << ans;
}


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

typedef pair<int, int> P;
const int MAX_T = 1e5 + 4;
int zikan[MAX_T];

int main()
{
    int N, C;
    scanf("%d %d", &N, &C);
    vector<P> ch[C];
    for(int i = 0; i < N; ++i) {
        int s, t, c;
        scanf("%d %d %d", &s, &t, &c);
        --c;
        ch[c].push_back(P(s, t));
    }
    for(int i = 0; i < C; ++i) {
        sort(ch[i].begin(), ch[i].end());
    }

    /*
    for(int i = 0; i < C; ++i) {
        for(int j = 0; j < ch[i].size(); ++j) {
            cout << ch[i][j].first << " " << ch[i][j].second << " ";
        }
        cout << endl;
    }
    */

    vector<P> ch1[C];
    for(int i = 0; i < C; ++i) {
        int j = 0, cur = 0;
        for(int j = 0; j < ch[i].size(); ++j) {
            int s = ch[i][j].first,
                t = ch[i][j].second;
            if(cur > 0 && ch1[i][cur-1].second == s) {
                ch1[i][cur-1].second = t;
            } else {
                ch1[i].push_back(P(s-1, t));
                ++cur;
            }
        }
    }

    /*
    for(int i = 0; i < C; ++i) {
        for(int j = 0; j < ch1[i].size(); ++j) {
            cout << ch1[i][j].first << " " << ch1[i][j].second << " ";
        }
        cout << endl;
    }
    */
    int zmx = 0;
    for(int i = 0; i < C; ++i) {
        for(int j = 0; j < ch1[i].size(); ++j) {
            int s = ch1[i][j].first,
                t = ch1[i][j].second;
                zmx = max(zmx, t);
            for(int k = s; k < t; ++k)
                ++zikan[k];
        }
    }
    int res = 0;
    /*
    for(int i = 0; i <= zmx; ++i) cout << i << ":" << zikan[i] << endl;
    cout << endl;
    */
    for(int i = 0; i <= zmx; ++i) res = max(res, zikan[i]);
    cout << res << endl;
    return 0;
}

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

//Minimum Macros
using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;
#define rep(_i,_n) for(ll _i = 0; _i < _n; ++_i)
#define rep2(_i,_s,_n) for(ll _i = _s; _i < _n; ++_i)
#define elif else if
//Vector Macros
#define vec vector
#define append(_x) push_back(_x)
#define fullSort(_a) sort(_a.begin(), _a.end())
#define inputVecI(_name, _n) vec<int> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecL(_name, _n) vec<long> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecLL(_name, _n) vec<ll> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecUL(_name, _n) vec<ul> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecULL(_name, _n) vec<ull> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecS(_name, _n) vec<string> _name(_n);rep(_i, _n)cin >> _name[_i];
#define maxIdx(_name) distance(_name.begin(), max_element(_name.begin(), _name.end()))
#define printVec(_vec) cout << "{";rep(i, _vec.size()-1)cout << _vec[i] << ",";cout << _vec[_vec.size()-1];cout << "}\n";
//Graph Macros
using Graph = vec<vec<long>>;
inline vec<long> BFS(Graph _g, long start){
  vec<long> _ans(_g.size(), -1); _ans[start] = 0; queue<long> _que; _que.push(start);
  while(!_que.empty()){
    long _target = _que.front(); _que.pop();
    for(long _towhere : _g[_target]){
      if(_ans[_towhere] == -1){
        _ans[_towhere] = _ans[_target] + 1; _que.push(_towhere);
      }
    }
  }
  return _ans;
}

int main()
{
    ll N, K, nowtown, nexttown;
    cin >> N >> K;
    inputVecLL(A, N);
    vec <ll> townidx(N, -1);
    townidx[0] = 0;
    nowtown = 0;
    rep2(i, 1, K + 1){  //i = 1, 2, 3, ...., K
      nexttown = A[nowtown] - 1;
      if(townidx[nexttown] != -1){
        ll buf = townidx[nexttown] + (K - townidx[nexttown]) % (i - townidx[nexttown]);
        rep(j, N){
          if(townidx[j] == buf){
            cout << j + 1 << endl;
            return 0;
          }
        }
      }
      else{
        townidx[nexttown] = i;
        nowtown = nexttown;
      }
    }
    cout << nowtown + 1 << endl;
    return 0;
}


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

using namespace std;

int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int x = c - a, y = d - b;

  cout << c - y << " " << d + x << " " << a - y << " " << b + x << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
#define S 2001
#define N 200200
#define mod 1000000007
#define rep(x, a, b) for(int x=a; x<=b; x++)
#define drp(x, a, b) for(int x=a; x>=b; x--)
int n, a[N], b[N], ans, f[2*S+10][2*S+10], fac[4*S+10], inv[4*S+10];
void add(int &f, int g){
	f+=g;
	if(f>=mod) f-=mod;
}
int C(int n, int m){
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int power(int a, int k){
	int ret=1;
	while(k)
	{
		if(k&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod; k>>=1;
	}
	return ret;
}
int main(){
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d%d", a+i, b+i);
	rep(i, 1, n) f[S-a[i]][S-b[i]]++;
	rep(i, 1, 2*S) rep(j, 1, 2*S) f[i][j]=(1ll*f[i][j]+f[i-1][j]+f[i][j-1])%mod;
	rep(i, 1, n) add(ans, f[S+a[i]][S+b[i]]);
	fac[0]=1;
	rep(i, 1, 8000) fac[i]=1ll*fac[i-1]*i%mod;
	inv[8000]=power(fac[8000], mod-2);
	drp(i, 8000, 1) inv[i-1]=1ll*inv[i]*i%mod;
	rep(i, 1, n) ans=(ans+mod-C(2*a[i]+2*b[i], 2*a[i]))%mod;
	printf("%d\n", 1ll*ans*(mod+1>>1)%mod);
}

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




string s;
cin>>s;
ll c=0;
ll i=0;
while(i<s.size())
{
    if(s[i]=='7')
    {
        c=1;
    }
    else
    {
        
    }
    
    i++;
}
    if(c==1)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }

return 0;    
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

struct UnionFind {
    vector< int > data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int find(int k) {
        if(data[k] < 0) return k;
        return data[k] = find(data[k]);
    }

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

    int size(int k) {
        return -data[find(k)];
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind friends(n);
    int ans = 1;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        friends.unite(a, b);
        ans = max(ans, friends.size(a));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4044
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @a, @b = gets.split.map(&:to_i)
  end

  def solve
    return "+" if a + b == 15
    return "*" if a * b == 15
    return "x"
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

short dp[2][1 << 20];
template<int SZ> int solve(int n, int m){
	if(SZ / 2 >= m) return solve<SZ / 2>(n, m);
	
	int ans = 0;
	vector<bitset<SZ>> b(n);
	
	rep(i, n){
		string s; cin >> s;
		rep(j, m) if(s[j] == '1') b[i][j] = 1;
	}
	rep(mask, 1 << n){
		int k = __builtin_popcount(mask);
		//if(k % 2 || ans >= k) continue;
		
		bitset<SZ> sum;
		rep(i, n) if(mask & 1 << i) sum ^= b[i];
		if(sum.none()) ans = max(ans, k);
	}
	return ans;
};
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m;
	while(cin >> n >> m, n){
		if(m > 20){
			cout << solve<512>(n, m) << endl;
		}
		else{
			memset(dp, -1, sizeof(dp));
			vi b(n);
			rep(i, n){
				string s; cin >> s;
				rep(j, m) if(s[j] == '1') b[i] |= 1 << j;
			}
			
			dp[0][0] = 0;
			int cur = 0, next = 1;
			rep(i, n){
				memcpy(dp[next], dp[cur], sizeof(dp[cur]));
				rep(j, 1 << m) if(dp[cur][j] >= 0){
					dp[next][j ^ b[i]] = max(dp[next][j ^ b[i]], (short)(dp[cur][j] + 1));
					//dp[next][j] = max(dp[next][j], dp[cur][j]);
				}
				swap(cur, next);
			}
			cout << dp[cur][0] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 7280