akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

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

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

void solve() {
    int n;
    cin >> n;
    int x = 0;
    for (int i = 1; i <= n; i++) {
        x = (x * 10 + 7) % n;
        if (x == 0) {
            cout << i;
            return;
        }
    }
    cout << -1;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();

    return 0;
}

Measured memory_bytes: 3668
#sort＞＞イコールならマイナス
#input
N = int(input())

#複数段の整数を配列に入力
d=[int(input()) for i in range(N)]
count = N

#sort
d.sort()

for n in range(0,N):
    if d[n-1] == d[n]:
        count -=1

if count == 0:
    count= 1
#output
print(count)

Measured memory_bytes: 3060
N, M = map(int, input().split())
foods = [0]*(M+1)

for i in range(N):
  person = list(map(int, input().split()))
  for j in range(1,M+1):
    if j in person[1:]:
      foods[j] += 1
ans = 0
for i in range(1,M+1):
  if foods[i] == N:
    ans += 1
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if(n%k==0){
            System.out.println("0");
        }
        else System.out.println("1");
    }


}


Measured memory_bytes: 22740
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<unordered_map>
#include<vector>
#include<string>
#include<unordered_set>
#include<set>
#include<algorithm>
using namespace std;


typedef long long ll;



int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int w, r;
	w = r = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'W') w++;
		else r++;
	}
	if (w == 0 || r == 0) cout << 0 << endl;
	else
	{
		int ans = 0;
		for (int i = 0; i < r; i++)
		{
			if (s[i] == 'W') ans++;
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

bool check(int a,int b,int c)
{
    if((a+b)>c && (c+b)>a && (a+c)>b)
        return true;
    return false;
}

int main()
{
    // freopen("input01.txt", "r", stdin);
    // freopen("output01.txt", "w", stdout);
    int n;
    cin>>n;
    map<ll int,int> mp;
    ll int a;
    int l,ct=0;
    for(l=0;l<n;l++)
    {
        cin>>a;
        mp[a]++;
    }
    
    if(mp.size()<3)
    {
        cout<<0;
        return 0;
    }

    for(auto i=mp.begin();next(next(i))!=mp.end();i++)
    {
        for(auto j=next(i);next(j)!=mp.end();j++)
        {
            for(auto k=next(j);k!=mp.end();k++)
            {
                if(check(i->first,j->first,k->first))
                    ct+=(i->second*j->second*k->second);
            }
        }
    }

    cout<<ct;
    return 0;
}

Measured memory_bytes: 3616
import heapq
q=[]
bool1=True
while bool1:
  n=input()
  if n=="end":
    bool1=False
    break
  elif n=="extract":
    i=heapq.heappop(q)
    print(-int(i))
  else:
    a,b=n.split()
    b=int(b)
    heapq.heappush(q,-b)


Measured memory_bytes: 45308
"""
重さと価値がそれぞれw_i,v_iであるようなn個の品物がある.
これらの品物の中から, 重さの総和がWを超えないように選んだ時の,
価値の総和の最大値を求めよ.
1<=n<=100, 1<=w_i,v_i<=100, 1<=W<=10000
"""
#-------------------------------------------------------------------------------
n ,W = map(int, input().split())
w=[0]*n
v=[0]*n
for i in range(n):
    x,y = map(int, input().split())
    w[i] = x
    v[i] = y
dp = [[0 for i in range(W+1)] for j in range(n+1)]
for i in range(n):
    for j in range(W+1):
        if j < w[i]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])
#print(dp)
print(dp[n][W])


Measured memory_bytes: 173576
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		int n=in.nextInt(),A[]=new int[n];
		for(int i=0;i<n;i++)A[i]=Integer.parseInt(in.next());
		
		int res[]=countingSort(A);
		
		PrintWriter out=new PrintWriter(System.out);
		for(int i=0;i<n-1;i++)out.print(res[i]+" ");
		out.println(res[n-1]);
		
		out.flush();
	}
	
	static int[] countingSort(int[] A) {
		int max=0,cnt[]=new int[10001],res[]=new int[A.length];
		
		for(int i=0;i<A.length;i++) {
			cnt[A[i]]++;
			if(A[i]>max)max=A[i];
		}
		
		for(int i=1;i<=max;i++)cnt[i]+=cnt[i-1];
				
		for(int i=A.length-1;i>=0;i--) {
			int v=A[i];
			cnt[v]--;
			res[cnt[v]]=v;
		}
		
		return res;
	}

}



Measured memory_bytes: 308656
#include<bits/stdc++.h>
using namespace std;
int dist[200][200];
const int inf=1e9;
int main(){
	int n,m,R,r[8];
	cin>>n>>m>>R;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			dist[i][j]=inf;
	for(int i=0;i<n;i++)
		dist[i][i]=0;
	for(int i=0;i<R;i++)
		cin>>r[i],r[i]--;
	for(int i=0;i<m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		dist[--a][--b]=c;
		dist[b][a]=c;
	}
	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
	int ans=1e9;
	
  sort(r,r+R);
  do{
		int tmp=0;
		for(int i=1;i<R;i++)
			tmp+=dist[r[i-1]][r[i]];
		ans=min(ans,tmp);
	}while(next_permutation(r,r+R));
	cout<<ans<<endl;
}


