akhauriyash/Code-Regression huggingface dataset:
/*
13:11 - 
 */

#include<algorithm>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<climits>
#include<cassert>
#include<deque>

#define MAX 20010
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)

using namespace std;

struct Point{
  int x,y;
  char c;
  Point(int x=IINF,int y=IINF,char c='$'):x(x),y(y),c(c){}
  bool operator < (const Point& a)const{
    return ( (x!=a.x) ? (x < a.x) : (y < a.y) );
  }
};

int n;
vector<int> G[MAX];
char color[MAX];

inline void makeGraph(const vector<Point>& vec,map<Point,int>& Index){
  rep(i,n)G[i].clear();
  rep(i,vec.size()){
    Point p1 = vec[i];
    Point p2 = p1;
    assert(Index.find(vec[i]) != Index.end());
    int cur = Index[vec[i]];
    if(p1.c == 'x')p2.x++;
    else if(p1.c == 'y')p2.y++;
    else assert(false);
    //cout << "Futon( (" << p1.x << "," << p1.y << ") , (" << p2.x << "," << p2.y << ") )" << endl;

    for(int y=p1.y-1;y<=p2.y+1;y++){
      for(int x=p1.x-1;x<=p2.x+1;x++){
	if(x == p1.x-1 && y == p1.y-1)continue;
	if(x == p2.x+1 && y == p1.y-1)continue;
	if(x == p1.x-1 && y == p2.y+1)continue;
	if(x == p2.x+1 && y == p2.y+1)continue;
	//cout << "check => (" << x << "," << y << ")" << endl;
	if(Index.find(Point(x,y)) != Index.end()){

	  int next = Index[Point(x,y)];
	  if(cur == next)continue;

	  G[cur].push_back(next);
	}
      }
    }
  }

  rep(i,n){
    sort(G[i].begin(),G[i].end());
    G[i].erase(unique(G[i].begin(),G[i].end()),G[i].end());
  }
}

bool dfs(int cur,char c){
  color[cur] = c;
  char rec = ((c == 'w')?'b':'w');
  for(int i=0;i<G[cur].size();i++){
    if(color[G[cur][i]] == c)return false;
    if(color[G[cur][i]] == 'x' && !dfs(G[cur][i],rec))return false;
  }
  return true;
}

int main(){

  while(cin >> n,n){
    // out = false;
    map<Point,int> Index;
    vector<Point> input;
    int dex = 0;
    for(int i=0;i<n;i++){
      int x,y;
      char c;
      cin >> x >> y >> c;
      Point p;
      if(c == 'x'){
	p = Point(x+1,y);
      } else {
	p = Point(x,y+1);
      }
      input.push_back(Point(x,y,c));
      Index[Point(x,y)] = Index[p]= dex++;
      color[i] = 'x';
    }
    assert(dex == n);
    makeGraph(input,Index);

    for(int i=0;i<n;i++){
      if(color[i] == 'x'){
	if(!dfs(i,'w')){
	  cout << "No" << endl;
	  goto Fin;
	}
      }
    }
    cout << "Yes" << endl;
  Fin:;


  }
  return 0;
}

Measured memory_bytes: 6188
s = input()
l=len(s)
s1=0
s0=0
l0=[]
l1=[]
for i in range(l):
    l0.append(str(i%2))
    l1.append(str((i+1)%2))
l0="".join(l0)
l1="".join(l1)
for i in range(l):
    if(l1[i]!=s[i]):
        s1=s1+1
    if(l0[i]!=s[i]):
        s0=s0+1
print(min(s0,s1))

Measured memory_bytes: 15860
#include<stdio.h>
static const int N =100;

void selectionSort(int *A, int n){
  int i,j,miji,key,count=0;
  for(i=0;i<n;i++){
    miji=i;
    for(j=i;j<n;j++){
      if(A[j]<A[miji])	miji=j;
    }
    key=A[i];
    A[i]=A[miji];
    A[miji]=key;
    if(miji!=i) count++;
  }
  for(i=0;i<n-1;i++)printf("%d ",A[i]);
  printf("%d\n",A[i]);
  printf("%d\n",count);
}

int main(){
  int n,i;
  int A[N];

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  selectionSort(A,n);

  return 0;
}

Measured memory_bytes: 600
using System;

class Program
{
  struct Vector
  {
    public int x, y;
  }

  private static bool isOrthogonal(Vector v1, Vector v2)
  {
    return v1.x*v2.x + v1.y*v2.y == 0;
  }

  private static bool isParallel(Vector v1, Vector v2)
  {
    return v2.x*v1.y - v2.y*v1.x == 0;
  }
  public static void Main()
  {
    int n = int.Parse(Console.ReadLine());

    for(int i=0; i<n; i++)
    {
      string[] s = Console.ReadLine().Split(' ');
      Vector v1, v2;
      v1.x = int.Parse(s[2]) - int.Parse(s[0]);
      v1.y = int.Parse(s[3]) - int.Parse(s[1]);
      v2.x = int.Parse(s[6]) - int.Parse(s[4]);
      v2.y = int.Parse(s[7]) - int.Parse(s[5]);

      if(isOrthogonal(v1, v2)) {
        Console.WriteLine("1");
      } else if(isParallel(v1, v2)) {
        Console.WriteLine("2");
      } else {
        Console.WriteLine("0");
      }
    }
  }
}

