akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 998244353 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

ll power(ll a, ll b, ll c)
{
	ll res = 1;
	while(b != 0)
	{
		if(b & 1)
			res = (res * a) % c;
		a = (a * a) % c;
		b /= 2;
	}
	return res;
}
int main()
{
	int n;
	string s;
	cin >> n;
	cin >> s;
	auto check = [&](int k)
	{
		//cout << k << "\n";
		map <string, int> m;
		for (int i = k; i <= n; i++)
		{			
			if(i - 2 * k >= 0)
				m[s.substr(i - 2 * k, k)] = 1;
			if(m[s.substr(i - k, k)] == 1)
			{
				return true;
			}
			//cout << i - k << " " << s.substr(i - k, k) << "\n";
		}
		return false;
	};
	int lo = 1, hi = n, ans = 0;
	while(lo <= hi)
	{
		int mid = (lo + hi) / 2;
		if(check(mid))
		{
			ans = mid;
			lo = mid + 1;
		}
		else
		{
			hi = mid - 1;
		}
	}
	cout << ans;
}


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

int main(){
  int A,B;
  cin>>A>>B;
  if(A==B)
    cout<<"Draw"<<endl;
  else if((A>B && B!=1) || A==1)
    cout<<"Alice"<<endl;
  else
    cout<<"Bob"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int n, m;
    cin >> n >> m;
    cout << (1900*m + 100*(n-m)) * pow(2, m) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//?????§????????????=?????\??????????????????????´???¨???????????????


void InsertionSort(vector<long> &A,long n,long g,long& cnt){

	long i,v,j;

	//g????????????????????????,n???????´???°
	//
	for (i = g; i < n ; ++i){
		v = A[i]; //v = A[3];
		j = i - g;//j=3-2=1;
		while (j >= 0 && A[j]>v){
			A[j+g] = A[j];//????????????A[3]???A[1]?????£??\
			j = j - g;//
			++cnt;

		}	A[j+g] = v;
	
	}	

}



int main(){


	int m;
	long n, i, j;
	long cnt = 0;
	long G[13] = { 1, 4, 13, 40, 121, 364, 1093, 3280, 9841, 29524, 88573, 265720, 797161 };

	cin >> n;
	vector<long>A;
	A.resize(n, 0);

	for (i = 0; i < n; i++){
		
		cin >> A[i];
	}


		for (i = 0; i < 13; i++){
			if ((A.size() >= G[i] && A.size() < G[i + 1]) || i == 12){
				j = i; break;
			}
		}
		
		cout<<j + 1<< endl;

		for (i = j; i >= 0; --i){
			cout << G[i];
			if (i != 0)cout << " ";
			InsertionSort(A, n, G[i],cnt);
		}cout << endl;


	

		cout << cnt << endl;

		for ( i = 0; i < n; i++){
			cout << A[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 8984
#include<stdio.h>
int main()
{
	int a[3][3],n,b[10];
	int i,j,k,x[3][3]={0},f=0;
	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			scanf("%d",&a[i][j]);
		}
	}
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			for(k=0;k<n;k++){
				if(a[i][j]==b[k]){
					x[i][j]=1;
				}
			}
		}
	}
	for(i=0;i<3;i++){
		if(x[0][i]==1&&x[0][i]==x[1][i]&&x[2][i]==x[0][i]){
			f=1;
		}
		if(x[i][0]==1&&x[i][0]==x[i][1]&&x[i][2]==x[i][0]){
			f=1;
		}
	}
	if(x[0][0]==1&&x[0][0]==x[1][1]&&x[0][0]==x[2][2]){
		f=1;
	}
	if(x[0][2]==1&&x[0][2]==x[1][1]&&x[0][2]==x[2][0]){
		f=1;
	}
	if(f==1){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

int main(){
	long N, K, i, j, ans=0;

	scanf("%ld %ld", &N, &K);

	//kこのとき最大から最小までカウント
	for(i=K; i<=N+1; i++){
		ans = (ans + (((N+(N-i+1))*i)/2 - ((i-1)*i)/2) + 1) % ((long)1e9 +7);
	}

	printf("%ld", ans);

	return 0;

}


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



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

int main(void){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a==1){
    a=14;
  }
  if(b==1){
    b=14;
  }
  if(b<a){
    printf("Alice\n");
  }else if(a<b){
    printf("Bob\n");
  }else{
    printf("Draw\n");
  }
  return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int i, n;
	short a[101];

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	if (n >= 1) printf("%d", a[n - 1]);
	for (i = n - 2; i >= 0; i--) printf(" %d", a[i]);
	putchar('\n');
	return 0;
}


Measured memory_bytes: 2084
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */

  for(i = 0 ; i <= VMAX ; i++) C[i] = 0;

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

  for(i = 1 ; i <= VMAX ; i++) C[i] = C[i] + C[i-1];

  for(j = 1 ; j <= n ; j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i = 1 ; i <= n ; i++){
    if(i > 1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 9624
import java.util.*;
 
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String[] s = sc.nextLine().split(",");
            double[] a = new double[8];
            for(int i=0;i < 8;i++){
                a[i] = Double.parseDouble(s[i]);
            }
             
            if(isCross(a[0],a[1],a[4],a[5],a[2],a[3],a[6],a[7]) > 0.0 || isCross(a[2],a[3],a[6],a[7],a[0],a[1],a[4],a[5]) > 0.0){
                System.out.println("NO");
            }else{
                System.out.println("YES");
            }
        }
    }
     
    private static double isCross(double p1_x,double p1_y,double p2_x,double p2_y,double p3_x,double p3_y,double p4_x,double p4_y){  
        return ( (p1_x-p2_x)*(p3_y-p1_y) + 
(p1_y-p2_y)*(p1_x-p3_x)) * ((p1_x-p2_x)*(p4_y-p1_y) +
 (p1_y-p2_y)*(p1_x-p4_x));  
    }
}

