akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005

// it's swapnil07 ;)

signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int a, b;
    cin>>a>>b;
    if(a>b)
        swap(a, b);
    int z = b-a;
    if(z%2){
        cout<<"IMPOSSIBLE";
    }
    else{
        int ans = a+z/2;
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 764
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000000
#define N 100005
#define pii pair<int,int>
#define vp vector<pair<int,int > >
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define gsz(x) ((int)(x).size())
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))

ll solve(ll dp[][4],ll n,ll a[],ll i,ll left,ll count)
{
	if(i>=n)
	{
		if(count==n/2)
		{
			return 0;
		}
		else return -MAX;
	}
	if(dp[i][left]!=-1)
	{
		return dp[i][left];
	}
	if(left==0)
	{
		dp[i][left] = solve(dp,n,a,i+2,left,count+1)+a[i];
	}
	else if(left==1)
	{
		dp[i][left] = max(solve(dp,n,a,i+2,left,count+1)+a[i],solve(dp,n,a,i+1,left-1,count));
	}
	else if(left==2)
	{
		dp[i][left] = max(solve(dp,n,a,i+2,left,count+1)+a[i],max(solve(dp,n,a,i+1,left-1,count),solve(dp,n,a,i+2,left-2,count)));
	}
	else
	{
		//if(i!=0&&i!=n-3)
			dp[i][left] = max(solve(dp,n,a,i+2,left,count+1)+a[i],max(solve(dp,n,a,i+1,left-1,count),max(solve(dp,n,a,i+2,left-2,count),solve(dp,n,a,i+3,left-3,count))));

	}
	return dp[i][left];
}

int main()
{
	fastio;
	ll n,i,j,k,a[200001];
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	// if(n%2==0)
	// {
	// 	ll sum1 = 0,sum2=0;
	// 	for(i=0;i<n;i+=2)
	// 	{
	// 		sum1+=a[i];
	// 	}
	// 	for(i=1;i<n;i+=2)
	// 	{
	// 		sum2+=a[i];
	// 	}
	// 	cout<<max(sum1,sum2)<<endl;
	// }
	
	{
		
		ll dp[n+1][4];
		ms(dp,-1);
		cout<<solve(dp,n,a,0,3,0)<<endl;

	}


	return 0;
}

Measured memory_bytes: 25476
#include<stdio.h>
#include <stdbool.h>
void swap(long num1, long num2, long a[100000]){
   long temp = a[num1];
   a[num1] = a[num2];
   a[num2] = temp;
}
long partition(long left, long right, long pivot, long a[100000]){
   long leftPointer = left -1;
   long rightPointer = right;

   while(true){
	
      while(a[++leftPointer] < pivot){
         //khong lam gi
      }
	  while(rightPointer > 0 && a[--rightPointer] > pivot){
         //khong lam gi
      }
      if(leftPointer >= rightPointer){
         break;
      }else{
         swap(leftPointer,rightPointer,a);
      }	
   }
   swap(leftPointer,right,a);
   return leftPointer;
}
// ham sap xep
void quickSort(long left, long right, long a[100000]){        
   if(right-left <= 0){
      return;   
   }else {
      long pivot = a[right];
      long partitionPoint = partition(left, right, pivot,a);
      quickSort(left,partitionPoint-1,a);
      quickSort(partitionPoint+1,right,a);
   }        
} 
int main()
{
  long d[100000],n,i;
  scanf("%ld", &n);
  for (i=0; i<n; i++) scanf("%ld", &d[i]);
  quickSort(0, n-1, d);
  printf("%ld", d[n/2]-d[n/2-1]);
  return 0;
}


Measured memory_bytes: 896
import java.io.*;
import java.util.*;
import java.math.*;


public class Main
{

public static long GCD(long a, long b){
	if(b == 0) return a;
	else return GCD(b, a%b);
}

public static long LCM(long a, long b){
	return (a * b)/GCD(a, b);
}




 public static void main(String args[]) throws Exception
       {
       	Scanner cin = new Scanner(System.in);
       	while(cin.hasNext()){
       		long a = cin.nextLong();
       		long b = cin.nextLong();
       		//System.out.println(GCD(a, b));
       		System.out.println( GCD(a, b) + " " + LCM(a, b));
       	}

}
}