Measured memory_bytes: 8996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 110;
const int max_v = 100100;
ll dp[N][max_v];
ll w[N];
ll v[N];
int n, max_w;

int main() {
    cin >> n >> max_w;
    for(int i = 1; i <= n; i ++) {
        cin >> w[i] >> v[i];
    }
    memset(dp, 0x3f3f3f3f, sizeof dp);
    dp[0][0] = 0;
    for(int i = 1; i <= n; i ++) {
        for(int j = 0; j <= max_v; j ++) {
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if(j >= v[i]) dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
        }
    }
    for(int i = max_v-1; i >= 0; i --) {
        if(dp[n][i] <= max_w) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

int N ;
int x,y,z ;
int a,b,c ;

int main()
{
	cin >> N ;

	for( int i = 0 ; i < N ; i ++ )
	{
		cin >> a >> b >> c ;
		x = max( a , max(b,c) ) ;

		if( x == a )
		{
			y = max( b,c ) ;
			z = min( b,c ) ;
		}
		else if( x == b )
		{
			y = max( a,c ) ;
			z = min( a,c ) ;
		}
		else if( x == c )
		{
			y = max( a,b ) ;
			z = min( a,b ) ;
		}

		if( ((x*x) == ((y*y) + (z*z))) )
		{
			cout << "YES" << endl ;
		}
		else
		{
			cout << "NO" << endl ;
		}
	}
}

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

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

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    
    ll l = c*d/gcd(c,d);
    ll total = b-a+1 - (b/c - (a-1)/c + b/d - (a-1)/d) + (b/l - (a-1)/l );
    cout << total << endl;
    
    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<deque>
using namespace std;
bool used[100005]={false};
int d[100005]={0};
int main()
{
	memset(d,-1,sizeof(d));
	int n;
	cin>>n;
	deque <int> q;
	q.push_back(1);
	d[1]=0;
	while(q.size())
	{
		int u=q.front();
		q.pop_front();
		if(used[u])continue;
		if(u==0)
		    break;
		used[u]=true;
		int f=(u*10)%n;
		if(!used[f])
		{
			q.push_front(f);
		    if(d[f]==-1||d[f]>d[u])d[f]=d[u];
		}    
		int z=(u+1)%n;
		if(!used[z])
		{
			q.push_back(z);
		    if(d[z]==-1||d[z]>d[u]+1)d[z]=d[u]+1;
		}    
	}
	cout<<d[0]+1;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 10000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	string s, t;
	cin >> s >> t;
	string ans = "";
	REP(i, s.size() - t.size() + 1){
		int x = 1;
		REP(j, t.size()){
			if(s[i+j] != t[j] && s[i+j] != '?') x = 0;
		}
		if(x){
			string tmp = s;
			REP(j, s.size()){
				if(i <= j && j <= i + t.size() - 1) tmp[j] = t[j-i];
				else if(s[j] == '?') tmp[j] = 'a';
				ans = tmp;
			}
		}
	}
	if(ans == "") cout << "UNRESTORABLE" << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
//\\                            ||                     ||
            ////          //  \\                           ||                     ||
                         //    \\          //\\    //\\    ||                     ||
            ////        //      \\       //   \\  //  \\   ||                     ||
            ////       ____________     ||     \\//    ||  ||_______      ________||
            ////      //          \\    ||             ||  ||______\\    //_______||
            ////     //            \\   ||             ||  ||       ||   ||       ||
            ////    //              \\  ||             ||  ||_______||   ||_______||
            ////   //                \\ ||             ||  ||______//     \\______||





                     /*WHO CARES IF ONE MORE LIGHT GOES OUT ?
                           IN A SKY OF A MILLION STARS
                               IT FLICKERS,FLICKERS
                       WHO CARES WHEN SOMEONE'S TIME RUNS OUT ?
                            IF A MOMENT IS ALL WE ARE.
                       WHO CARES IF ONE MORE LIGHT GOES OUT ?
                                WELL I DO...*/
#include<bits/stdc++.h>
using namespace std;
long long int fa[1022];

long long int powe(long long int d,long long int s)
{
    if(s==1) return d;
    else if(s==0) return 1;
    else
    {
        long long int u,v=d;
        for(u=1;u<s;u++)
        {
            d=d*v;
        }
        return d;
    }
}
long long int phi(long long int n)
{
    double result=n;
    for (long long int p=2;p*p<=n;++p){
        if (n%p==0){
            while(n%p==0)
                n/=p;
            result*=(1.0-(1.0/(double)p));
        }
    }
    if(n>1)
        result*=(1.0-(1.0/(double)n));

    return (long long int)result;
}
long long int bigmod(long long int a, long long int b,long long int m)
{
    long long int r;
    if(b==0) return 1;
    if(b%2==0)
    {
        r=bigmod(a,b/2,m)%m;
        r=(r*r)%m;
        return  r;
    }
        return ((a%m)*bigmod(a,b-1,m)%m)%m;
}
int main()
{
    int n,count=0,i;
    cin>>n;
    int ara[n+1];
    for(i=1;i<=n;i++) cin>>ara[i];
    sort(ara+1,ara+n+1);
    cout<<ara[(n/2)+1]-ara[(n/2)];
    
    
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    ll m;cin>>m;
    vector<int> h(n);
    For(i,0,n) cin>>h[i];
    vector<vector<int>> tree(n);
    For(i,0,m){
        int a,b;cin >> a >> b;
        a--;
        b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    For(i,0,n){
        int otherH=-1;
        for(auto j:tree[i]){
            otherH=max(otherH,h[j]);
        }
        if(otherH<h[i]) ans++;
    }
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 8800
package main

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

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	h := nextInt()
	w := nextInt()

	ans := make([][]int, h)
	for i := 0; i < h; i++ {
		ans[i] = make([]int, w)
	}

	for i := 0; i < h; i++ {
		s := nextString()
		for j := 0; j < w; j++ {
			if s[j] == '#' {
				ans[i][j] += 10
				for x := -1; x <= 1; x++ {
					for y := -1; y <= 1; y++ {
						if (0 <= i+y && i+y < h) && (0 <= j+x && j+x < w) {
							ans[i+y][j+x] += 1
						}
					}
				}

			}
		}
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if ans[i][j] >= 10 {
				fmt.Print("#")
			} else {
				fmt.Print(ans[i][j])
			}
		}
		fmt.Println()
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        
        int[][] A = new int[n][m];
        int[][] B = new int[m][l];
        
        for (int i = 0; i < n ; i++) {
            for (int j = 0; j < m; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < l; j++) {
                B[i][j] = sc.nextInt();    
            }
        }
        
        long[][] result = new long[n][l];
        
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                for (int k = 0; k < m; k++) {
                    result[i][j] += A[i][k] * B[k][j];
                }
            }
        }
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                if (j != l - 1) {
                    System.out.printf("%d ", result[i][j]);
                }
                else {
                    System.out.printf("%d\n", result[i][j]);
                }
            }
        }
    }
}