Measured memory_bytes: 17168
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        if (n % 2 == 0) {
            a[n / 2] = sc.nextInt();
            for (int i = 1; i < n / 2; i++) {
                a[n / 2 - i] = sc.nextInt();
                a[n / 2 + i] = sc.nextInt();
            }
            a[0] = sc.nextInt();
            for (int i = 0; i < n; i++) {
                System.out.print(a[i]);
                System.out.print(" ");
            }
        } else {
            a[n / 2] = sc.nextInt();
            for (int i = 1; i <= n / 2; i++) {
                a[n / 2 - i] = sc.nextInt();
                a[n / 2 + i] = sc.nextInt();
            }
            for (int i = n - 1; i >= 0; i--) {
                System.out.print(a[i]);
                System.out.print(" ");
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 94780
n, m = map(int, input().split())


# Even case
# N+N, M+M -> nC2, mC2
ans = 0
if n == 1 and m == 1:
    ans = 0
elif n <= 1:
    ans = m * (m - 1) // 2
elif m <= 1:
    ans = n * (n - 1) // 2
else:
    ans = (m * (m - 1) + n * (n - 1)) // 2

print(ans)


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

int main() {
  while (true) {
    int n, k;
    cin >> n >> k;
    if (n == 0 && k == 0) break;
    vector<int> v(n);
    for (auto&& w : v) cin >> w;
    vector<int> s(n + 1, 0);
    for (int i = 0; i < n; i++) {
      s[i + 1] = s[i] + v[i];
    }
    int ret = 0;
    for (int i = 0; i + k < n + 1; i++) {
      int sm = s[i + k] - s[i];
      ret = max(ret, sm);
    }
    cout << ret << endl;
  }
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,y;
  cin >> x >> y;
  cout << x + y/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int T;
	cin>>T;
	float x=22.0/7.0;

	cout<<x*2*T;
	return 0;
}


Measured memory_bytes: 3820
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;

int main(){
   int n;
   string s;
   
   cin >> n >> s;
   if(n%2 == 1){
      cout << "No\n";
      return 0;
   }
   REP(i,n/2){
      if(s[i] != s[i + n/2]){
         cout << "No\n";
         return 0;
      }
   }
   cout << "Yes\n";
   
   return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  int a[2][100];
  for(int i = 0; i < 2; ++i)
    for(int j = 0; j < n; ++j)
      cin >> a[i][j];
  int dp[2][100] = {};
  for(int i = 0; i < 2; ++i){
    for(int j = 0; j < n; ++j){
      if(i == 0){
	if(j == 0){
	  dp[i][j] = a[i][j];
	} else {
	  dp[i][j] = dp[i][j-1] + a[i][j];
	}
      } else {
	if(j == 0){
	  dp[i][j] = dp[i-1][j] + a[i][j];
	} else {
	  dp[i][j] = max(dp[i][j-1],dp[i-1][j]) + a[i][j];
	}
      }
    }
  }
  cout << dp[1][n-1] << endl;
}



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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  int ret = 0;
  while(N--) {
    string S;
    cin >> S;
    ret += S == "E869120";
  }
  cout << ret << endl;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define EPS 1e-10
using namespace std;
typedef long long ll;

double add(double a,double b){
	if(fabs(a+b)<EPS*(fabs(a)+fabs(b)))return 0.0;
	return a+b;
}

class P{
public:
	double x,y;
	int id;
	P(double xx=0.0,double yy=0.0,int idd=-1){
		x=xx;
		y=yy;
		id=idd;
	}
	P operator +(P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator -(P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator *(double d){
		return P(x*d,y*d);
	}
	P operator /(double d){
		return P(x/d,y/d);
	}
	double norm() {
		return x * x + y * y;
	}
	bool operator<(const P &p)const{
		if(fabs(add(x,-p.x))<EPS)return y<p.y;
		return x<p.x;
	}
};

typedef P Vector;
typedef vector<P> Polygon;

double norm(Vector p){
	return add(p.x*p.x,p.y*p.y);
}

double abs(Vector p){
	return sqrt(norm(p));
}

double dot(Vector a,Vector b){
	return add(a.x*b.x,a.y*b.y);
}

double cross(Vector a,Vector b){
	return add(a.x*b.y,-a.y*b.x);
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw(P p0, P p1, P p2) {
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if (cross(a, b) > EPS)return COUNTER_CLOCKWISE;
	if (cross(a, b) < -EPS)return CLOCKWISE;
	if (dot(a, b) < -EPS)return ONLINE_BACK;
	if (a.norm() < b.norm())return ONLINE_FRONT;
	return ON_SEGMENT;
}


Polygon andrewScan(Polygon s){
	Polygon u,l;
	if(s.size()<3)return s;
	sort(s.begin(),s.end());
	u.push_back(s[0]);
	u.push_back(s[1]);
	l.push_back(s[s.size()-1]);
	l.push_back(s[s.size()-2]);
	for(int i=2;i<s.size();i++){
		for(int n=u.size();n>=2 && ccw(u[n-2],u[n-1],s[i])!=-1;n--){
			u.pop_back();
		}
		u.push_back(s[i]);
	}

	for(int i=s.size()-3;i>=0;i--){
		for(int n=l.size();n>=2 && ccw(l[n-2],l[n-1],s[i])!=-1;n--){
			l.pop_back();
		}
		l.push_back(s[i]);
	}
	reverse(l.begin(),l.end());
	for(int i=u.size()-2;i>=1;i--){
		l.push_back(u[i]);
	}
	return l;
}

int n;
ll x[101],y[101];
bool flag[101];
double ans[101];

P getCP(P p1,P p2){
	P mip=(p1+p2)/2.0;
	P tmp=p1-p2;
	P dir=P(-tmp.y,tmp.x,-1);
	double l=0.0,r=1e100;
	for(int i=0;i<10000;i++){
		double mid=(l+r)/2;
		if(pow(mip.x+dir.x*mid,2)+pow(mip.y+dir.x*mid,2)<=1e100)l=mid;
		else r=mid;
	}
	return P(mip.x+dir.x*l,mip.y+dir.y*l,-1);
}

int main(void){
	scanf("%d",&n);
	Polygon g;
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&x[i],&y[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++){
			for(int k=0;k<n;k++){
				if(i==k || j==k)continue;
				if(ccw(P(x[i],y[i]),P(x[j],y[j]),P(x[k],y[k]))==0){
					flag[k]=true;
				}
			}
		}
	}
	for(int i=0;i<n;i++){
		if(!flag[i]){
			g.push_back(P(x[i],y[i],i));
		}
	}
	Polygon res=andrewScan(g);
	if(res.size()<=2){
		for(int i=0;i<n;i++){
			if(!flag[i]){
				printf("%.10f\n",0.5);
			}else{
				printf("%.10f\n",0.0);
			}
		}
	}else{
		double sum=0.0;
		int m=res.size();
		for(int i=0;i<res.size();i++){
			P p1=getCP(res[(i+1)%m],res[i]);
			P p2=getCP(res[i],res[(i+m-1)%m]);
			double co=dot(p1,p2)/(abs(p1)*abs(p2));
			ans[res[i].id]=acos(co)/(M_PI*2.0);
		}
		for(int i=0;i<n;i++){
			printf("%.20f\n",ans[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

int main(){
    in n,m,k,ans = 999999999;
    cin >> n >> m >> k;
    vector<string> g(n);
    rep(i,0,n) cin >> g[i];
    rep(i,0,1<<(n-1)){
        in nb = 1 + __builtin_popcount(i);
        vector<in> v(nb);
        in res = nb-1, state = 1;
        rep(j,0,m){
            in now = 0;
            rep(z,0,n){
                if(g[z][j] == '1') v[now]++;
                if((1<<z) & i) now++;
            }
            if(*max_element(all(v)) > k){
                if(state == 0){
                    res = 999999999;
                    break;
                }
                res++;
                for(auto &it : v) it = 0;
                j--;
                state = 0;
                continue;
            }
            state = 1;
        }
        ans = min(ans,res);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
class CraneAndTurtle
  def solve(x, y)
    a = 4 * x - y
    b = y - 2 * x
    
    if a.even? && b.even? && a >= 0 && b >= 0 then "Yes" else "No" end
  end

  def run
    x, y = gets.chomp.split(/\s+/).map(&:to_i)
    puts solve(x, y)
  end
end

if $0 == __FILE__
  CraneAndTurtle.new.run
end


Measured memory_bytes: 14312
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  int x[n][m], y[m] = {}, sum;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> x[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    sum = 0;
    for (int j = 0; j < m; j++) {
      cout << x[i][j] << ' ';
      sum += x[i][j];
      y[j] += x[i][j];
    }
    cout << sum << endl;
  }
  sum = 0;
  for (int j = 0; j < m; j++) {
    cout << y[j] << ' ';
    sum += y[j];
  }
  cout << sum << endl;
}

Measured memory_bytes: 3116
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

def buffet(N,x,y,z):
  a = sum(y)
  for i in range(N-1):
    if x[i+1] - x[i] == 1:
      a = a + z[x[i]-1]
  print(a)

if __name__ == '__main__':
  buffet(N,A,B,C)
  

Measured memory_bytes: 3060
n = int(input())
s = input()

if n % 2 == 1:
    print('No')
else:
    sli = int(n/2)
    before_s = s[:sli]
    after_s = s[sli:]
    if before_s == after_s:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define PB push_back
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
 
int main(){
    string N;
    cin >> N;
    if(N.at(0) != '7' && N.at(1) != '7' && N.at(2) != '7'){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3624
// A modular inverse based solution to 
// compute nCr % p 
#include<bits/stdc++.h> 
using namespace std; 
/* Iterative Function to calculate (x^y)%p 
  in O(log y) */
long long power(long long x, long long y, long long p) 
{ 
    long long res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
long long modInverse(long long n, long long p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 

  
// Driver program 
int main() 
{ 
    // p must be a prime greater than n. 
    long long N, a,b;
    cin>>N>>a>>b;
    const long long M = 1e9+7;
    long long ans = power(2,N, M) - 1;
    //cout<<ans<<endl;
    long X = 1, Y= 1;
    for (int i = 0; i<a; i++) {
        X = ((X%M)*(N-i)%M)%M;
    }
    for (int i = 0; i<a; i++) {
        Y = ((Y%M)*(a-i)%M)%M;
    }
    Y = power(Y,M-2,M);
    long long res = 0;
    res += ((X%M) * (Y%M)) %M;
    X = 1; Y= 1;
    for (int i = 0; i<b; i++) {
        X = ((X%M)*(N-i)%M)%M;
    }
    for (int i = 0; i<b; i++) {
        Y = ((Y%M)*(b-i)%M)%M;
    }
    Y = power(Y,M-2,M);
    res += ((X%M) * (Y%M)) %M;
    res = res %M;
    ans = (ans - res +M) % M;
    cout<<ans;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  double sum = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    sum += double (1) / a;
  }
  printf("%f\n", 1 / sum);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X, tmpD,ans=0;
  bool flag=true;
  cin >> N >> X;
  tmpD = 9999999999;
  vector<int> city(N);
  for(int i=0; i<N; i++){
      cin >> city[i];
      tmpD = min(tmpD, abs(city[i]-X));
  }

  for(int j=tmpD; 0<j; j--){
      flag=true;
    for(int i=0; i<N; i++){
        if(abs(city[i]-X)%j!=0){
            flag=false;
            break;
        }
    }
    if(flag || j==1){
        ans = j;
        break;
    }
  }

  
    cout <<  ans << endl;
  
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int count[] = new int[4];

		for (int i = 0; i < n; i++) {
			String str = br.readLine();

			if (str.equals("AC")) {
				count[0]++;
			} else if (str.equals("WA")) {
				count[1]++;
			} else if (str.equals("TLE")) {
				count[2]++;
			} else {
				count[3]++;
			}
		}

		for (int i = 0; i < 4; i++) {
			String str = "";

			if (i == 0) {
				str = "AC x ";
			} else if (i == 1) {
				str = "WA x ";
			} else if (i == 2) {
				str = "TLE x ";
			} else if (i == 3) {
				str = "RE x ";
			}
			str += count[i];
			System.out.println(str);
		}
	}
}

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

int main() {
  int x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  int x_diff = x2 - x1;
  int y_diff = y2 - y1;
  
  x3 = x2 - y_diff;
  y3 = y2 + x_diff;
  x4 = x3 - x_diff;
  y4 = y3 - y_diff;
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  
  return 0;
}

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

#define TLong long long 

// abs(n)
int abs(int n){
	if(n < 0)	n *= -1;
	return n;
}

// gcd(a,b)
int gcd(int a,int b){
	int ret;
	ret = (b == 0) ? a : gcd(b, a % b);
}

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

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

int main(void){
	char instr[11],outstr[11] = "";
	scanf("%s",instr);
	for(int i = 0; i < strlen(instr); ++i){
		if(instr[i] == 'B') outstr[strlen(outstr) - 1] = '\0';
		else outstr[strlen(outstr)] = instr[i];
	}
	printf("%s",outstr);
	return 0;
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int ans = 0;
	for(int i=1;i<=n;i++){
	    int j;
	    cin>>j;
	    if(i%2==0) continue;
	    if(j%2==0) continue;
	    ans+=1;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;
#define MOD 1000000007

map<int, int> prime_factor(int n) {
    map<int, int> res;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    if(N==1) {
        cout << 1 << endl;
        return 0;
    }

    map<int, int> mp;
    for(int n=2; n<=N; n++){
        int m = n;
        for(int i=2; i*i <= m; i++){
            while(m % i == 0){
                mp[i]++;
                m /= i;
            }
        }
        if(m != 1) mp[m] += 1;
    }
    unsigned long long ans = 1;
    for(int i=2; i <= N; i++){
        ans *= (mp[i]+1) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;


ll pow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}


int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r,p;
    cin >> x >> y;
    if(y-2*x>=0&&(y-2*x)%2==0&&4*x-y>=0&&(4*x-y)%2==0){
        cout << "Yes\n";
    }
    else
        cout << "No\n";
    return 0;
}
    


Measured memory_bytes: 3644
use std::collections::BTreeSet;

fn dp(xs: &Vec<i64>, to: i64) -> bool {
    let sum = xs.iter().sum::<i64>();
    if (sum + to) % 2 != 0 { return false; }
    let mut cur = BTreeSet::new();
    cur.insert(0);
    for &x in xs {
        let mut next = BTreeSet::new();
        for &c in cur.iter() {
            next.insert(c + x);
            next.insert(c - x);
        }
        cur = next;
    }
    return cur.contains(&to);
}

fn main() {
    let mut sc = Scanner::new();
    let s: Vec<char> = (sc.read::<String>() + "T").chars().collect();
    let mut x: i64 = sc.read();
    let y: i64 = sc.read();

    let mut sx = Vec::new();
    let mut sy = Vec::new();
    let mut to_x = true;
    let mut buf = 0;
    for &c in &s {
        if c == 'F' {
            buf += 1;
        } else {
            if to_x {
                if sx.is_empty() && sy.is_empty() {
                    x -= buf;
                } else {
                    sx.push(buf);
                }
            } else {
                sy.push(buf);
            }
            to_x = !to_x;
            buf = 0;
        }
    }

    if dp(&sx, x) && dp(&sy, y) {
        println!("Yes");
    } else {
        println!("No");
    }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 4352
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int k, x;
    cin >> k >> x;
    for(int i = -(k-1); i<=k-1; i++) {
        int plus = x + i;
        if(plus < -1000000 || plus>1000000) continue;
        cout << plus << " ";
    }
    cout << endl;
    return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    vector<int> dp(1000000, 1000000);
    dp[0] = 0;

    for(int i = 0; i <= 100000; i++){

        int cur = 6;
        while(cur <= 1000000){
            dp[i + cur] = min(dp[i + cur], dp[i] + 1);
            cur *= 6;
        }
        cur = 9;
        while(cur <= 1000000){
            dp[i + cur] = min(dp[i + cur], dp[i] + 1);
            cur *= 9;
        }
    }

    int ans = 1e6;
    
    for(int i = n; i >= 0; i--)ans = min(ans, dp[i] + (n - i));
    cout << ans << endl;

}

Measured memory_bytes: 4096
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#define SQR(X) ( (X) * (X) )

int main()
{
   static long i,j,k,l;
   long double a,b,c,C;
   long double ans;
   static long cnt[100];
   int n,x;

   for(k=0;;k++) {
      cin >> n >> x;
      if(n == 0 && x == 0)
         break;
      for(i=1;i<=n;i++) {
         for(j=i+1;j<=n;j++) {
            if(i+j+n>=x && i+2*j<x)
               cnt[k]++;
         }
      }
   }
   for(i=0;i<k;i++)
      cout << cnt[i] << endl;

   return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<memory.h>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int cnt[100];

int main(){
  int n;
  cin >> n;
  int d[n];
  rep(i,n)cin >> d[i];
  int cnt[13]={};
  rep(i,n){
    cnt[d[i]]++;
  }
  rep(i,13){
    if(i>=1 && i<12 &&cnt[i]>2){
      cout << 0 << endl;
      return 0;
    }
    else if(i%12==0 && cnt[i]>1){
      cout << 0 << endl;
      return 0;
    }
  }
  vector<int> u,v;
  rep(i,n){
    if(d[i]%12==0)u.push_back(d[i]);
    else v.push_back(d[i]);
  }
  int ans=-1;
  int N=v.size();
  for(int bit=0;bit<(1<<N);bit++){
    int temp[n]={};
    int res=inf;
    for(int i=0;i<N;i++){
      if(bit & (1<<i) && v[i]!=0){
        temp[i]=24-v[i];
      }else{
        temp[i]=v[i];
      }
    }
    rep(j,u.size()){
      temp[N+j]=u[j];
    }
    sort(temp,temp+n);
    rep(i,n-1){
      res=min(res,temp[i+1]-temp[i]);
    }
    res=min(res,temp[0]);
    res=min(res,24-temp[n-1]);
    ans=max(ans,res);
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
    int H, W;
    string S[60];
    string T[60];
    cin >> H >> W;   
    for (int i = 1; i <= H ; i++){
        cin >> S[i];
    }

    //外側に0を入れる
    for (int i = 1 ; i <= H; i++) S[i] = "." + S[i] + ".";
    for (int j = 0; j <= W + 1; j++) {
        S[0] += '.';
        S[H+1] += '.'; 
    }

    for (int i = 1; i <= H; i++){
        for (int j = 1; j <= W; j++){
            if (S[i][j] == '.') {
                int counter = 0;
                string t;
                for (int k = -1; k <= 1; k++){
                    for (int l = -1; l <= 1; l++){
                        if (S[i+k][j+l] == '#') counter++;
                    }
                }
                t = to_string(counter);
                T[i] += t;
            }
            else T[i] += '#';
        }
    }
   // for (int i = 0; i <= H+1; i++){
    //    cout << S[i] << endl;
   // }
   for (int i = 1;i <= H; i++){
       cout << T[i] << endl;
   }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 50;
ll dp[N][N][2505];
int v[N];
int n, a;

ll f(int i, int k, int sum) {
    if (i == n) return k ? sum == a*k : 0;
    ll &r = dp[i][k][sum];
    if (r != -1) return r;
    r = f(i+1, k, sum) + f(i+1, k+1, sum+v[i]);
    return r;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    cin >> n >> a;
    fore(i,0,n) cin >> v[i];
    memset(dp, -1, sizeof(dp));
    cout << f(0, 0, 0) << endl;
}


Measured memory_bytes: 49152
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <functional>
#include <string>
#include <stack>
#include <queue>
#include <map>

typedef long long ll;
ll mod = 1e9 + 7;
  
using namespace std;

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

    int ret;
    if(a < c && c < b)
        cout << "Yes" << endl;
    else if (a > c && c > b)
        cout << "Yes" << endl;
    else
    {
        cout << "No" <<endl;
    }
	return 0;
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j, k) for (int i = j; i < k; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define int ll

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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int A, B, N;
    cin >> A >> B >> N;

    auto f = [&](ll N) {
        return A * N / B - A * (N / B);
    };
    ll ans = f(N);
    chmax(ans, f(max(N - N % B - 1, 0LL)));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = Integer.parseInt(s.next());
        int K = Integer.parseInt(s.next());
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            int p = Integer.parseInt(s.next());
            arr[i] = p;
        }
        int sum = 0;
        int tmp = 0;
        for (int i = 0; i < arr.length; i++) {
            if (i < K) {
                sum += arr[i];
                tmp += arr[i];
                continue;
            }
            tmp += arr[i];
            tmp -= arr[i - K];
            if (sum < tmp) {
                sum = tmp;
            } 
        }
        System.out.println((sum + K) / (double) 2.0);
    }
}

Measured memory_bytes: 60028
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int n;
pair<string, pair<int, int> > p[111];

signed main() {
    cin >> n;
    rep(i,n) {
        cin >> p[i].first >> p[i].second.first;
        p[i].second.first *= -1;
        p[i].second.second = i+1;
    }
    sort(p, p+n);
    rep(i,n) cout << p[i].second.second << endl;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi;
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;
}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_C() {}

int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vi s(N + 1, -1); FOR(i, 1, N + 1) cin >> s[i];

    vvi dp(N + MGN, vi(N * 100 + MGN, 0));
    // dp[i][j] : patterns of sum=j from {s1,s2,...,si}
    dp[0][0] = 1;

    FOR(i, 1, N+1) {
        FOR(j, 0, N*100+1) {
            //dp[i][j] = dp[i - 1][j] + dp[i - 1][j - s[i]];
            dp[i][j] = dp[i - 1][j];
            if (j - s[i] >= 0) dp[i][j] += dp[i - 1][j - s[i]];
        }
    }

    int ans = 0;
    for(int j=N*100+1; j>=0; j--) {
        if (dp[N][j]>0 && j%10!=0) {
            ans = j;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int a,b;cin>>a>>b;
  int ans=(a-1)*(b-1);
  cout <<ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1LL << 62;
constexpr ll MAX_N = 200;

vector<p> points;
ll N, K;

ll count_included_points(ll x1, ll y1, ll x2, ll y2) {
    ll res = 0;
    for (ll i = 0; i < N; i++) {
        ll x = points[i].first;
        ll y = points[i].second;
        if (x1 <= x && x <= x2 && y1 <= y && y <= y2) {
            res++;
        }
    }

    return res;
}

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

    cin >> N >> K;
    points = vector<p>(N);

    for (auto&& point : points) {
        cin >> point.first >> point.second;
    }

    ll ans = INF;

    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N; j++) {
            if (i == j) {
                continue;
            }

            p a = points[i];
            p b = points[j];

            ll x1 = min(a.first, b.first);
            ll x2 = max(a.first, b.first);

            ll area = INF;
            for (ll s = 0; s < N; s++) {
                for (ll t = 0; t < N; t++) {
                    if (s == t) {
                        continue;
                    }

                    p c = points[s];
                    p d = points[t];
                    ll y1 = min(c.second, d.second);
                    ll y2 = max(c.second, d.second);
                    if (K <= count_included_points(x1, y1, x2, y2)) {
                        area = min(area, (y2 - y1) * (x2 - x1));
                    }
                }
            }

            ans = min(ans, area);
        }
    }

    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int A, B, C;
long long K;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> A >> B >> C >> K;
  int s = A-B;
  if (K%2) s = -s;
  cout << s << "\n";
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    int k = (int)s.size();

    char x = s[k/2];
    int left = (k - 1) / 2;
    int right = k / 2;

    if (s[left] != s[right]) {
        cout << k / 2 << endl;
        exit(0);
    }

    while (right < k - 1) {
        if (s[right + 1] == x) right++;
        else break;
    }
    while (left > 0) {
        if (s[left - 1] == x) left--;
        else break;
    }

    int ans = min(right - (k - 1) / 2, k / 2 - left);
    if (k % 2 == 1) ans++;

    cout << k / 2 + ans << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long m = sc.nextLong();
    HashMap<Long, Long> map = new HashMap<Long, Long>();
    map.put((long)0, (long)1);
    long sum = 0;
    long ans = 0;
    for(int i = 0; i < n; i++) {
      long a = sc.nextLong();
      sum = (sum + a) % m;
      if(map.containsKey(sum)) ans += map.get(sum);
      if(map.containsKey(sum)) {
        map.put(sum, map.get(sum) + 1);
      } else {
        map.put(sum, (long)1);
      }
    }
    System.out.println(ans);
  }
}

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

int main(){
  string s;
  cin >> s;
  
  int n = s.size();
  vector<long long int> ct(2019);
  vector<long long int> t(n+1);
  
  t[n] = 0;
  ct[0]++;
  long long int base=1;
  for(int i=0; i<n; i++){
    t[n-i-1] = t[n-i] + (s[n-i-1]-'0')*base;
    t[n-i-1] %= 2019;
    base *= 10;
    base %= 2019;
    ct[t[n-i-1]]++;
    //cout << "->" << t[n-i-1]<<endl;
  }
  
  long long int ans=0;
  for(int i=0; i<2019; i++){
    ans += ct[i]*(ct[i]-1)/2;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 5168