Measured memory_bytes: 25892
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int N = GetInt();
		int[] a = new int[N];
		for(int i = 0; i < N; i++)
			a[i] = GetInt();

		int xor = 0;
		for(int i = 0; i < N; i++)
			xor ^= a[i];
	
		Console.WriteLine((xor == 0) ? "Yes" : "No");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 23776
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve(std::string S){
    ll cnt=0;
    for (ll i = 0; i < S.length()/2; i++) {
        if (S[i] != S[S.length()-1-i]) cnt++;
    }
    cout << cnt << "\n";
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int, [input() for i in range(n)]))
x = 0
y = 0
m = 0

for i in range(n):
  if x < p[i]:
    x = p[i]
    y = i
    
p[y] = int(x/2)
for i in range(n):
  m += p[i]
  
print(m)

Measured memory_bytes: 3060
import sys

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

X = [a,b,c,d,e]

for x1 in X:
    for x2 in X:
        if abs(x1-x2) > k:
            print(":(")
            sys.exit()
print("Yay!")


Measured memory_bytes: 38384
/// A問題やB問題が解けなくても焦らない
/// 時間は大事だけど、一度WAしたんだったら、
/// テストケースくらいは通そう
/// 焦ったら深呼吸
/// どうやったってC問題までは解ける実力があるんだから、
/// 解けなかったら一旦飛ばすことも考えよう
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
static const lint MOD = (lint)1e9+7;