Measured memory_bytes: 63052
#include <bits/stdc++.h>
using namespace std;
int n,m,cnt[26];
char buf[103];
int s1,s2,s4;
int main() {
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;++i) {
        scanf("%s",buf);
        for (int j=0;j<m;++j) cnt[buf[j]-'a']++;
    }
    if (n%2 && m%2) s1=1;else s1=0;
    if (n%2) s2+=m-s1;
    if (m%2) s2+=n-s1;
    s4=n*m-s1-s2;
    for (int i=0;i<26;++i) {
        while (cnt[i]>=4 && s4>=4) cnt[i]-=4,s4-=4;
        while (cnt[i]>=2 && s2>=2) cnt[i]-=2,s2-=2;
        while (cnt[i] && s1) cnt[i]--,s1--;
        if (cnt[i]) {
            puts("No");
            return 0;
        }
    }
    if (s4>0 || s2>0 || s1>0) {
        puts("No");
        return 0;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 384
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)

#define rep2(i, N, s) for(int (i) = (s); (i) < (N) + (s); (i) ++)
#define rrep(i, N) for(int (i) = (N) - 1; (i) >= (0); (i) --)
#define rrep2(i, N, s) for(int (i) = (s); (i) >= (s) - (N) + 1; (i) --)
#define INF 1e9

#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

typedef long long ll;
typedef  pair<int, int> pint;

int main(){
    ll N;
    cin >> N;
    vector<char> res;
    while(N != 0){
        if(N % -2 == 0){
            res.push_back('0');
        }else{
            res.push_back('1');
            N -= 1;
        }
        N /= (-2);
    }
    rep(i, res.size()){
        cout << res[res.size() - i - 1];
    }
    if(res.size() == 0){
        cout << '0';
    }
    cout << endl;

}


Measured memory_bytes: 256
# ABC 156 A
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nms = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
n,r=nm()
if n>=10:
    print(r)
elif n<10:
    print(r+100*(10-n))



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

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

int main() {
    vector<int> a(3);
    rep(i, 3) { cin >> a[i]; }
    sort(a.begin(), a.end());
    cout << abs(a[0] - a[1]) + abs(a[1] - a[2]) << endl;
    return 0;
}

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

using namespace std;

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

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

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

    vector<int> A(N + 1, 0);
    rep(i, N) {
        if (S[i] == '<') {
            A[i + 1] = A[i] + 1;
        }
    }

    rrep(j, N - 1, 0) {
        if (S[j] == '>') {
            A[j] = max(A[j + 1] + 1, A[j]);
        }
    }
    ll ans = accumulate(A.begin(), A.end(), 0LL);
    cout << ans << '\n';
}

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