Measured memory_bytes: 384
/*  ex3_4
    potter0723sw  */

//方針：Nを１〜９で割ってみて商が１〜９かつ余りが０か調べる

#include <stdio.h>

int main(void) {
	int number,quotient,remainder,d;//dはdevide
	scanf("%d", &number);
	d = 1;
	while(d <= 9){//1~9まで調べる
		quotient = number / d;//商
		remainder = number % d;//余り
		if(quotient >= 1 && quotient <= 9 && remainder == 0){//商が１〜９かつ余りが０
			printf("Yes\n");
			break;//Yesを出力してwhile脱出
		}
		d += 1;
	}
	if(d == 10){//１〜９まで試してダメだった場合d=10なのでその時にNoを出力
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
using ll = long long;
int main() {
  ll n; scanf("%lld", &n);
  for (ll i = 0; i < n; ++i) {
    for (ll j = i+1; j < n; ) {
      ll d = i ^ j;
      ll ans = 0;
      for (ll l = d & -d; l; ++ans) l >>= 1;
      printf("%lld%c", ans, " \n"[++j==n]);
    }
  }
}


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

const int N = 1e6 + 5;
ll n , k;

ll tot[N] , p[N];

ll f(ll n , ll x) {
    if(n == 0) {
        if(x <= 0)
            return 0;
        else
            return 1;
    }

    if(x <= tot[n - 1] + 1) {
        return f(n - 1 , x - 1);
    }
    else return 1ll*(p[n - 1] + 1 + f(n - 1, x - tot[n - 1] - 2));

}

int main(){
    ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
    cin >> n >> k;
    tot[0] = 1;
    p[0] = 1;
    for(int i = 1 ; i <= n ; i ++) {
        tot[i] = tot[i - 1]*2 + 3*1ll;
        p[i] = p[i - 1]*2 + 1*1ll;
    }

    cout << f(n , k);
}

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

namespace panasonic2020_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = CIn.ReadInt();
            var b = CIn.ReadInt();
            var c = CIn.ReadInt();
            long i = c - a - b;
            
                if (i >= 0 && (long)4 * a * b < i * i)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            
        }
    }
    class CIn
    {
        private static readonly Queue<string> fieldBuffer = new Queue<string>();

        public static string Read()
        {
            if (fieldBuffer.Count == 0)
            {
                foreach (var field in Console.ReadLine().Split())
                {
                    fieldBuffer.Enqueue(field);
                }
            }

            return fieldBuffer.Dequeue();
        }

        public static int ReadInt() => int.Parse(Read());
        public static long ReadLong() => long.Parse(Read());
        public static double ReadDouble() => double.Parse(Read());

        public static string[] ReadStringArray(long n)
        {
            var array = new string[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = Read();
            }

            return array;
        }

        public static int[] ReadIntArray(long n)
        {
            var array = new int[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadInt();
            }

            return array;
        }

        public static long[] ReadLongArray(long n)
        {
            var array = new long[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadLong();
            }

            return array;
        }
        public static double[] ReadDoubleArray(long n)
        {
            var array = new double[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadDouble();
            }

            return array;
        }
    }

}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=2503;
const ll INF=1LL<<50;
vector<int> S[MAX],can(MAX,0);
vector<pair<int,ll>> T[MAX];

vector<ll> dis(MAX);
int N;

bool bell(){
    for(int i=0;i<N;i++){
        dis[i]=INF;
    }
    dis[0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<T[j].size();k++){
                int a=T[j][k].first;
                ll b=T[j][k].second;
                if(dis[j]!=INF&&dis[a]>dis[j]+b){
                    dis[a]=dis[j]+b;
                    if(i==N-1) return true;
                }
            }
        }
    }
    return false;
}

void DFS(int u){
    can[u]=1;
    stack<int> ST;
    ST.push(u);
    
    while(ST.size()){
        int a=ST.top();
        ST.pop();
        for(int i=0;i<S[a].size();i++){
            int b=S[a][i];
            if(can[b]==0){
                can[b]=1;
                ST.push(b);
            }
        }
    }
    
    return;
}

int main(){
    
    int M;
    ll P;cin>>N>>M>>P;
    vector<pair<pair<int,int>,ll>> W(M);
    
    for(int i=0;i<M;i++){
        int a,b;
        ll c;cin>>a>>b>>c;
        a--;b--;
        W[i]=make_pair(make_pair(a,b),c);
        S[b].push_back(a);
    }
    
    DFS(N-1);
    
    for(int i=0;i<M;i++){
        int a=W[i].first.first;
        int b=W[i].first.second;
        ll c=W[i].second;
        
        if(can[a]&&can[b]){
            T[a].push_back(make_pair(b,-(c-P)));
        }
    }
    
    if(bell()) cout<<-1<<endl;
    else cout<<max(0LL,-dis[N-1])<<endl;
    
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int mod){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%mod;Rac[n-1]=modInv(Fac[n-1],mod);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 301;
int n, m;
ll DP[N][N][N];
V<P<int, int>> h[N];
bool check(int i, int j, int k){
  if(i>j) swap(i, j);
  if(j>k) swap(j, k);
  if(i>j) swap(i, j);
  for(auto p:h[k]){
    if(p.se==1 && p.fi<=j) return false;
    if(p.se==2 && (p.fi<=i || j<p.fi)) return false;
    if(p.se==3 && i<p.fi) return false;
  }
  return true;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, m){
    int l, r, x;
    cin >> l >> r >> x;
    h[r].eb(l, x);
  }
  DP[0][0][0] = 1;
  FOR(i, 0, n)FOR(j, 0, n)FOR(k, 0, n){
    DP[i][j][k] %= MOD;
    int l = max(i, max(j, k))+1;
    if(check(l, j, k)) DP[l][j][k] += DP[i][j][k];
    if(check(i, l, k)) DP[i][l][k] += DP[i][j][k];
    if(check(i, j, l)) DP[i][j][l] += DP[i][j][k];
  }
  ll ans = 0;
  FOR(i, 0, n)FOR(j, 0, n) ans += (DP[i][j][n]+DP[j][n][i]+DP[n][i][j])%MOD;
  cout << ans%MOD << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)