int main()
{
    int N;
    cin >> N;
    cout << N*N*N << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll minDiv = 10000;
    ll divtimes;
    ll A;
    rep(i, N){
        cin >> A;
        divtimes = 0;
        while(A % 2 == 0){
            A /= 2;
            divtimes++;
        }
        minDiv = min(minDiv, divtimes);
    }

    cout << minDiv << endl;
    
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << (h2 * 60 + m2) - (h1 * 60 + m1) - k;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long int a,b;
int main()
{
    cin>>a>>b;
    if(a>0&&b>0)cout<<"Positive"<<endl;else
    if(a<=0&&b>=0)cout<<"Zero"<<endl;else
    if((b-a+1)%2!=0)cout<<"Negative"<<endl;
    else cout<<"Positive"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if((x*4<y)||(x*2>y)||(y%2!=0))
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)cout << 0 << endl;
	else cout << min(a*b, min(b*c, c*a)) << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

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


Measured memory_bytes: 384
#include<stdio.h>

int main(void){
  int i,j;
  char str[11];
  int a[10][10];

  while(scanf("%s ",str)!=EOF){
    for(i=0;i<10;i++)a[0][i] = str[i] - '0';

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string YES[2] = {"NO", "YES"};
string yes[2] = {"No", "Yes"};

int main(){
    ll n;   cin >> n;
    ll res=0;
    FOR(i, 1, n+1){
        for(ll j=1; j*i<=n; j++){
            if(i*j==n) continue;
            res += 1;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	vi a(n),b(n);
	vi c(n);
	for(auto &i:a) cin>>i;
	for(auto &i:b) cin>>i;
	for(int i=0;i<n;i++) c[i]=i+1;
	int x,y,t=0;
	do{
		if(a==c) x=t;
		if(b==c) y=t;
		t++;
	}while(next_permutation(c.begin(),c.end()));
	cout<<abs(x-y)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int row, col, num, board[6][6], i, j, k, l, onoff[64][6], bi[7] = {1, 2, 4, 8, 16, 32, 64}, count = 0, ans = 0;
  char ch;
  scanf("%d %d %d", &row, &col, &num);
  
  for(i = 0; i < row; i++){
    for(j = 0; j < col; j++){
      scanf(" %c", &ch);
      if(ch == '.') board[i][j] = 0;
      if(ch == '#') board[i][j] = 1;
    }
  }
  
  for(i = 0; i < 64; i++){
    l = i;
    for(j = 5, k = 32; j >= 0; j--){
      onoff[i][j] = l / k;
      l %= k;
      if(k > 1) k /= 2;
    }
  }
    
  for(i = 0; i < bi[row]; i++){
    for(j = 0; j < bi[col]; j++){
      for(k = 0; k < row; k++){
        if(onoff[i][k] == 1){
          for(l = 0; l < col; l++){
            if(onoff[j][l] == 1){
              if(board[k][l] == 1) count++;
            }
          }
        }
      }
      if(num == count) ans++;
      count = 0;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1692
from collections import deque

h, w = map(int, input().split())
grid = [input() for _ in range(h)]
visited = [[0]*w for _ in range(h)]
moves = ((1, 0), (-1, 0), (0, 1), (0, -1))

ans = 0
for i in range(h):
    for j in range(w):
        if not visited[i][j]:
            bcnt, wcnt = 0, 0
            q = deque([(i, j)])
            while q:
                cx, cy = q.popleft()
                if visited[cx][cy]:
                    continue
                if grid[cx][cy] == "#":
                    bcnt += 1
                else:
                    wcnt += 1
                visited[cx][cy] = 1
                for (dx, dy) in moves:
                    if 0 <= cx + dx < h and 0 <= cy + dy < w and not visited[cx + dx][cy + dy] and grid[cx + dx][cy + dy] != grid[cx][cy]:
                        q.append((cx + dx, cy + dy))
            ans += bcnt * wcnt
print(ans)

Measured memory_bytes: 10828
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
str s;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>s;
    int ans = 0;
    int l = 0; int r = s.size()-1;
    while(l<=r){
        if(s[l] != s[r]) ans++;
        l++;r--;
    }
    cout<<ans<<newl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  //1の位
  int b = a%10;
  //100の位
  int c = a/100;
  //10の位
  int d = (a-b-c*100)/10;
  
  cout << b+c+d << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[100];
int n;
int main(){
	a[0]=2;a[1]=1;
	cin>>n;
	for(int i=2;i<=n;i++)a[i]=a[i-1]+a[i-2];
	cout<<a[n]<<endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vector<string> s(N); cin >> s;
    map<vec, int> cnt;

    int ans = 0;
    REP(i, N){
        vec v(26, 0);
        for(char x: s[i]) v[x - 'a']++;
        ans += cnt[v];
        cnt[v] += 1;
    }
    Out(ans);

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    ll n, k, q; cin >> n >> k >> q;
    int bucket[100010] = {};
    rep(i, q) {
        int a; cin >> a;
        a--;
        bucket[a]++;
    }
    rep(i, n) {
        int tmp = bucket[i]-q;
        cout << (tmp > -k ? "Yes" : "No") << '\n';
    }
    return 0;
}

Measured memory_bytes: 1024
from scipy.misc import comb
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
chars = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
result = []
for n in range(N):
    res = {}
    for char in chars:
        res[char] = S[n].count(char)
    result.append(res)
result2 = Counter([str(i) for i in result ])
cnt = 0
for key in result2.keys():
    if result2[key] == 1:
        pass
    else:
        cnt += comb(result2[key],2,exact=True)
print(int(cnt))

Measured memory_bytes: 223724
#include<iostream>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<vector>
#include<set>
#include<bitset>
#include<queue>
#include<deque>
using namespace std;

#define ll long long
#define pi pair<int,int>
#define x first
#define y second

#define in ({ll x=0;int o=0,c=getchar();for(;!isdigit(c);c=getchar()) o=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';o?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})
#define instring ({string s;char c=getchar();for(;c==' '||c=='\n';c=getchar());for(;c!=' '&&c!='\n';c=getchar()) s+=c;s;})

#define FOR(i,a,b) for(int i=a,_=b;i<=_;i++)
#define ROF(i,a,b) for(int i=b,_=a;_<=i;i--)
#define RR(x,a,b) FOR(__,a,b) cout<<x[__]<<" \n"[__==b];
#define rr(x) " "<<#x<<'='<<x<<" "

#define bitnum(x) __builtin_popcountll(x)
#define bitl(x) (64-__builtin_clzll(x))
#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define pw2(x) (1ll<<x)

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define vall(a) a.begin(),a.end()
#define fiv(a) (int)a.size()-1

#define false(x) if(!(x))
#define middle(a,b) (a+(b-(a))/2)
#define Min(a,b) ({bool o=0;auto b2=b;if(a>b2) a=b2,o=1;o;})
#define Max(a,b) ({bool o=0;auto b2=b;if(a<b2) a=b2,o=1;o;})
////////////////////////////////////////// HUX
const int N=1e5+5;
int n;
int a[N];
int f[N][2];
main()
{
   // freopen("hx.inp","r",stdin);
    // freopen("hx.out","w",stdout);
    n=in;
    FOR(i,1,n) a[i]=in;
    f[1][0]=f[1][1]=1;
    FOR(i,2,n)
    {
        f[i][0]=min(f[i-1][1]+1,f[i-1][0]+(a[i-1]>a[i]));
        f[i][1]=min(f[i-1][0]+1,f[i-1][1]+(a[i-1]<a[i]));
    //    cout<<rr(f[i][0]) rr(f[i][1]) "\n";
    }
    cout<<min(f[n][0],f[n][1]);
}


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

using namespace std;

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

	int e = c - a, f = d - b;

	cout << c - f << " " << d + e << " " << a - f << " " << b + e << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

int p[2010][2010];
void solve() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i) p[i][i] = 1;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            if(j < i) p[i][j] = 0;
            else if(i == j) continue;
            else p[i][j] = (p[i][j - 1] + p[i][j - i]) % MOD1;
        }
    }
    cout << p[3][n];
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}


Measured memory_bytes: 19260
#include <iostream>

using namespace std;

int main()
{
    int S, s1, s2;
    cin >> S;
    s1 = S / 100;
    s2 = S % 100;
    if(s1 == 0 || s1 > 12){
        if(s2 > 0 && s2 < 13)
            cout << "YYMM" << endl;
        else{
            cout << "NA" << endl;
        }
    }
    else if(s2 == 0 || s2 > 12){
        if(s1 > 0 && s1 < 13)
            cout << "MMYY" << endl;
        else{
            cout << "NA" << endl;
        }
    }
    else{
        cout << "AMBIGUOUS" << endl;
    }
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)

typedef pair< int, int > pii;
typedef pair< pii, pii > ppii;

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
int n, x[20020], y[20020], visit[20020][2];
char dir[20020];
pii pos[40040], ids[40040];

int xadd(int i) { return dir[i] == 'x' ? 1 : 0; }
int yadd(int i) { return dir[i] == 'y' ? 1 : 0; }

bool rec(int i, int j, int v, vector< pii >& upd) {
	bool res = 1;
	
	if (visit[i][j] < 0) {
		visit[i][j] = v;
		visit[i][j^1] = v^1;
		upd.push_back(pii(i,j));
		upd.push_back(pii(i,j^1));
		
		int nx1 = x[i] + (j ? xadd(i) : 0), ny1 = y[i] + (j ? yadd(i) : 0);
		int nx2 = x[i] + (j ? 0 : xadd(i)), ny2 = y[i] + (j ? 0 : yadd(i));
		for_(d,0,4) {
			pii nxp1(nx1 + dx[d], ny1 + dy[d]);
			if (binary_search(pos, pos + 2*n, nxp1)) {
				int k = lower_bound(pos, pos + 2*n, nxp1) - pos;
				if (ids[k].second != i) res &= rec(ids[k].second, ids[k].first, v, upd);
			}
			
			pii nxp2(nx2 + dx[d], ny2 + dy[d]);
			if (binary_search(pos, pos + 2*n, nxp2)) {
				int k = lower_bound(pos, pos + 2*n, nxp2) - pos;
				if (ids[k].second != i) res &= rec(ids[k].second, ids[k].first, v^1, upd);
			}			
		}
	} else {
		res = (visit[i][j] == v);
	}
	
	return res;
}

int main() {
	while (cin >> n, n) {
		vector< ppii > vp;
		
		for_(i,0,n) {
			cin >> x[i] >> y[i] >> dir[i];
			vp.push_back(ppii(pii(x[i], y[i]), pii(0, i)));
			vp.push_back(ppii(pii(x[i] + xadd(i), y[i] + yadd(i)), pii(1, i)));
		}
		
		sort(vp.begin(), vp.end());
		
		for_(i,0,2*n) {
			pos[i] = vp[i].first;
			ids[i] = vp[i].second;
		}
		
		memset(visit, -1, sizeof(visit));
		
		bool ok = 1;
		for_(i,0,n && ok) {
			if (visit[i][0] < 0) {
				vector< pii > upd;
				if (!rec(i, 0, 0, upd)) {
					int u_size = (int)upd.size();
					for_(j,0,u_size) visit[upd[j].first][upd[j].second] = -1;
					ok = rec(i, 0, 1, upd);
				}
			}
		}
		cout << (ok ? "Yes" : "No") << endl;
	}
	
	return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>

int main(void){

  int N , X;
  int L[100];
  scanf("%d %d", &N , &X);
  for(int i = 0 ; i < N ; i++){
    scanf("%d", &L[i]);
  }

  int count = 1;
  int sum = 0;
  for(int i = 0 ; i < N ; i++){
    sum += L[i];
    if(X < sum) break;
    count++;
  }

  printf("%d", count);
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	long long a=1,b=0,c,n=0; 
	scanf("%lld",&n);
	while(b<n){
		
		b++;
		a=a*b;
		a=a%1000000007;
	}

	

printf("%lld",a); 
	return 0;
}


Measured memory_bytes: 128
fun main(arg: Array<String>) {
    val N = nextLong()
    val S = nextLong()
    if (N == S) return print(N + 1)
    val sqrtN = Math.sqrt(N.toDouble()).toLong()
    val list = mutableListOf<Long>()
    fun f(b: Long, N: Long): Long {
        var n = N
        var cnt = 0L
        while (n > 0) {
            cnt += n % b
            n /= b
        }
        return cnt
    }
    for (b in 2 .. sqrtN) if (f(b, N) == S) return print(b)
    val A = N - S
    if (A < 0) return print(-1)
    for (n in 1 .. sqrtN) {
        if (A % n == 0L) {
            list.add(n + 1)
            if (n != A / n) list.add(A / n + 1)
        }
    }
    list.sort()
    for (b in list) {
        if (b > sqrtN && f(b, N) == S)
            return print(b)
    }
    return print(-1)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong() = listOfString().map(String::toLong)



Measured memory_bytes: 33776
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll ans = 0;
int main() {
	ll n, k;
	cin >> n >> k;
	FOR(i, k, n + 2) {
		ll a = i * (i - 1) / 2;
		ll b = i * (2 * n - i + 1) / 2;
		//cout << b << " " << a << endl;
		ans += b - a + 1;
		ans %= MOD;
	}
	cout << ans << endl;
}


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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    ll takahashi = 1;
    ll aoki = 1;

    for (int i = 0; i < N; i++) {
        ll T, A;
        cin >> T >> A;
        ll j;
        j = max((takahashi+T-1)/T, (aoki+A-1)/A);
        takahashi = T*j;
        aoki = A*j;
    }
    cout << takahashi+aoki << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	long long x,y,c;
	cin>>x>>y;
	if(x<y)swap(x,y);
	while(true){
		c=x%y;
		if(c==0){
			cout<<y<<endl;
			break;
		}
		x=y;
		y=c;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>
int main(int argc, char const *argv[])
{
  int n,m;
  scanf("%d%d",&n,&m);
  if(n==1 && m==0){
    printf("0");
    return 0;
  }
  int num[n+1];
  for(int i=0;i<n+1;i++){
    num[i]=10;
  }
  int s[m],c[m];
  for(int i=0;i<m;i++){
    scanf("%d%d",&s[i],&c[i]);
    if(s[i]==1 && c[i]==0 && n>1){
      printf("-1");
      return 0;
    }
    if(num[s[i]]<10 && num[s[i]]!=c[i]){
      printf("-1");
      return 0;
    }
    num[s[i]]=c[i];
  }
  for(int i=2;i<n+1;i++){
    if(num[i]==10) num[i]=0;
  }
  if(num[1]==10) num[1]=1;
  for(int i=1;i<n+1;i++){
    printf("%d",num[i]);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	// your code goes here
	int n,w;
	cin>>n>>w;
	vector<long int>a(n),b(n);
	rep(i,n)
	{
	    long int c,d;
	   cin>>c>>d;
	 //  cout<<c<<" "<<d<<endl;
	   a[i]=c;
	   b[i]=d;
	    
	}

	long int dp[n+1][w+1];
	
	   rep(i,n+1)
	   {
	       rep(j,w+1)
	       dp[i][j]=0;
	   }
	    
	    
	for(int i=1;i<=n;i++)
	{
	    for(int j=0;j<=w;j++)
	    {
	        if(a[i-1]>j)
	        {
	            dp[i][j]=dp[i-1][j];
	        }
	        else
	        dp[i][j]=max(dp[i-1][j],b[i-1]+dp[i-1][j-a[i-1]]);
	    }
	}
	
    cout<<dp[n][w];

	return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  //ll n;
  //cin >> n;
  string s; cin >> s;
  ll result = 0;
  bool judge = true;
  char c;
  if(s.size() <= 25){
    for(c = 'a'; c <= 'z'; c++){
      judge = true;
      for(i = 0; i < s.size(); i++){
        if(s[i] == c)
          judge = false;
      }
      if(judge)
        break;
    }
    s += c;
    cout << s << endl;
  }
  else if(s == "zyxwvutsrqponmlkjihgfedcba")
    cout << -1 << endl;
  else{
    c = s[25];
    s.pop_back();
   
    for(i = 24; ;i--){
      if(c < s[i]){
        c = s[i];
        s.pop_back();
      }
      else{
        c = s[i];
        s.pop_back();
        //
        for(c += 1; c <= 'z'; c++){
          //cout << c << endl;
          judge = true;
      	  for(i = 0; i < s.size(); i++){
            if(s[i] == c)
          	  judge = false;
      	  }
      	  if(judge)
        	break;
    	}
    	s += c;
        //
        break;
      }
    }
    cout << s << endl;
  }
        
   
  /*
  vector<ll> a(n);
  for(i = 0; i < n; i++)
    cin >> a[i];
  //for(i = 0; i < n; i++)
  */
  

  return 0;
}

Measured memory_bytes: 256
N = int(input())
T = [list(map(int, input().split())) for i in range(N)]

judge = True
for i in range(len(T)):
    if i == 0:
        time = T[i][0]
        distance = sum(T[i][1:])
    else:
        time = T[i][0] - T[i-1][0]
        distance = abs(sum(T[i][1:]) - sum(T[i-1][1:]))
    if time >= distance and (time - distance) % 2 == 0:
        continue
    else:
        judge = False
        break

print("Yes" if judge else "No")

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

int N;
double p[3010];
double dp[3010][3010];
double search()
{   
    dp[0][0] = 1;
    for(int n = 0; n < N; n++)
    for(int fr = 0; fr <= n; fr++)
    {
        dp[n + 1][fr + 1] += dp[n][fr] * p[n];
        dp[n + 1][fr] += dp[n][fr] * (1 - p[n]);
    }

    double res = 0;

    for(int i = N; i >= N / 2 + 1; i--) res += dp[N][i];

    return res;


}

int main()
{
    cin >> N;
    for(int i = 0; i < N; i++) cin >> p[i];

    cout.precision(10);
    cout << fixed << search() << endl;
}

Measured memory_bytes: 69120
n=int(input())
a=[[int(i) for i in input().split()]for i in range(n)]
dpa=[0]*(n+1)
dpb=[0]*(n+1)
dpc=[0]*(n+1)

for i in range(1,n+1):
    dpa[i]=max(dpb[i-1]+a[i-1][0],dpc[i-1]+a[i-1][0])
    dpb[i]=max(dpa[i-1]+a[i-1][1],dpc[i-1]+a[i-1][1])
    dpc[i]=max(dpa[i-1]+a[i-1][2],dpb[i-1]+a[i-1][2])

print(max(dpa[-1],dpb[-1],dpc[-1]))

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

int gcd(int x, int y) {
	if (y == 0)return x;

	int m;
	m = max(x, y) % min(x, y);
	gcd(min(x, y), m);
}

int main() {

	int n, x;
	cin >> n >> x;
	int dis[100000];

	for (int i = 0; i < n; i++) {
		int xi;
		cin >> xi;
		dis[i] = abs(xi-x);
	}

	sort(dis, dis + n);
	reverse(dis, dis + n);

	int d=dis[0];
	for (int i = 0; i < n; i++) {
		if (dis[i] != 0) {
			if (dis[i]%d != 0) {
				d=gcd(d, dis[i]);
			}
		}
	}

	cout << d << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a[N];
  bool b[N];
  for(int i=0; i<N; i++){
    cin >> a[i];
    b[i] = false;
  }

  int i = 0;
  b[i] = true;
  int count = 0;
  while(true){
    i = a[i]-1;
    if(b[i]){
      cout << -1 << endl;
      return 0;
    }
    count++;
    b[i] = true;
    if(i == 1){
      cout << count << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdlib>
#include <set>
#include <iterator>
using namespace std;
#define REP(i, a, b) for(long long i = a; i < b; i++)
int distinct(int n);

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

  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << "\n";
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	public static int[][] col = 
		{
			{1,1,1,1,1,1,1,1,1,1},
			{2,1,1,1,1,1,1,1,1},
			{2,2,1,1,1,1,1,1},
			{2,2,2,1,1,1,1},
			{2,2,2,2,1,1},
			{2,2,2,2,2},
			{3,1,1,1,1,1,1,1},
			{3,2,1,1,1,1,1},
			{3,2,2,1,1,1},
			{3,2,2,2,1},
			{3,3,1,1,1,1},
			{3,3,2,1,1},
			{3,3,2,2},
			{3,3,3,1},
			{4,1,1,1,1,1,1},
			{4,2,1,1,1,1},
			{4,2,2,1,1},
			{4,2,2,2},
			{4,3,1,1,1},
			{4,3,2,1},
			{4,3,3},
			{4,4,1,1},
			{4,4,2},
			{5,1,1,1,1,1},
			{5,2,1,1,1},
			{5,2,2,1},
			{5,3,1,1},
			{5,3,2},
			{5,4,1},
			{6,1,1,1,1},
			{6,2,1,1},
			{6,2,2},
			{6,3,1},
			{7,1,1,1},
			{7,2,1},
			{8,1,1}
		};
	
	//public static int def_max = 0;
	
	public static long bit_trans(int[] weight){
		long bit = 0;
		
		for(int i = 1; i < 10; i++){
			bit <<= 7;
			bit |= weight[i];
		}
		
		return bit;
	}
	
	public static int dps(int[] weight, Map<Long, Integer> memo, int sum){
		long bit = bit_trans(weight);
		
		if(memo.containsKey(bit)){
			return memo.get(bit);
		}
		
		int max = 0;
		for(int i = 0; i < col.length; i++){
			boolean ok = true;
			
			for(int cost : col[i]){
				weight[cost]--;
				sum -= cost;
				
				if(weight[cost] < 0){
					ok = false;
				}
			}
			
			if(ok){
				max = Math.max(max, dps(weight, memo, sum) + 1);
				//def_max = Math.max(max, def_max);
			}
			
			for(int cost : col[i]){
				weight[cost]++;
				sum += cost;
			}
		}
		
		memo.put(bit, max);
		
		return max;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		Map<Long, Integer> map = new HashMap<Long, Integer>();
		
		while (true) {
			
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			//def_max = 0;
			
			int[] weights = new int[10];
			
			for(int i = 0; i < n; i++){
				weights[sc.nextInt()]++;
			}
			
			int count = 0;
			
			count += weights[5] / 2;
			weights[5] %= 2;
			for(int i = 1; i < 5; i++){
				int min = Math.min(weights[5 + i], weights[5 - i]);
				
				count += min;
				weights[5 + i] -= min;
				weights[5 - i] -= min;
			}
			
			int sum = 0;
			for(int i = 1; i < weights.length; i++){
				sum += weights[i] * i;
			}
			
			//System.out.println(Arrays.toString(weights));
			System.out.println(count + dps(weights, map, sum));
			
		}
	}

}

Measured memory_bytes: 107852
#include <iostream>
#include <utility>

int main()
{
	long long n, a, b;
	std::cin >> n >> a >> b;
	
	long long c = n / (a + b) * a;
	n %= (a + b);
	c += std::min(n, a);
	
	std::cout << c << std::endl;
	
	return 0;
}


Measured memory_bytes: 3228
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        cout<<"x";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair

int mod = 1e9+7;
int inf = 1e18;
const int N = 3e5+5;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
      int a,b;
      cin>>a>>b;
      rep(i,1,10000000)
      {
          int x = i*(.1);
          int y = i*(.08);
          if(x==b&&y==a)
          {
              cout<<i<<el;
              return 0;
          }
      }
      cout<<-1;


    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define BINF 10000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;

/*
Created at 15:28
*/



#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);



    int n, k, s;
    cin >> n >> k >> s;
    int a[n];
    for(int i = 0; i < k; i++){
        a[i] = s;
    }
    int sum = 0;
    for(int i = k; i < n; i++){
        sum++;
        if(sum == s){
            a[i] = s + 1;
            sum = 0;
            continue;
        }else a[i] = 1;
    }

    for(int i = 0; i < n; i++)
        cout << a[i] << ' ';
    

return 0;
}



Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int h[] =  new int[n];
		
		for(int i=0;i < n ; i++) {
			h[i] = Integer.parseInt(sc.next());
		}
	
		int max = 0;
		int cnt = 0;
		for(int i = 0 ;i < n -1 ; i++) {
			if(h[i] >= h[i+1] ) {
				cnt++;
			}else {
				if (cnt > max) {
					max = cnt;
				}
				cnt = 0;
			}
			if (cnt > max) {
				max = cnt;
			}
		}
		
		System.out.println(max);
	}
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int a,b; cin >>a>>b;

    cout << (a<=b?a:a-1) << endl;
}


Measured memory_bytes: 256
from heapq import heappop, heappush

n, k = map(int, input().split())
a = list(map(int, input().split()))

s = sum(a)
d = []
for i in range(1, int(s**0.5)+1):
    if s % i == 0:
        heappush(d, -i)
        if i != s // i:
            heappush(d, -(s // i))

while len(d) > 0:
    x = - heappop(d)
    r = list(map(lambda b:b%x, a))
    r.sort()
    L = -1
    for i in range(n):
        if r[i] != 0:
            L = i
            break
    if L == -1:
        if k % x == 0:
            print(x)
            exit()
        else:
            continue
    H = n - 1
    temp = r[L] - (x - r[H])
    count = r[L] + (x - r[H])
    L += 1
    H -= 1
    while L <= H:
        if temp <= 0:
            temp += r[L]
            count += r[L]
            L += 1
        else:
            temp -= x - r[H]
            count += x - r[H]
            H -= 1
        if count > 2 * k:
            break
    #print(x, count, temp, L, H)
    if count > 2 * k:
        continue
    if temp % (2 * x) == 0:
        print(x)
        exit()

print(1)

Measured memory_bytes: 3316
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }


int main() {
    int N;
    cin >> N;
    vector<set<pair<int, int>>> graph(N + 1, set<pair<int, int>>());
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        graph[u].insert(make_pair(v, w));
        graph[v].insert(make_pair(u, w));
    }

    vint ans(N + 1, -1);
    ans[1] = 0;
    queue<pair<int, int>> q;
    q.push(make_pair(1, 0));
    while (1) {
        if (q.size() <= 0) {
            break;
        }
        auto nd = q.front();
        q.pop();
        for (auto & adj : graph[nd.first]) {
            if (ans[adj.first] == -1) {
                if ((adj.second + nd.second) % 2 == 0) {
                    ans[adj.first] = 0;
                }
                else {
                    ans[adj.first] = 1;
                }
                q.push(make_pair(adj.first, adj.second + nd.second));
            }
        }
    }

    REP(i, 1, N + 1) {
        cout << ans[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 14848