Measured memory_bytes: 2844
N,A,B = (int(x) for x in input().split())

sum = 0
for a in range(N+1):
  
  a = str(a)
  a_list = list(a)
  a_list_i = [int(a) for a in a_list]

  a_list_i_sum = 0
  for b in a_list_i:
    a_list_i_sum = a_list_i_sum + b
  if a_list_i_sum >=A and a_list_i_sum <= B:
    sum = sum + int(a)

print(sum)

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

x, y = 0, 0
for i in range(n):
    dif = b[i] - a[i]
    if dif > 0:
        x += dif // 2
    else:
        y += -dif

print("Yes" if x >= y else "No")

Measured memory_bytes: 10596
#include <bits/stdc++.h>
        using namespace std;
        #define int long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18

        bool compare(pair<int,int> a,pair<int,int> b){
            if(a.first==b.first)
                return a.second<b.second;
            return a.first<b.first;
        }

        signed main() {
 
     
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        string s;
        cin>>s;
        if(s=="ABC")
            cout<<"ARC";
        else
            cout<<"ABC";
        return 0;
    }

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    
    ll n;
    cin >> n;
    for (ll i=0;i<n;i++){
        ll a;
        cin >> a;
        if(a % 2 == 1){
            cout << "first" << endl;
            goto Exit;
        }
    }
    cout << "second" << endl;
    Exit:
    ;

}




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

using namespace std;

#define sz(vec) ( (int)(vec).size() )
using LL = long long;

int n;
vector<LL> a;

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

    cin >> n;
    a.assign(n, 0);
    for (int i = 0; i < n; ++i) cin >> a[i];

    LL sumA = accumulate(a.begin(), a.end(), 0LL);
    LL pref = 0, ans = 1e18;
    for (int i = 0; i + 1 < n; ++i) {
        pref += a[i];
        ans = min(ans, abs(sumA - (pref << 1) ) );
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 1792
n, m = [int(item) for item in input().split()]
xyz = [[int(item) for item in input().split()] for _ in range(m)]

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

UF = UnionFind(n)
for x, y, z in xyz:
    x -= 1
    y -= 1
    if not UF.same_check(x, y):
        UF.union(x, y)

s = set() 
for i in range(n):
    s.add(UF.find(i))
    
print(len(s))

Measured memory_bytes: 34920
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int x;
    cin >> x;
    if(x < 600) cout << '8' << endl;
    else if(x < 800) cout << '7' << endl;
    else if(x < 1000) cout << '6' << endl;
    else if(x < 1200) cout << '5' << endl;
    else if(x < 1400) cout << '4' << endl;
    else if(x < 1600) cout << '3' << endl;
    else if(x < 1800) cout << '2' << endl;
    else cout << '1' << endl;
}

Measured memory_bytes: 3652
import sys

class Dice(object):
    def __init__(self, dice):
        self.__dice = dice

    def roll_north(self):
        self.__dice = (self.__dice[1], self.__dice[5], self.__dice[2],
                       self.__dice[3], self.__dice[0], self.__dice[4])

    def roll_south(self):
        self.__dice = (self.__dice[4], self.__dice[0], self.__dice[2],
                       self.__dice[3], self.__dice[5], self.__dice[1])

    def roll_west(self):
        self.__dice = (self.__dice[2], self.__dice[1], self.__dice[5],
                       self.__dice[0], self.__dice[4], self.__dice[3])

    def roll_east(self):
        self.__dice = (self.__dice[3], self.__dice[1], self.__dice[0],
                       self.__dice[5], self.__dice[4], self.__dice[2])

    def number(self, face_id):
        return self.__dice[face_id - 1]

    def equals(self, dice):
        my_pair = {self.number(1): self.number(6),
                   self.number(2): self.number(5),
                   self.number(3): self.number(4),
                   self.number(4): self.number(3),
                   self.number(5): self.number(2),
                   self.number(6): self.number(1)}
        other_pair = {dice.number(1): dice.number(6),
                      dice.number(2): dice.number(5),
                      dice.number(3): dice.number(4),
                      dice.number(4): dice.number(3),
                      dice.number(5): dice.number(2),
                      dice.number(6): dice.number(1)}
        if my_pair != other_pair:
            return False
        if self.number(2) in (dice.number(3), dice.number(4)):
            dice.roll_west()
        while self.number(2) != dice.number(2):
            dice.roll_north()
        while self.number(1) != dice.number(1):
            dice.roll_west()
        return self.number(3) == dice.number(3)