#define bpll __builtin_popcountll

// input: 3, 5, 100 => 43
template <typename T>
T pow_mod(T x, T n)
{
	T res = 1;
	while (n > 0)
	{
		if (n & 1)
			res = (res * x) % cMOD;
		x = (x * x) % cMOD;
		n >>= 1;
	}
	return res;
}

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

    ll sum = 0;
    auto add = [&sum]( ll a, ll b ){
        sum = ( sum + pow_mod( 3ll, a ) * b % cMOD ) % cMOD;
    };

    ll b = 1;
    ll cnt = 0;
    REP(i,len)
    {
        if( s[i] == '1' )
        {
            add( len - 1 - i, b );
            b = b*2%cMOD;
            ++cnt;
        }
    }
    sum = ( sum + pow_mod( 2ll, cnt ) ) % cMOD;

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main()
{
//変数定義
int N;
int A;
int B;

//入力
scanf("%d", &N);
//printf("%d",N);

//Nの判定
for(int A=1; A<10; A++)
for(int B=1; B<10; B++){
  if(A*B==N){
  printf("Yes\n");
  return 0;
  }
//else
//printf("NO\n");
 //}
}
printf("No\n");
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	while(1){
		int W,H;
		cin>>W>>H;
		if(W==0 && H==0)
			return 0;
		int ans=1;
		vector<string> S;
		for(int i=0;i<H;i++){
			string s;
			cin>>s;
			S.pb(s);
		}
		queue<pint> Q;
		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++)
				if(S[i][j]=='@')
					Q.push(mp(j,i));
		while(Q.size()){
			pint P=Q.front();
			Q.pop();
			for(int k=0;k<4;k++){
				int X=P.first+dx[k],Y=P.second+dy[k];
				if(X<0 || W<=X || Y<0 || H<=Y)
					continue;
				if(S[Y][X]=='.'){
					Q.push(mp(X,Y));
					S[Y][X]='@';
					ans++;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
typedef long long ll;
const ll MOD = 1000000007LL;
const ll MAX = 100010LL;

template <typename T> T gcd(T a, T b) { 
    if(b == 0) 
        return a; 
    return gcd(b, a % b); 
}
template <typename T> T power(T x, T y, ll m = MOD) {
    T ans = 1; 
    x %= m; 
    while (y > 0) { 
        if (y & 1LL) {
            ans = (ans * x) % m;   
        } 
        y >>= 1LL; 
        x = (x * x) % m; 
    } 
    return (ans % m); 
}

int main() {

    FAST_IO;

    string s;
    cin >> s;

    int l = s.length();
    int res = 0;
    for (int i = 0; i < l/2; ++i) {
        if (i != l - i - 1 && s[i] != s[l - i - 1]) {
            ++res;
        }
    }
    cout << res << endl;
    return 0;
}

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

class point {
public:
	int x, y;
	point() {}
	point( int x_, int y_ ) :x(x_), y(y_) {}
	point operator -( point p ) { return point( x - p.x, y - p.y ); } 
};

int main()
{
	int q;
	cin >> q;
	for( int i = 0; i < q; i++ ) {
		point p[4];
		for( int j = 0; j < 4; j++ ) {
			int x, y;
			cin >> x >> y;
			p[j].x = x;
			p[j].y = y;
		}

		point v1 = p[1] - p[0];
		point v2 = p[3] - p[2];
		int ipro = v1.x * v2.x + v1.y * v2.y;
		int opro = v1.x * v2.y - v1.y * v2.x;
		int ans = 0;
		if( ipro == 0 ) ans = 1;
		else if( opro == 0 ) ans = 2;
		cout << ans << endl;
	}
}



Measured memory_bytes: 3116
N = int(raw_input())

def dfs(depth, l, r):
    if depth == 10:
        return True
    res = False
    if l < A[depth]:
        res |= dfs(depth+1, A[depth], r)
    if r < A[depth]:
        res |= dfs(depth+1, l, A[depth])
    return res

for c in range(N):
    A = map(int, raw_input().split(" "))
    print "YES" if dfs(0, 0, 0) else "NO"
    

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

int main(){

  int n;

  while(cin>>n,n){

	long long e,p,q;
	map<long long,long long> total;
	bool flag = false;

	for(int i=0;i<n;++i){
	  cin>>e>>p>>q;

	  if(total[e] <1000000){
		total[e]+=p*q;
		if(total[e] >= 1000000){
		  cout<<e<<endl;
		  flag = true;	  
		}
	  }

	}
	
	if(flag == false)
	  cout<<"NA"<<endl;
	
  }

  return 0;
  
}



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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());
            var primeList = new List<int>() { 2 };

            var ans = X;
            while (true)
            {
                SetPrime((int)Math.Sqrt(ans) + 1, primeList);
                if (primeList.Contains(ans) || primeList.All(s => ans % s != 0))
                {
                    Console.WriteLine(ans);
                    return;
                }
                ans++;
            }
        }

        static void SetPrime(int n, List<int> primeList)
        {
            var last = primeList.Last();
            if (last >= n) return;

            for (int i = last + 1; i <= n; i++)
            {
                if (primeList.All(s => i % s != 0)) primeList.Add(i);
            }
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
ll a,b,k;
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b >> k;
	if(a > 0){
		ll c = min(a,k);
		a -= c; k -= c;
	}
	if(b > 0) b -= min(b,k);
	cout << a << " " << b << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  double a, b, x;
  cin >> a >> b >> x;
  double ans;
  if (a * a * b / 2 < x) {
    double diff = a * a * b - x;
    double c = (2 * a * a * b - 2 * x) / (a * a);
    ans = atan(c / a) * (180 / M_PI);
  } else {
    double c = 2.0 * x / (a * b);
    ans = atan(b / c) * (180 / M_PI);
  }
  printf("%0.10lf\n", ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

char lower(char c);

int main(){
  double x1,y1,x2,y2;
  double X,Y;

  scanf("%lf %lf %lf %lf", &x1,&y1,&x2,&y2);
  X = x1-x2;
  Y = y1-y2;
  printf("%f\n",sqrt(X*X+Y*Y));

  return 0;
}



Measured memory_bytes: 2116
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

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

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

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

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func sum(a []int) int {
	ret := 0
	for _, v := range a {
		ret += v
	}
	return ret
}

func divFloor(a, b int) int {
	return (a + (b - 1)) / b
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a, b := nextInts(n), nextInts(n)

	d := sum(b) - sum(a)

	cnt := []int{0, 0}
	for i := 0; i < n; i++ {
		if a[i] > b[i] {
			cnt[0]++
		} else {
			cnt[1] += divFloor(b[i]-a[i], 2)
		}
	}

	if max(cnt...) <= d {
		puts("Yes")
	} else {
		puts("No")
	}
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e9;
int main(){
	string s;
	cin >> s;
	auto key = vector<string>({"dreamer","eraser","dream","erase"});
	for(int i=s.size()-1;i>=0;i--){
		bool f=false;
		for(auto j:key){
            if(i<j.size()-1) continue;
          	//cout <<j<<" "<<s.substr(i-j.size()+1,j.size()) << endl;
			if(s.substr(i-j.size()+1,j.size()).find(j)!=string::npos){
				f=true;
				i-=j.size()-1;
        	    break;
			}
		}
		if(!f){
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define inf -1
struct tree{
	int p;
	int r;
	int l;
}T[100001];
int P[100001],D[100001];
void setdepth(int u,int v){
	if(u==-1)return; 
	D[u]=v;
 setdepth(T[u].r,v);
	 setdepth(T[u].l,v+1);
}
void print(int i){
	printf("node %d: ",i);
	printf("parent = %d, ",T[i].p);
	printf("depth = %d, ",D[i]);
	if(T[i].p==-1)printf("root, ");
	else if(T[i].l==-1)printf("leaf, ");
	else printf("internal node, ");
	printf("[");
	int j=0,c;
	for(j=0,c=T[i].l;c!=-1;j++,c=T[c].r){
		if(j!=0)printf(", ");
		printf("%d",c); 
	}
	printf("]\n");
	
}
int main(){
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++)T[i].p=T[i].r=T[i].l=-1;
	int k,c,d,id,t;
	for(int i=0;i<n;i++){
		scanf("%d%d",&id,&k);
		for(int j=0;j<k;j++){
			if(j==0){
			scanf("%d",&c);
			T[id].l=c;T[c].p=id;
			}
			else{
			 scanf("%d",&d);
			 T[c].r=d;T[d].p=id;
			 c=d;
			} 
		}
	} 
	int root;
	for(int i=0;i<n;i++)if(T[i].p==-1)root=i;
	setdepth(root,0);
    for(int i=0;i<n;i++)print(i);
} 


Measured memory_bytes: 7836
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

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

int main() {

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

    int a[n];
    REP(i, n) {
        scanf("%d", &a[i]);
    }

    sort(a, a + n);
    int m = a[n - 1];
    int r = m / 2;

    vector<pair<int, int> > v;
    REP(i, n) {
        v.push_back(make_pair((r < a[i]) ? m - a[i] : a[i], a[i]));
    }

    sort(v.begin(), v.end(), greater<pair<int, int> >());

    printf("%d %d\n", m, (m == v[0].second) ? v[1].second : v[0].second);

    return 0;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define F first
#define S second
#define mset(x,v) memset(x, v, sizeof(x))
int main()
{
      boost;
            int cats,tot,x;
            cin>>cats>>tot>>x;
            if(cats+tot>=x && cats<=x)
            {
                  cout<<"YES";
            }
            else
            {
                  cout<<"NO";
            }
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			int n = sc.nextInt();
			long[] a = new long[n];
			BigInteger ret = BigInteger.ONE;
			String x1 = "1000000000000000000";
			BigInteger x = new BigInteger(x1) ;
			
			for(int i=0;i<n;i++) {
				a[i] = sc.nextLong();
				if(a[i]==0) {
					System.out.println(0);
					return;
				}
			}
			
			for(int i=0;i<n;i++) {
				ret = ret.multiply(BigInteger.valueOf(a[i]));
				if(ret.compareTo(x)==1) {
					System.out.println(-1);
					return;
				}
			}
			
			
			System.out.println(ret);
		}
		
	}


Measured memory_bytes: 61832
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;
typedef long long  ll;

const int N = 100010;
int a[N], b[N];
map<pair<int, int> , int> myhash;
int ans;


int main() {
	int n, ans = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) {
		if (a[a[i]] == i)
			ans++;
	}
	printf("%d\n", ans / 2);
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main (void){
	set<string> t;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		t.clear();
		string s;
		cin >> s;
		for(int j = 0; j < s.length() - 1; j++){
			string te1="", te2="", te3="", te4="";
			for(int k = 0; k <= j; k++){
				te1 += s[k];
				te2 += s[j-k];
			}
			for(int k = j+1; k < s.length(); k++){
				te3 += s[k];
				te4 += s[s.length()- (k - j - 1) - 1];
			}
			t.insert(te1+te3);
			t.insert(te1+te4);
			t.insert(te2+te3);
			t.insert(te2+te4);
			t.insert(te3+te1);
			t.insert(te3+te2);
			t.insert(te4+te1);
			t.insert(te4+te2);
			//cout << te1 << " " << te2 << " " << te3 << " " << te4 << endl;
		}
		cout << t.size() << endl;

	}


	return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
const int N=200005;
int f1[N],f2[N];
map <pair <int ,int > ,int > ans;
inline int getrt(int x,int *f){
	return f[x]==x?x:f[x]=getrt(f[x],f);
}
inline void merge(int x,int y,int*f){
	if (getrt(x,f)!=getrt(y,f))
		f[getrt(x,f)]=y;
}
int main (){
	int n,m,k;scanf ("%d%d%d",&n,&m,&k);
	for (int i=1;i<=n;i++) f1[i]=f2[i]=i;
	for (int i=1,u,v;i<=m;i++)
		scanf ("%d%d",&u,&v),merge(u,v,f1);
	for (int i=1,u,v;i<=k;i++)
		scanf ("%d%d",&u,&v),merge(u,v,f2);
	for (int i=1;i<=n;i++)
		ans[make_pair(getrt(i,f1),getrt(i,f2))]++;
	for (int i=1;i<=n;i++)
		printf ("%d ",ans[make_pair(getrt(i,f1),getrt(i,f2))]);
	return 0;
}


Measured memory_bytes: 13568
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N, X, Y; cin >> N >> X >> Y;
    vector<int> cnt(N+1);
    
    X--, Y--;
    for(int i=0; i<N; i++) {
        for(int j=i+1; j<N; j++) {
            int dist = -1;
            if(j <= X) dist = j - i;
            else if(i >= Y) dist = j - i;
            else if(i < X) {
                // (X, Y) を使って移動、そのまま移動
                dist = min({(X - i) + 1 + abs(Y - j), j - i});
            }
            else if(i >= X) {
                // (X, Y) を使って移動、そのまま移動
                dist = min({(i - X) + 1 + abs(Y - j), j - i});
            }
            cnt[dist]++;
        }
    }

    for(int i=1; i+1<=N; i++) printf("%d\n", cnt[i]);
    return 0;
}


Measured memory_bytes: 256
S=input();T=input();
M=-1;
for i in range(len(S)-len(T)+1):
  t=True;
  for j in range(len(T)):
    t*=(S[i+j]==T[j] or S[i+j]=='?');
  if(t):
    M=i;
if(M==-1):
  print("UNRESTORABLE");
  exit();
print((S[:M]+T+S[M+len(T):]).replace("?","a"));

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD =(ll)(1e9 + 7);
int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        a[i] = 0;
    }
    for (int i = 0; i < n; i++)
    {
        int pos;
        cin >> pos;
        a[pos]++;
    }
    int sum = 1;
    for (int i = 0; i < n; i++)
    {
        if ((a[i] % 2 == 1 && i > 0) || (a[0] == 0 && n % 2 == 1))
        {
            cout << 0;
            return 0;
        }
        sum *= a[i] != 0 ? a[i] : 1;
        sum %= MOD;
    }
    cout << sum % MOD;
    return 0;
}

Measured memory_bytes: 640
from collections import deque


class Dinic:
    def __init__(self, n):
        self.n = n
        self.links = [[] for _ in range(n)]
        self.depth = None
        self.progress = None
 
    def add_link(self, _from, to, cap):
        self.links[_from].append([cap, to, len(self.links[to])])
        self.links[to].append([0, _from, len(self.links[_from]) - 1])
 
    def bfs(self, s):
        depth = [-1] * self.n
        depth[s] = 0
        q = deque([s])
        while q:
            v = q.popleft()
            for cap, to, rev in self.links[v]:
                if cap > 0 and depth[to] < 0:
                    depth[to] = depth[v] + 1
                    q.append(to)
        self.depth = depth
 
    def dfs(self, v, t, flow):
        if v == t:
            return flow
        links_v = self.links[v]
        for i in range(self.progress[v], len(links_v)):
            self.progress[v] = i
            cap, to, rev = link = links_v[i]
            if cap == 0 or self.depth[v] >= self.depth[to]:
                continue
            d = self.dfs(to, t, min(flow, cap))
            if d == 0:
                continue
            link[0] -= d
            self.links[to][rev][0] += d
            return d
        return 0
 
    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.depth[t] < 0:
                return flow
            self.progress = [0] * self.n
            current_flow = self.dfs(s, t, float('inf'))
            while current_flow > 0:
                flow += current_flow
                current_flow = self.dfs(s, t, float('inf'))

def main():
    N = int(input())
    rl = []
    bl = []
    mf = Dinic(2 * N + 2)
    for i in range(N):
        mf.add_link(0, i+1, 1)
        mf.add_link(i+N+1, 2*N+1, 1)
    for _ in range(N):
        a, b = map(int, input().split())
        rl.append((a,b))
    for _ in range(N):
        c, d = map(int, input().split())
        bl.append((c, d))
    for i in range(N):
        for j in range(N):
            if rl[i][0] < bl[j][0] and rl[i][1] < bl[j][1]:
                mf.add_link(i+1, j+N+1, 1)
    return mf.max_flow(0, 2*N+1)
print(main())


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

using namespace std;

int n;
int A[20202];

int main()
{
	int i,a;
	
	scanf("%d", &n);
	
	for(i=1;i<=n;i++){
		scanf("%d", &a);
		A[a] = i;
	}
	
	for(i=1;i<=n;i++){
		printf("%d ", 50000 * (i-1) + A[i]);
	}
	
	printf("\n");
	
	for(i=n;i>=1;i--){
		printf("%d ", 50000 * i);
	}
	
	printf("\n");
	
	return 0;
}

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

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vec vector

typedef long long ll;

const ll inf = 1LL << 60;
const int mod = 1e9 + 7;

using namespace std;

/* Input variables. */
int n, m;
vec<pair<ll, int> > ab;

/* Solve! */
void solve() {
  ll ans = 0;
  sort(ab.begin(), ab.end());
  int i = 0;
  while (m > 0) {
    ans += ab[i].fi * min(m, ab[i].se);
    m -= min(m, ab[i].se);
    i++;
  }
  cout << ans << endl;
}

int main() {
  /* Input handling. */
  cin >> n >> m;
  ab = vec<pair<ll, int> >(n);
  rep(i, n) cin >> ab[i].fi >> ab[i].se;

  solve();
  return 0;
}

Measured memory_bytes: 1792
from itertools import accumulate
from bisect import bisect_left

s=input()
n=len(s)
s=[[1 if (ord('a')+i)==ord(c) else 0  for c in s] for i in range(26)]

for i in range(26):
    cnt=[0]+list(accumulate(s[i]))

    d=[2*cnt[j]-j for j in range(n+1)]

    minlst=[d[0]]
    poslst=[0]
    for j in range(1,n+1):
        if minlst[-1]>d[j]:
            minlst.append(d[j])
            poslst.append(j)
        else:
            minlst.append(minlst[-1])
            poslst.append(poslst[-1])
    
    for j in range(n,1,-1):
        if d[j]>minlst[j-2]:
            print('{} {}'.format(poslst[j-2]+1,j))
            exit(0)

print('-1 -1')

Measured memory_bytes: 212544
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, z, w; cin >> n >> z >> w;
  if (n == 1) {
    int a; cin >> a;
    cout << abs(w - a) << '\n';
    return 0;
  }
  vector<int> a(n); REP(i, n) cin >> a[i];
  cout << max(abs(a[n-1] - a[n-2]), abs(w - a[n-1])) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long TYPE;
const int MAXN=1E5+10;
const int INF=~0U>>1;
const TYPE mod=1E9+7;
int input() {
	int x;scanf("%d",&x);
	return x;
}
int Z=0,F=0,N=0;
TYPE a[MAXN],b[MAXN];
int doingZ() {
	TYPE x=a[1];
	for(int i=3;i<=Z;++i) {
		x-=a[i];
	}
	if(Z>=2) {
		x=a[2]-x;
	}
	printf("%lld\n",x);
	x=a[1];
	for(int i=3;i<=Z;++i) {
		printf("%lld %lld\n",x,a[i]);
		x-=a[i];
	}
	if(Z>=2) {
		printf("%lld %lld\n",a[2],x);
		x=a[2]-x;
	}
}
int doingZF() {
	TYPE x=b[F];
	for(int i=1;i<Z;++i) {
		x-=a[i];
	}x=a[Z]-x;
	for(int i=1;i<F;++i) {
		x-=b[i];
	}
	printf("%lld\n",x);
	x=b[F];
	for(int i=1;i<Z;++i) {
		printf("%lld %lld\n",x,a[i]);
		x-=a[i];
	}
	printf("%lld %lld\n",a[Z],x);
	x=a[Z]-x;
	for(int i=1;i<F;++i) {
		printf("%lld %lld\n",x,b[i]);
		x-=b[i];
	}
}
int doingF() {
	TYPE x=b[F];
	for(int i=1;i<F;++i) {
		x-=b[i];
	}
	printf("%lld\n",x);
	x=b[F];
	for(int i=1;i<F;++i) {
		printf("%lld %lld\n",x,b[i]);
		x-=b[i];
	}
} 
int main() {
	N=input();
	for(int i=1;i<=N;++i) {
		int x=input();
		if(x>0) {
			a[++Z]=x;
		}else {
			b[++F]=x;
		}
	}
	std::sort(a+1,a+Z+1);
	std::sort(b+1,b+F+1);
	if(Z==0&&F!=0)doingF();
	if(Z!=0&&F!=0)doingZF();
	if(Z!=0&&F==0)doingZ();
	return 0;
}


Measured memory_bytes: 2688
sa=input()
sb=input()
sc=input()

t=sa[0]
sa=sa[1:]
while True:
  if t=="a":
    if len(sa)==0:
      print("A")
      exit()
    t=sa[0]
    sa=sa[1:]
  elif t=="b":
    if len(sb)==0:
      print("B")
      exit()
    t=sb[0]
    sb=sb[1:]
  else:
    if len(sc)==0:
      print("C")
      exit()
    t=sc[0]
    sc=sc[1:]

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n)   for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define ALL(x)     begin (x), end (x)
using namespace std;
constexpr int64_t inf = 0xde0b6b43b9aca00;

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

  int M, D;
  cin >> M >> D;

  int64_t ans = 0;
  FOR (m, 1, M + 1)
  {
    FOR (d, 1, D + 1)
    {
      auto d1 = d % 10;
      auto d10 = d / 10;
      if (d1 < 2 || d10 < 2) continue;
      if (d1 * d10 == m) ++ ans;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int main()
{
	int N;
	map <string, int> done;

	cin >> N;

	string bef;
	for (int si = 0; si < N; si++) {
		string word;
		cin >> word;
		if (done.count(word) > 0) {
			printf("No");
			return 0;
		}

		done[word] = 1;
		if (si > 0 && bef[bef.size() - 1] != word[0]) {
			printf("No");
			return 0;
		}

		bef = word;
	}

	printf("Yes");


	return 0;
}



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

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

int main() {
  /****input****/
  string s;
  cin >> s;

  /****calc****/
  int len = s.length();

  /*回文生成*/
  string key;
  rep(i,len/2) key += s[i];
  if(len % 2 != 0) key += s[len/2];
  for(int i = (len/2-1); i>=0 ; --i) key += s[i];

  /*入力文字列と回文の比較*/
  int ans = 0;
  rep(i,len){
	  if(s[i] != key[i]) ans++;
  }

  /****output****/
//  cout << key << endl;
  cout << ans << endl;
  return 0;
}



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

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

  // ここにプログラムを追記
  if (a == '7' || b == '7' || c == '7') {
    cout << "Yes" << endl;
  }
  else {
    cout  << "No" << endl;
  } 
  
}


Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;
int main(){
    double x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    printf("%lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
    return 0;
    
}


Measured memory_bytes: 3276
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parent=list(range(n+1))
        self.size=[1]*(n+1)
    def find(self,x):
    #根を探す。
    #別なグループ間をつなげた場合は、つなげた先の根に書き換える。
        if self.parent[x]==x:
            return x
        else:
            self.parent[x]=self.find(self.parent[x])
            return self.parent[x]
    def unite(self,x,y):
    #二つのグループをつなげる
    #大きいほうに小さいほうをつなげる。
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return
        else:
            if self.size[x]>=self.size[y]:
                self.parent[y]=x
                self.size[x]+=self.size[y]
            else:
                self.parent[x]=y
                self.size[y]+=self.size[x]
    def cnt(self,x):
    #サイズの取得
        return self.size[self.find(x)]

def main():
    n,m=map(int,input().split())
    ab=[list(map(int,input().split())) for _ in range(m)][::-1]
    u=UnionFind(n)
    ans=[0]*(m+1)
    ans[0]=n*(n-1)//2
    for i in range(m):
        a,b=ab[i][0],ab[i][1]
        if u.find(a)==u.find(b):
            ans[i+1]=ans[i]
        else:
            ans[i+1]=ans[i]-u.cnt(a)*u.cnt(b)
            u.unite(a,b)
    for i in ans[m-1::-1]:
        print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 34956
# coding: utf-8
# Your code here!

import sys
n = int(input())
inf = float("inf")
xmin = [inf, inf, inf] #傾き-1,0,1
xmax = [-inf, -inf, -inf]
ymin = [inf, inf, inf]
ymax = [-inf, -inf, -inf]

for _ in range(n):
    x,y,d = [i for i in input().split()]
    x=int(x); y=int(y)
    if d=="U": ud = 2; lr = 1
    if d=="D": ud = 0; lr = 1
    if d=="L": ud = 1; lr = 0
    if d=="R": ud = 1; lr = 2
    xmin[lr] = min(xmin[lr],x)
    xmax[lr] = max(xmax[lr],x)
    ymin[ud] = min(ymin[ud],y)
    ymax[ud] = max(ymax[ud],y)

def lpos(t):
    return min([(v-1)*t + i for v,i in enumerate(xmin)])
def rpos(t):
    return max([(v-1)*t + i for v,i in enumerate(xmax)])
def dpos(t):
    return min([(v-1)*t + i for v,i in enumerate(ymin)])
def upos(t):
    return max([(v-1)*t + i for v,i in enumerate(ymax)])


s = {0}
for i in range(3):
    for j in range(i+1,3):
        t = (xmin[j]-xmin[i])/(i-j)
        if t > 0 and t != inf and t!= -inf: s.add(t)
        t = (xmax[j]-xmax[i])/(i-j)
        if 0 < t and t != inf and t!= -inf: s.add(t)
        t = (ymin[j]-ymin[i])/(i-j)
        if 0 < t and t != inf and t!= -inf: s.add(t)
        t = (ymax[j]-ymax[i])/(i-j)
        if 0 < t and t != inf and t!= -inf: s.add(t)
        

ans = 10**18
for t in s:
    area = (rpos(t)-lpos(t))*(upos(t)-dpos(t))
    if area < ans: ans = area

print(ans)

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

int main(){
    int x,y;
    cin>>x>>y;
    vector<int> v={3,0,1,0,2,0,2,0,0,2,0,2,0};
    cout<<(v[x]==v[y]?"Yes":"No")<<endl;
    return 0;
}

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

int main() {
  int r, c;
  cin >> r >> c;

  // データ受け取り
  vector<vector<int>> board(r + 1, vector<int>(c + 1));
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> board.at(i).at(j);
    }
  }

  // c列目に行の合計値を追加
  for (int i = 0; i < r; i++) {
    int sum = 0;
    for (int j = 0; j < c; j++) {
      sum += board.at(i).at(j);
    }
    board.at(i).at(c) = sum;
  }

  // r行目に列の合計値を追加
  for (int j = 0; j < c; j++) {
    int sum = 0;
    for (int i = 0; i < r; i++) {
      sum += board.at(i).at(j);
    }
    board.at(r).at(j) = sum;
  }

  // 表全体の合計値を追加
  int sum = 0;
  for (int i = 0; i < r; i++) {
    sum += board.at(i).at(c);
  }
  board.at(r).at(c) = sum;

  // 表を出力する
  for (int i = 0; i < r + 1; i++) {
    for (int j = 0; j < c + 1; j++) {
      cout << board.at(i).at(j);
      // 最後の列の右に、スペースを表示しない
      if (j < c) { cout << " "; }
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  string s;
  cin >> s;
  if (s.length() == 3) {
	  swap(s[0], s[2]);
	}
  cout << s << endl;
  return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int A,B,M;cin >>A>>B>>M;
    vector<int>a(A);
    int mina=INF;
    int minb=INF;
    for (int i = 0; i < A; ++i) {
        cin >>a[i];
        mina=min(mina,a[i]);
    }
    vector<int>b(B);
    for (int i = 0; i < B; ++i) {
        cin >>b[i];
        minb=min(minb,b[i]);
    }
    vector<int>x(M);
    vector<int>y(M);
    vector<int>c(M);
    int ans=mina+minb;
    for (int i = 0; i < M; ++i) {
        cin >>x[i]>>y[i]>>c[i];
        x[i]--;y[i]--;
        ans=min(ans,a[x[i]]+b[y[i]]-c[i]);
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 5112
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)


ll gcd(ll a, ll b);

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

#endif  // end of use_templates


int main()
{
    ll x;
    cin >> x;
    if (x >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

#define N_MAX 200000

int compare_char(const void* left, const void* right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;

    return strcmp( left_char, right_char );
}


int main(void){

	char s[N_MAX][11];
	char buff[12];
	int n;
	int len;
	int num;
	int i,j;
	long long int ret = 1;


	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",s[i]);
	}

	qsort(s, n, sizeof(s[0]), compare_char);


//	for(i=0;i<n-1;i++){
//		for(j=i+1;j<n;j++){
//			if(strncmp(s[i],s[j],10)==1){
//				strncpy(buff,s[i],10);
//				strncpy(s[i],s[j],10);
//				strncpy(s[j],buff,10);
//			}
//		}
//	}

	for(i=0;i<n-1;i++){
		if(strcmp(s[i],s[i+1])!=0){
			ret++;
		}
	}

	printf("%lld\n",ret);



	return 0;
}

Measured memory_bytes: 5740
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[2][110];
    rep(i, N) cin >> A[0][i];
    rep(i, N) cin >> A[1][i];
    int ans = 0;
    rep(i, N) {
        int tmp = 0;
        rep(j, N) {
            if(j <= i) tmp += A[0][j];
            if(j >= i) tmp += A[1][j];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  if(n == 1) n = 0;
  else n = 1;
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 3604