dice1 = Dice([int(i) for i in sys.stdin.readline().split()])
dice2 = Dice([int(i) for i in sys.stdin.readline().split()])
if dice1.equals(dice2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 6816
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
using namespace std;

int N,M,C[3]; bitset<707> can;
bool chk[707][707]; int col[707];

void go(int x)
{
	C[col[x]]++;
	for (int y=1;y<=N;y++) if (!chk[x][y]){
		if (col[y]){
			if (col[x] + col[y] != 3){
				puts("-1");
				exit(0);
			}
		}
		else{
			col[y] = 3 - col[x];
			go(y);
		}
	}
}

int main()
{
	scanf ("%d %d",&N,&M);
	for (int i=1;i<=N;i++) chk[i][i] = 1;
	for (int i=0;i<M;i++){
		int x,y; scanf ("%d %d",&x,&y);
		chk[x][y] = chk[y][x] = 1;
	}

	can[0] = 1;
	for (int i=1;i<=N;i++) if (!col[i]){
		C[1] = C[2] = 0;
		col[i] = 1, go(i);
		can = (can << C[1]) | (can << C[2]);
	}

	int ans = N * (N - 1) / 2;
	for (int i=0;i<=N;i++) if (can[i]){
		int now = i * (i - 1) / 2 + (N - i) * (N - i - 1) / 2;
		if (ans > now)
			ans = now;
	}

	printf ("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
public class Watch {
  static void Main(string[] args) {
    int sec_input = int.Parse(System.Console.ReadLine());
    int hour = sec_input / 3600;
    int sec  = sec_input % 60;
    int min  = (sec_input - hour * 3600) / 60;
    System.Console.WriteLine("{0}:{1}:{2}", hour, min, sec);
  }
}

Measured memory_bytes: 9188
#include<iostream>
using namespace std;
int main(){
	int i, j, x, y;	
	while( cin >> x >> y ){
		
	if( x == 0 && y == 0 )
	break;
		
	for(i=0;i<y;i++)
		cout << "#";
	
	cout << "\n";
	
	for(i=1;i<x-1;i++) {
	for(j=0;j<y;j++) {
		
		if(j == 0 || j == y-1)
		cout << "#";
		
		else
		cout << ".";
	}
		cout << "\n";
	}
	
	for(i=0;i<y;i++)
		cout << "#";
		
	cout << "\n\n";
}
	return 0;
}


Measured memory_bytes: 3088
#include<iostream>
using namespace std;
int main(){
  
 string s;
  
   cin >> s;
  
  if(s == "abc" || s == "acb" || s == "bac" || s == "bca" || s == "cab" || s == "cba"){
    cout << "Yes" << std::endl; 
  }else{
   cout << "No" << std::endl; 
  }
  
  
  
  
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <utility>

using namespace std;

const int N = 100;

int main() {
	int n, m, sa, sb, d, ans;
	int a[N], b[N];
	pair<int, int> p;
	while(cin >> n >> m, n){
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		sa = sb = 0;
		ans = 2 * N;
		p = make_pair(0, 0);
		for(int i = 0;i < n;++i){
			cin >> a[i];
			sa += a[i];
		}
		for(int i = 0;i < m;++i){
			cin >> b[i];
			sb += b[i];
		}
		d = sa - sb;
		if(d & 1) {
			cout << -1 << endl;
		}
		else {
			d = d / 2;
			for(int i = 0;i < n;++i){
				for(int j = 0;j < m;++j){
					if(a[i] - b[j] == d && a[i] + b[j] < ans) {
						ans = a[i] + b[j];
						p = make_pair(a[i], b[j]);
					}
				}
			}
			if(ans != 2 * N) {
				cout << p.first << " " << p.second << endl;
			}
			else {
				cout << -1 << endl;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
typedef unsigned long long ull;
const int inf=103974182;
using namespace std;
int n;
ll c;
ll a[100005];
ll v[100005];
ll m[100005];
set <ll> squ;
ll maxn;

void func()
{
	memset(m,0,sizeof(m));
	ll now=0;
	for(int i=0;i<n;i++)
	{
		now+=v[i];
		m[i]=max(now-a[i],(i-1<0?0:m[i-1]));
	}
	maxn=max(maxn,m[n-1]);
	ll d=0;
	now=0;
	for(int i=n-1;i>=0;i--)
	{
		d=c-a[i];
		now+=v[i];
		maxn=max(maxn,now-d-d+(i-1<0?0:m[i-1]));
		maxn=max(maxn,now-d);
	}
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>c;
	for(int i=0;i<n;i++)
	{
		scanf("%lld%lld",a+i,v+i);
	}
	ll now=0;
	for(int i=n-1;i>=0;i--)
	{
		now+=v[i];
		m[i]=max(now-(c-a[i]),m[i+1]);
//		if(now-(c-a[i])) squ.insert(i);
	}
//	for(int i=0;i<n;i++)
//	{
//		cout<<m[i]<<endl;
//	}
	maxn=m[0];
	ll d=0;
	now=0;
	for(int i=0;i<n;i++)
	{
		d=a[i];
		now+=v[i];
//		cout<<now<<' '<<now-d-d+m[i+1]<<endl;
		maxn=max(maxn,now-d-d+m[i+1]);
		maxn=max(maxn,now-d);
//		maxn=max(maxn,now);
	}
	func();
	cout<<maxn<<endl;
	return 0;
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

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

const int maxN = 5e5 + 10;
const ll mod = 1e9 + 7;

int n, m;
ll fact[1000010], ifact[1000010];

ll power(ll a, ll b)
{
    ll r = 1;
    while (b)
    {
        if (b & 1)
        {
            r = r * a % mod;
        }
        b /= 2;
        a = a * a % mod;
    }
    return r;
}

void init()
{
    fact[0] = 1;
    for (int i = 1; i <= 1e6; ++i)
    {
        fact[i] = fact[i - 1] * i % mod;
    }
    ifact[1000000] = power(fact[1000000], mod - 2);
    for (int i = 999999; i >= 0; --i)
    {
        ifact[i] = ifact[i + 1] * (i + 1) % mod;
    }
}

ll nCk(int n, int k)
{
    return fact[n] * ifact[k] % mod * ifact[n - k] % mod;
}

ll nPk(int n, int k)
{
    return fact[n] * ifact[n - k] % mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    init();
    cin >> n >> m;
    ll ans = nPk(m, n) * nPk(m, n) % mod;
    for1(i, n)
    {
        ans += (i % 2 == 1 ? -1LL : 1LL) * nCk(m, i) * nPk(n, i) % mod * nPk(m - i, n - i) % mod * nPk(m - i, n - i) % mod;
        ans = (ans % mod + mod) % mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 19284
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    def calc_id(x, y):
        return min(x, y) * 10007 + max(x, y)

    from collections import defaultdict, Counter, deque
    from copy import copy

    n = int(readline())

    edge = defaultdict(list)
    count = Counter()

    for x in range(1, n + 1):
        a = list(map(int, readline().split()))
        count[calc_id(x, a[0])] += 0
        for j in range(n - 2):
            y = a[j]
            z = a[j + 1]
            u_id = calc_id(x, y)
            v_id = calc_id(x, z)
            edge[u_id].append(v_id)
            count[v_id] += 1

    ans = 0
    rem = n * (n - 1) // 2
    que = deque()
    for key, val in count.items():
        if val == 0:
            que.append(key)
    que_tomorrow = deque()

    while rem:
        ans += 1
        if not que:
            print(-1)
            return
        while que:
            cur_match = que.popleft()
            for nx_match in edge[cur_match]:
                count[nx_match] -= 1
                if count[nx_match] == 0:
                    que_tomorrow.append(nx_match)
            rem -= 1
        que = copy(que_tomorrow)
        que_tomorrow.clear()

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 240084
a, b, c, d = map(int, input().split())
ans = ''
ans += (d-b)*'U'
ans += (c-a)*'R'
ans += (d-b)*'D'
ans += (c-a)*'L'
ans += 'L'
ans += (d-b+1)*'U'
ans += (c-a+1)*'R'
ans += 'DR'
ans += (d-b+1)*'D'
ans += (c-a+1)*'L'
ans += 'U'
print(ans)

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

typedef long long ll;

int main()
{
    int h,w,i,j;
    cin >> h >> w;
    vector<vector<int>> c(10,vector<int>(10));
    for(i = 0;i < 10;++i){
        for(j = 0;j < 10;++j){
            cin >> c.at(i).at(j);
        }
    }
    int k;
    for(i = 0;i < 10;++i){
        for(j = 0; j < 10;++j){
            for(k = 0;k < 10;++k){
                c.at(j).at(k) = min(c.at(j).at(k),c.at(j).at(i) + c.at(i).at(k));
            }
        }
    }
    ll ans = 0;
    int a;
    for(i = 0;i < h;++i){
        for(j = 0;j < w;++j){
            cin >> a;
            if(a != -1){
                ans += c.at(a).at(1);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   int a,b,d,r;
   scanf("%d%d",&a,&b);

   d=a/b;
   r=a%b;
   double p,q,f;
   p=a;
   q=b;
   f=p/q;

   printf("%d %d %.5lf\n",d,r,f);

    return 0;
}



Measured memory_bytes: 2112
import collections

N, M = map(int,input().split())
H = list(map(int,input().split()))
a = []
b = []
loser = []

for i in range(M):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)

    if H[a[i]-1] > H[b[i]-1]:
        loser.append(b[i])

    elif H[a[i]-1] == H[b[i]-1]:
        loser.append(b[i])
        loser.append(a[i])

    elif H[a[i]-1] < H[b[i]-1]:
        loser.append(a[i])

X = len(collections.Counter(loser))
print(N-X)

Measured memory_bytes: 27756
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  ll n;
  cin >> n;
  string ans = "";
  rep(i, 10000) {
    n--;
    ll a = n % 26;
    char c = 'a' + a;
    ans.push_back(c);
    n /= 26ll;
    if (n <= 0) break;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
/*
*/
#include<bits/stdc++.h> 
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
//#define int long long 
#define LL long long 
#define rg register 
#define pt(x) printf("%d ", x);
#define Fin(x) {freopen(#x".in","r",stdin);}
#define Fout(x) {freopen(#x".out","w",stdout);}
using namespace std;
const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e9 + 7;
const double eps = 1e-9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}

int N, a[MAXN], K;
main() {
	N = read(); K = read();
	for(int i = 1; i <= N; i++) a[i] = read();
	sort(a + 1, a + N + 1);
	int ans = INF;
	for(int i = 1; i <= N - K + 1; i++) ans = min(ans, abs(a[i] - a[i + K - 1]));
	cout << ans;
    return 0;
}
/*

*/

Measured memory_bytes: 640
n = int(input())
vs = sorted([int(input()) for _ in range(n)])

def do(i):
    if i==0:
        return 0, 1
    else:
        return i+1, i-1
    
score = 0
for i in range(n//2):
    a, b = do(i)
    score += vs[-a-1] + vs[-b-1] - vs[i]*2
if n % 2 == 1:
    v = (vs[(n//2)+1] - vs[n//2]) - (vs[(n//2)] - vs[(n//2)-1])
    if v > 0:
        score += v
print(score)

Measured memory_bytes: 8284
import java.math.BigDecimal;

public class Main {

	public static void main(String[] args) {
		double money = 100000;
		int moneyNew = 0;
		int n = new java.util.Scanner(System.in).nextInt();

		for (int i = 0; i < n; i++) {
			money = money + money * 0.05;
			BigDecimal bd = new BigDecimal(money);
			BigDecimal bd2 = bd.setScale(-3, BigDecimal.ROUND_UP);
			money = +bd2.intValue();
		}

		System.out.println((int) money);

	}

}

Measured memory_bytes: 26388
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int cnt[26] = { 0 };
	string S; cin >> S;
	if (S.size() < 26) {
		for (int i = 0; i < S.size(); i++) {
			cnt[S[i] - 'a']++;
		}
		cout << S;
		for (int i = 0; i < 26; i++) {
			if (cnt[i] == 0) {
				cout << (char)(i + 'a') << endl;
				return 0;
			}
		}
	}
	else {
		bool flag = true;
		int po;
		for (int i = S.size() - 1; i > 0; i--) {
			if (S[i] > S[i - 1]) {
				if (i == S.size() - 1) {
					for (int j = 0; j < i - 1; j++) {
						cout << S[j];
					}
					cout << S[S.size() - 1] << endl;
					return 0;
				}
				else {
					for (int j = 0; j < i - 1; j++) {
						cout << S[j];
					}
					char tmp;
					for (int j = i; j < S.size(); j++) {
						if (S[j] > S[i - 1]) {
							tmp = S[j];
						}
					}
					cout << tmp << endl;
					return 0;
				}
			}
		}
		cout << "-1" << endl;
	}
}


Measured memory_bytes: 256
n = input()
m = input()

card = [x + 1 for x in xrange(2 * n)]

for i in xrange(m):
    k = input()
    if k == 0:
        b = card[n:2*n]
        card = card[:n] 

        for j in xrange(n):
            card.insert(2 * (j + 1) - 1, b[j])

    else:
        a = card[:k] 
        b = card[k:2*n]

        card = b + a
        
for i in card:
    print i

Measured memory_bytes: 4236
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    string s;
    cin >> s;
    set<char> st;
    rep(i, sz(s)) st.insert(s[i]);
    if (sz(st) == sz(s)) puts("yes");
    else puts("no");
}


Measured memory_bytes: 3560
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
int a,b;
int main()
{
 cin>>a>>b;
 if(a==b) {printf("Draw\n");return 0;}
 if(a==1 || a>b && b!=1) {printf("Alice\n");return 0;}
 if(b==1 || a<b && a!=1) {printf("Bob\n");return 0;}
 return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ans_num_lis = [0 for i in range(N)]
pre_ans_lis = [0 for i in range(N)]
ans_lis = [0 for i in range(N)]
for i in range(M):
  problem, result = input().split()
  problem_num = int(problem)
  if result == "WA":
    pre_ans_lis[problem_num-1] += 1
  if result == "AC" and not ans_num_lis[problem_num-1]:
    ans_num_lis[problem_num-1] = 1
    ans_lis[problem_num-1] = pre_ans_lis[problem_num-1]

print(sum(ans_num_lis), sum(ans_lis))

Measured memory_bytes: 11384
mod=1000000007
fact=[1 for i in range(3000000)]
for i in range(1,3000000):
    fact[i]=(fact[i-1]*i)%mod

def inv(a):
    a%=mod
    b=mod
    u=0
    v=1
    while a!=0:
        t=b//a
        b-=t*a
        a,b=b,a
        u-=t*v
        u,v=v,u
    if u<0:
        u+=mod
    return u

def c(n,r):
    return (fact[n]*inv(fact[n-r])*inv(fact[r]))%mod

r1,c1,r2,c2=map(int,input().split())
print((c(r2+c2+2,r2+1)-c(r2+c1+1,r2+1)-c(r1+c2+1,r1)+c(r1+c1,r1)+mod+mod)%mod)

Measured memory_bytes: 123368
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	cin >> s >> t;
	REP(i,SZ(t)){
		bool b = true;
		REP(j,SZ(t)){
			if(s[j] != t[(i+j)%SZ(t)]){
				b = false;
				break;
			}
		}
		if(b){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

int n;
int B[MAX_N];
int ans = 0;

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

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

    ans = B[1];
    for (int i=2; i<n; i++) {
        if (B[i] >= B[i-1]) {
            ans += B[i-1];
        } else {
            ans += B[i];
        }
    }

    ans += B[n-1];

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

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

    string s; cin >> s;
    int len = s.length();

    vector<ll> cum(len+5, 0);
    for(int i=0; i<len; ++i){
        if(s[i] == '1') cum[i] = 1 + (i == 0? 0:cum[i-1]);
        else cum[i] = i == 0? 0:cum[i-1];
    }
    
    ll ans = 0;
    for(int k=-1; k<len; ++k){
        if(k == -1){
            // a+b = L
            ans += modpow(2, cum[len-1]);
        }
        else{
            // a+b < Lについて、二つのビット列を左から比較した時にはじめて異なるビットが出てきた桁がk　つまりa+bのkビットは0でLのkビットは1
            if(s[k] == '0') continue;
            ans += modpow(2, k==0? 0:cum[k-1]) % mod * modpow(3, len-1-k);
        }
        chmod(ans);
    }

    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int cmp(int a,int b){
	return a>b;
}
int a[200010],b[200010],ans[200010],n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	memcpy(b,a,sizeof(a));
	sort(b+1,b+n+1,cmp);
	for(int i=1;i<=n;i++){
		if(a[i]==b[1])ans[i]=b[2];
		else ans[i]=b[1];
	}
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T1, class T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll N, M;
    cin >> N >> M;

    vector<vector<ll>> E(N);
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        --a;
        --b;
        E[a].emplace_back(b);
        E[b].emplace_back(a);
    }

    vector<ll> used(N, INF);
    used[0] = 0;

    queue<ll> que;
    que.emplace(0);

    while (!que.empty()) {
        ll cur = que.front();
        que.pop();
        for (auto to : E[cur]) {
            if (used[to] != INF) {
                continue;
            }
            used[to] = cur;
            que.emplace(to);
        }
    }

    for (auto &x : used) {
        if (x == INF) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    for (ll i = 1; i < N; ++i) {
        cout << used[i] + 1 << endl;
    }
}

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

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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    rep(i, h) {
        rep(j, w) {
            if(s[i][j] == '#') continue;
            else {
                int cnt = 0;
                rep(d, 8) {
                    int nx = j;
                    int ny = i;
                    nx += dx[d];
                    ny += dy[d];
                    if(nx < 0 || nx >= w) continue;
                    if(ny < 0 || ny >= h) continue;
                    if(s[ny][nx] == '#') cnt++;
                }
                s[i][j] = (char) (cnt + '0');
            }
        }
    }
    rep(i, h) {
        cout << s[i] << endl;
    }
    return 0;
}


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

queue<pair<int, int>> q;
vector<int> dx = {0, 0, -1, 1};
vector<int> dy = {-1, 1, 0, 0};
int cnt;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    
    for (int i = 0; i < H; ++i) {
        cin >> grid[i];
    }
    cnt = H * W;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (grid[i][j] == '#') {
                --cnt;
                q.emplace(i, j);
            }
        }
    }
    
    int step = 0;
    while (!q.empty()) {
        int size = q.size();
        if (cnt == 0) {
            break;  
        }
        while (size--) {
            auto p = q.front(); q.pop();
            int cx = p.first, cy = p.second;
            for (int i = 0; i < 4; ++i) {
                int nx = cx + dx[i];
                int ny = cy + dy[i];
                if (nx < 0 || nx >= H || ny < 0 || ny >= W || grid[nx][ny] == '#') {
                    continue;  
                }
                q.emplace(nx, ny);
                grid[nx][ny] = '#';
                --cnt;
            }
        }
        ++step;
    }
    
    cout << step << endl;
    return 0;
}

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

int main(){
  int A , B , C , K ;
  cin >> A >> B >> C >> K ;
  int sum = 0 ;
  for(int i =0 ; i<A;i++){
    if(i==K) break ;
    sum++;
  }
  for(int i =0 ; A+B+i<K ; i++){
    if(A+B+i>=K) break;
    sum--;
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 3636
using System;
using System.Linq;

namespace csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var w = int.Parse(Console.ReadLine());

            var output = "";
            for(var i=0; i<S.Length; i++){
                if(i%w == 0){
                    output += S[i];
                }
            }
            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define INF (1e9 + 7)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  map<string, int> s;
  vector<int> t(N);
  REP(i, N){
    string S;
    int T;
    cin >> S >> T;
    s[S] = i;
    t[i] = T;
  }
  string X; cin >> X;
  int ans = 0;
  if(s[X] == N - 1){
    cout << 0 << endl;
    return 0;
  }else{
    for(int i = s[X] + 1; i < N; i++){
      ans += t[i]; 
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256