akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using ll=long long;
using P=pair<int,int>;

const int MOD=1e9+7;
const int INF=1<<30;
const int MAX=1e5;

template<class T>
inline void xmin(T &a, T b){a=(a<b)?a:b;}
template<class T>
inline void xmax(T &a, T b){a=(a>b)?a:b;}


int n;
int d[100];
int ans=0;

void solve(){
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>d[i];
    }
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
}

signed main(){
    //while(1)
    solve();
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
    int F => int.Parse(Str);
    long FL => long.Parse(Str);
    int[] G => Strs.Select(int.Parse).ToArray();
    long[] GL => Strs.Select(long.Parse).ToArray();
    string Str => ReadLine();
    string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    const int MOD = 1000000007;
    public K()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        Solve();
        Out.Flush();
    }
    void Solve()
    {
        var cnt = new int[4];
        for (var i = 0; i < 3; i++)
        {
            var I = G;
            cnt[I[0] - 1]++;
            cnt[I[1] - 1]++;
        }
        Array.Sort(cnt);
        WriteLine(cnt[0] == cnt[1] && cnt[1] == 1 && cnt[2] == cnt[3] && cnt[3] == 2 ? "YES" : "NO");
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)==2)
    {
        if(a==0)
        {
            if(b==100)
                printf("%d\n",101);
            else
                printf("%d\n",b);
        }
        if(a==1)
        {
            if(b==100)
                printf("%d\n",10100);
            else
                printf("%d\n",b*100);
        }
        if(a==2)
        {
            if(b==100)
                printf("%d\n",1010000);
            else
                printf("%d\n",b*10000);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)3e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    string s;
    cin>>s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout<<"Yes";
    else cout<<"No";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}


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

using namespace std;

int main()
{
    int n, k, x, y, sum = 0;
    cin >> n >> k >> x >> y;
    
    if(n <= k)
    {
        cout << n * x << endl;
        return 0;
    }
    else
    {
        sum += (k * x);
        sum += ((n - k) * y);
        cout << sum << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	private static final int WHITE = 1;
	private static final int BLACK = 0;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int w = scanner.nextInt(), h = scanner.nextInt(), n = scanner.nextInt();
			int[][] cells = new int[w][h];
			IntStream.range(0, w).forEach(i -> Arrays.fill(cells[i], WHITE));
			IntStream.range(0, n).forEach(i -> {
				int x = scanner.nextInt() - 1, y = scanner.nextInt() - 1, a = scanner.nextInt();
				switch (a) {
				case 1:
					IntStream.rangeClosed(0, x).forEach(j -> Arrays.fill(cells[j], BLACK));
					break;
				case 2:
					IntStream.range(x + 1, w).forEach(j -> Arrays.fill(cells[j], BLACK));
					break;
				case 3:
					IntStream.rangeClosed(0, y).forEach(j -> IntStream.range(0, w).forEach(k -> cells[k][j] = BLACK));
					break;
				case 4:
				default:
					IntStream.range(y + 1, h).forEach(j -> IntStream.range(0, w).forEach(k -> cells[k][j] = BLACK));
					break;
				}
			});
			System.out.println(IntStream.range(0, w).map(i -> Arrays.stream(cells[i]).sum()).sum());
		}
	}
}


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

int main() {
	int A, B, C, D;
	int result;
	cin >> A >> B >> C >> D;
	result = min(B, D) - max(A, C);

	if (result > 0)
		cout << result;
	else
		cout << 0;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
if a==1:
  if b==2:
    c=3
  elif b==3:
    c=2
elif a==2:
  if b==1:
    c=3
  elif b==3:
    c=1
elif a==3:
  if b==1:
    c=2
  elif b==2:
    c=1
print(c)    

Measured memory_bytes: 3060
#include <iostream>
#include <chrono>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

int main() {
	set<int> a{ 1,3,5,7,8,10,12 };
	set<int> b{ 4,6,9,11 };
	set<int> c{ 2 };
	int x, y;
	cin >> x >> y;
	if (a.find(x) != a.end() && a.find(y) != a.end()) {
		cout << "Yes" << endl;
	}
	else if (b.find(x) != b.end() && b.find(y) != b.end()) {
		cout << "Yes" << endl;
	}
	else if (c.find(x) != c.end() && c.find(y) != c.end()) {
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	int n, x;
	cin>>n>>x;
	int w[n];
	int v[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>w[i];
		cin>>v[i];
	}
	int dp[n+1][x+1];
	for (int i = 0; i < n+1; ++i)
	{
		dp[i][0]=0;

	}
	for (int i = 0; i < x+1; ++i)
	{
		dp[0][i]=0;
	}
	for (int i = 1; i < n+1; ++i)
	{
		for(int j=1; j<x+1; j++)
		{
			if(w[i-1]<=j)
			{
				dp[i][j]= max(v[i-1]+dp[i-1][j-w[i-1]], dp[i-1][j]);
			}
			else
				dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][x];

}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
    cin>>a;
    if(int(a.find('C'))!=-1 and int(a.rfind('F'))!=-1 and a.find('C')<a.rfind('F'))
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n,m,tmp;vector <int> a;vector <int> b;
bool solve(int num,int sum)
{
    if(num>n) return 0;
    else if(a[num]>sum) return solve(num+1,sum);
    else if(sum==0) return 1;
    else return solve(num+1,sum-a[num])+solve(num+1,sum);
};
int main()
{

    cin>>n;for(int i=0;i<n;i++) {cin>>tmp;a.push_back(tmp);}
    cin>>m;for(int i=0;i<m;i++) {cin>>tmp;b.push_back(tmp);}

    for(auto i=b.begin();i!=b.end();i++)
        cout<<(solve(0,*i)?"yes":"no")<<endl;
return 0;
    }



Measured memory_bytes: 3164
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [n, k] = nextIntArray()
    let a = nextIntArray()
    let ans = ""
    for (let i = k; i < n; i++) {
        if (a[i-k] < a[i]) {
            ans += "Yes\n"
        } else {
            ans += "No\n"
        }
    }
    console.log(ans)
}
Main()




Measured memory_bytes: 54324
import java.awt.Color;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//???
		int b = sc.nextInt();//???
		String c[] = new String[a];
		for(int i=0;i<a;i++){c[i] = sc.next();}//?????? ??£??\
		for(int i=0;i<a;i++){
			int t = -1;
			for(int j=0;j<b;j++){
				if(j != 0){System.out.print(" ");}
				if(c[i].charAt(j) == 'c'){	
					t = 0;
					System.out.print(t);
					}
				else if(t != -1){t = t+1;System.out.print(t);}
					else{System.out.print(t);}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 35264
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using pll = pair<ll,ll>;
using vll = vector<pll>;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    string s; cin >> s;
    if (s[0]=='7' or s[1]=='7' or s[2]=='7') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

const int mod =1000000007;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back

template<typename T, typename U>
inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U>
inline void amax(T &x, U y) { if(x < y) x = y; }

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

int main(){
	int n;
	cin>>n;
	vi h(n);
	for(auto & ht:h)
	cin>>ht ;
	vi cost(n);
	cost[0]=0;
	cost[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;++i){
		cost[i]=min(abs(h[i]-h[i-1])+cost[i-1],abs(h[i]-h[i-2])+cost[i-2]);
	}
	cout<<cost[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
 
public class Main
{
 
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
 
		int age = Integer.parseInt(sc.next());
 		int b = Integer.parseInt(sc.next());
		
      	if(age>=13){
          System.out.println(b);
        }else if(age<=5){
          System.out.println("0");
        }else{
          System.out.println(b/2);
        }
	}
}

Measured memory_bytes: 21844
/*
Looking from a window above
It's like a story of love
Can you hear me?
Came back only yesterday
I'm moving further away
Want you near me
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you
Sometimes when I think of her name
When it's only a game
And I need you
Listen to the words that you say
It's getting harder to stay
When I see you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you
Uh uh uh only you, only you
Only you, only you, only you
This is going to take a long time
And I wonder what's mine
Can't take no more
Wonder if you'll understand
It's just the touch of your hand
Behind a closed door
And all I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
Only you
*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) ((int)(x.size()))
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 3e18;
const int N = 5e5 + 100;




int32_t main(){ 
   FAST;
   int a, b;
   cin >> a >> b;
   b *= 2;
   a = max(0LL, a - b);
   cout << a << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            var oneLine = Console.ReadLine();

            StringBuilder strs = new StringBuilder();
            for (int i = 0; i < oneLine.Length; i++)
            {
                if (char.IsUpper(oneLine[i]))
                {
                    strs.Append(char.ToLower(oneLine[i]));
                }
                else if(char.IsLower(oneLine[i]))
                {
                    strs.Append(char.ToUpper(oneLine[i]));
                }
                else
                {
                    strs.Append(oneLine[i]);
                }
            }

            Console.WriteLine(strs.ToString());
        }
    }
}



Measured memory_bytes: 15820
N = int(input())
B = list(map(int, input().split()))

res = 0
for i in range(N):
  if i == 0:
    res += B[0]
  elif i == N-1:
    res += B[N-2]
  else:
    res += min(B[i-1], B[i])

print(res)

Measured memory_bytes: 3064
N,M = gets.split.map(&:to_i)
enred = Array.new(N+1, false)
enred[1] = true
nums = Array.new(N+1,1)
M.times{
  x,y = gets.split.map(&:to_i)
  nums[x] -= 1
  nums[y] += 1
  if enred[x]
    enred[y] = true
  end
  if nums[x] == 0
    enred[x] = false
  end
}

p enred.count(true)

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,a[N],ans;

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)
    if(a[a[i]-1]==i+1)ans++;
  cout<<ans/2<<endl;
  return 0;
}


Measured memory_bytes: 768
{-# LANGUAGE LambdaCase #-}

import           Data.Either
import           Data.Maybe

import qualified Data.Array.IArray   as I
import qualified Data.Array.MArray   as M

import           Data.Array.IO       (IOArray)
import           Data.Array.ST       (STArray)

import qualified Data.List           as L

import           Data.Bifunctor
import           Data.Function
import           Data.Monoid

import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Functor

main :: IO ()
main = do
    n <- read <$> getLine
    ls <- getSeq
    print $ solve ls n

getSeq :: Read a => IO [a]
getSeq = map read . words <$> getLine

solve :: [Int] -> Int -> Int
solve ls n = runST $ do
    sticks <- M.newArray (1, 100) (Right 0) :: ST s (STArray s Int (Either Int Int))
    forM_ ls $ \l ->
      M.readArray sticks l
      >>= M.writeArray sticks l . either (Right . (l +)) Left

    xs <- M.getAssocs sticks
    return . getSum $
      (foldMap (either Sum Sum . snd) xs)
      <>
      (foldMap (Sum . fst . snd) . filter ((0 ==) . fst) . zip (cycle [0, 1]) $ filter (isLeft . snd) xs)


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int H, W; cin >> H >> W;
	int N; cin >> N;
	vector<int> res;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		while (a--) {
			res.push_back(i+1);
		}
	}
	for (int i = 0; i < H; i++) {
		vector<int> v(res.begin() + i * W, res.begin() + (i+1) * W);
		if (i & 1) reverse(v.begin(), v.end());
		for (int j = 0; j < W; j++) {
			cout << v[j] << " \n"[j+1==W];
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
const int N=1e5+5;
int n,val[N];

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

template <class T> bool gcmp(const T a,const T b){
	return a>b;
}

inline bool jdg(){
	int x=1,y=1,lim_x;
	for(; x<n&&y+1<=val[x+1]; ++x,++y);
	if((val[x]-y)&1) return 1;
	for(lim_x=x; val[lim_x+1]>=y; ++lim_x);
	return (lim_x-x)&1;
}

int main(){
	n=nxi();
	for(int i=1; i<=n; ++i){
		val[i]=nxi();
	}
	std::sort(val+1,val+n+1,gcmp<int>);
	puts(jdg()?"First":"Second");
	return 0;
}

Measured memory_bytes: 640
n, m = map(int, input().split())
x = list(map(int, input().split()))

if len(x) <= n:
    print('0')
else:
    x_sorted = sorted(x,reverse = True)
    x_dif = list()
    for i in range(m-1):
        x_dif.append(x_sorted[i] - x_sorted[i+1])
    x_dif.sort()
    ans = 0
    for i in range(m-n):
        ans += x_dif[i]
    print(int(ans))

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

 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_LONG_MAX;
const double EPS=0.00001;

int main(){
    string SS;
    cin>>SS;
    LL N=SZ(SS);
    LL res=N*(N-1LL)/2LL+1LL;
    vector<LL>vec[26];
    REP(i,N)vec[SS[i]-'a'].PB(i);
    REP(i,26)if(SZ(vec[i])>1){
        LL N2=SZ(vec[i]);
        res-=N2*(N2-1LL)/2LL;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	vector<int> a(n); rep(i,n) cin >> a[i];
	int ans = 0, now = 1;;
	for(int i = 0; i < n; ++i) {
		if(a[i] == now) {
			++now;
		} else {
			ans++;
		}
	}
	if(ans == n) {
		cout << -1 << '\n';
	} else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int main(){

    int n;
    cin >> n;

    bool ans = false;

    rep(i,9){
        int div = n / (i + 1);
        if(n % (i + 1) == 0 && 1 <= div && div <= 9){
            ans = true;
            break;
        }
    }

    cout << (ans ? "Yes": "No") << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
A.append(0)
a = 0
cost = 0
for i in A:
    b = i
    cost += abs(a-b)
    a = b
cost += abs(A[-1])

ori = cost
for i in range(1, len(A)-1):
    cost += abs(A[i-1]-A[i+1])
    cost -= abs(A[i-1]-A[i])+abs(A[i+1]-A[i])
    print(cost)
    cost  = ori

Measured memory_bytes: 13920
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;
pair<pair<string,int>,int> p[110];

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

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

  return 0;
}

Measured memory_bytes: 256
/*****include*****/
#include <iostream>
#include <fstream>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/
int number[5];

/*****その他関数置き場*****/
void Q_sort(int left,int right){
	int threshold = (number[left] + number[right])/2;
	int i;
	int j;
	i = left;
	j = right;
	do{
		while(number[i] < threshold)	i++;
		while(number[j] > threshold)	j--;
		if(i <= j){
			int swap = number[i];
			number[i] = number[j];
			number[j] = swap;
			i++;
			j--;
		}
	}while(i <= j);
	if(j > left)	Q_sort(left,j);
	if(i < right)	Q_sort(i,right);
}
/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return;
	}
#endif
	/*****変数置き場*****/
	for(int i=0;i<5;i++)	cin >> number[i];
	Q_sort(0,4);
	for(int i=0;i<5;i++){
		cout << number[4-i];
		if(i==4)	cout << endl;
		else		cout << " ";
	}
	/*****処理部*****/

	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

Measured memory_bytes: 1160
n, c = map(int, input().split())

lx, lv = [], []

for _ in range(n):
    tmpx, tmpv = map(int, input().split())
    lx.append(tmpx)
    lv.append(tmpv)

lux = [c-x for x in reversed(lx)]

#両方向の累積和
tmpv1, tmpv2 = 0,0
vc, vuc = [],[]
for i in range(n):
    tmpv1 += lv[i]
    tmpv2 += lv[n-1-i]
    _ = [x.append(y) for x,y in zip([vc,vuc],[tmpv1,tmpv2])]

sc, suc = [],[]
tmp1,tmp2 = 0,0
for i in range(n):
    sc.append(vc[i] - lx[i])
    suc.append(vuc[i] - (c - lx[n-1-i]))

ssc,ssuc = [],[]
tmp,tmpu = -c, -c
for i in range(n):
    tmp = max(tmp, sc[i])
    tmpu = max(tmpu, suc[i])
    ssc.append(tmp)
    ssuc.append(tmpu)
ans = 0

for i in range(n):
    s1 = sc[i]
    s2 = suc[i]
    if i == n-1:
        s3,s4 = 0,0
    else:
        s3 = s1 - lx[i] + ssuc[max(0,n-i-2)]
        s4 = s2 - lux[i] + ssc[max(0,n-i-2)]

    ans = max(ans,s1,s2,s3,s4)

print(ans)

Measured memory_bytes: 34040
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int N, K;
string S;

int main() {
    cin >> N >> S >> K;
    string ans = "";

    for (int i = 0; i < N; i++){
        if (S[i] == S[K-1]) ans += S[K-1];
        else ans += '*';
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
import scala.annotation.tailrec
import scala.io.StdIn._
object Main extends App {

  loop()
  @tailrec def loop(): Unit = {
    val Array(n, k) = readLine.trim.split(' ').map(_.toLong)
    if (n == 0 && k == 0) return
    println(count(n - 1, k))
    loop()
  }
  def count(rest: Long, k: Long, digit: Int = 1): String = {
    val d = countDigit(digit)
    if (d * digit >= rest) makeString(rest % digit, k, power(10, digit - 1) + rest / digit)
    else count(rest - d * digit, k, digit + 1)
  }
  def makeString(rest: Long, k: Long, start: Long): String = {
    (start to start + k).mkString.substring(rest.toInt, rest.toInt + k.toInt)
  }
  def countDigit(digit: Int): Long = {
    power(10, digit) - power(10, digit - 1)
  }
  def power(base: Long, exp: Int): Long = {
    exp match {
      case 0 ⇒ 1L
      case 1 ⇒ base
      case _ ⇒ power(base * base, exp / 2) * power(base, exp % 2)
    }
  }
}


Measured memory_bytes: 45148
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"


int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	ll A,B,M,ac=1e12,ak=ac;
	cin>>A>>B>>M;
	ll a[A+1],b[B+1];
	for(ll i=1;i<=A;i++){
		cin>>a[i];
		ac=min(a[i],ac);
	}
	for(ll i=1;i<=B;i++){
		cin>>b[i];
		ak=min(ak,b[i]);
	}
	ll max=ak+ac;
	while(M--)
	{
		cin>>x>>y>>z;
		k=a[x]+b[y]-z;
		max=min(k,max);
		
	}
	cout<<max;
}


Measured memory_bytes: 5208
n, k = [int(i) for i in input().split()]
s = input()

status = s[0]
cnt = 1
sa = []
for i in range(1, n):
    if s[i] != status:
        sa.append(status * cnt)
        cnt = 0
        status = s[i]
    cnt += 1
sa.append(status * cnt)

for i in range(1, min(k*2, len(sa)), 2):
    sa[i] = ("R" if sa[i][0] == "L" else "L") * len(sa[i])

sa = ''.join(sa)

ans = 0
for i in range(n):
    if sa[i] == "L":
        if i > 0: 
            if sa[i-1] == "L": ans += 1
    else:
        if i < n-1:
            if sa[i+1] == "R": ans += 1

print(ans)

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

int main(){
    int n;
    cin >> n;
    int l[n];
    rep(i,n) cin >> l[i];
    sort(l,l+n);
    int ans = 0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            auto iter = lower_bound(l,l+n,l[i]+l[j]);
            int x = iter-l-j-1;
            ans+=x;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100000+5
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(int &f){
	f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
char s[DMAX];
int n,q;
int pre[DMAX];
int cnt=0;
int main(){
    read(n),read(q);
    scanf("%s",s+1);
    int ls=strlen(s+1);
    for(int i=2;i<=ls;i++){
        pre[i]=pre[i-1];
        if(s[i]=='C' && s[i-1]=='A'){
            pre[i]++;
        }
    }
//    for(int i=1;i<=ls;i++){
//        cout<<pre[i]<<" ";
//    }
//    cout<<endl;
    int x,y;
    for(int i=1;i<=q;i++){
        read(x),read(y);
        cout<<pre[y]-pre[x]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1280
use std::io;

fn main() {
    let mut terminal_input = String::new();
    io::stdin().read_line(&mut terminal_input).expect("Failed to read line");
    let terminal_input: i32 = terminal_input.trim().parse().expect("Type error");

    let terminal_output = terminal_input.pow(3);

    println!( "{}", terminal_output );
}



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











#define rep(i,n) for(int i=0;n>i;++i)
#define MOD 1000000007
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
//最大公約数
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
//最小公倍数
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
bool prime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0)
        return false;
    }
    return true;
}
int main(){
    ll n;
    cin>>n;
    stack<ll> q;
    for(int i=0;n>0;i++){
        n--;
        q.push(n%26);
        n/=26;
    }
    int size=q.size();
    for(int i=0;size>i;i++){
        char s='a';
        s+=q.top();
        q.pop();
        cout<<s;
    }
}

Measured memory_bytes: 3632
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

if N==1:
  print(1)
  exit()

from itertools import permutations
from collections import Counter
l = [((A[0]-B[0]),(A[1]-B[1])) for A,B in permutations(XY,2)]
c = Counter(l)
print(N - c.most_common()[0][1] )

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

using namespace std;

template <typename T> string toString(const T& t) {
    ostringstream os; os << t; return os.str();
}

int main(void) {
    int n;
    string s, ns;
    while (cin >> n, n) {
        cin >> s;

        for (int i = 0; i < n; i++) {
            ns = "";
            for (int j = 0; j < s.size(); ) {
                int k = j;
                while (k < s.size() && s[k] == s[j]) k++;
                ns += toString(k - j) + s[j];
                j = k;
            }
            s = ns;
        }

        cout << s << endl;
    }

    return 0;
}


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

void input(int& rnLimit, vector<llong>& rvnCostA, vector<llong>& rvnCostB)
{
  int nCostASiz, nCostBSiz;
  cin >> nCostASiz >> nCostBSiz >> rnLimit;
  rvnCostA.resize(nCostASiz + 1);
  rvnCostB.resize(nCostBSiz + 1);

  for (int i = 1; i < rvnCostA.size(); i++)
  {
    int nOneCost;
    cin >> nOneCost;
    rvnCostA[i] = rvnCostA[i - 1] + nOneCost;
  }

  for (int i = 1; i < rvnCostB.size(); i++)
  {
    int nOneCost;
    cin >> nOneCost;
    rvnCostB[i] = rvnCostB[i - 1] + nOneCost;
  }
}

int calcMaxSelect(int nLimit, const vector<llong>& cnrvnCostA, 
                              const vector<llong>& cnrvnCostB)
{
  int nMaxSelCnt = 0;
  int nBgnB = cnrvnCostB.size() - 1;
  int nxA = 0;

  while ( nxA < cnrvnCostA.size()  &&
          cnrvnCostA[nxA] <= nLimit   )
  {
    int nxB = nBgnB;

    while ( cnrvnCostB[nxB] > nLimit - cnrvnCostA[nxA] )
      nxB--;

    nMaxSelCnt = max(nMaxSelCnt, nxA + nxB);
    nBgnB = nxB;

    nxA++;
  }
  return nMaxSelCnt;
}
 
int main()
{
  int nLimit;
  vector<llong> vnCostA, vnCostB;

  input(nLimit, vnCostA, vnCostB);
  cout << calcMaxSelect(nLimit, vnCostA, vnCostB) << endl;

  return 0;
}

Measured memory_bytes: 6356
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static long ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] s = new int[M];
		int[] c = new int[M];

		for(int i = 0;i<M ; i++) {
			s[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}

		ans = -1;
		int start = 0;
		int end = 0;
		if(N==1) {
			start=0;
			end = 9;
		}else if(N==2) {
			start=10;
			end=99;
		}else {
			start=100;
			end=999;
		}

		for(int i = start;ans==-1&&i<=end ; i++) {
			for(int j = 0;j<M ; j++) {
				if(String.valueOf(i).charAt(s[j]-1)==(String.valueOf(c[j]).charAt(0))) {
					if(j==M-1) {
						ans=i;
						break;
					}
				}else {
					break;
				}
			}
		}

		if(M==0) {
			ans = start;
		}


		System.out.println(ans);
	}

	//素数判定
	public static boolean isPrime(long num) {
		if (num < 2) return false;
		else if (num == 2) return true;
		else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

		double sqrtNum = Math.sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2)
		{
			if (num % i == 0)
			{
				// 素数ではない
				return false;
			}
		}

		// 素数である
		return true;
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


Measured memory_bytes: 35404
N, Y = map(int, input().split())
l = []
flag = False
for i in range(N+1):
    for j in range(N-i+1):
        if 10000 * i + 5000 * j + 1000 * (N-i-j) == Y:
            l = [i, j, N-i-j]
            flag = True
        if flag:
            break
if flag:
    print(*l)
else:
    print(-1, -1, -1)

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
#include <cassert>
#include <complex>
using namespace std;
//#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> Q;

struct edge
{
    int to;
    ll cost;
};

vector<edge>g[105];
int main() {
    int n,m;
    cin>>n>>m;
    map<pair<int,int>,int>mp;
    set<int>ans;
    for(int i=0;i<m;i++){
        int a,b;
        ll c;
        cin>>a>>b>>c;
        a--;
        b--;
        g[a].push_back({b,c});
        g[b].push_back({a,c});
        pair<int,int> p = make_pair(a,b);
        mp[p]=i;
    }
    for(int st=0;st<n;st++){
        for(int go=st+1;go<n;go++){
            vector<ll>dist(n,(ll)INF);
            vector<bool>visited(n);
            vector<int>prever(n,-1);
            priority_queue<P,vector<P>,greater<P>>pq;
            dist[st]=0;
            pq.push(P(st,0));
            while(!pq.empty()){
                P p = pq.top();
                pq.pop();
                int now = p.first;
                int d = p.second;
                if(dist[now]<d)continue;
                for(int i=0;i<g[now].size();i++){
                    edge e = g[now][i];
                    int to = e.to;
                    ll cost = e.cost;
                    if(dist[to]>dist[now]+cost){
                        dist[to]=dist[now]+cost;
                        prever[to]=now;
                        pq.push(P(to,dist[to]));
                    }
                }
            }
            int t = go;
            for(;t!=-1;t=prever[t]){
                int v = prever[t];
                pair<int,int> p1 = make_pair(v,t);
                pair<int,int> p2 = make_pair(t,v);
                if(mp.find(p1)!=mp.end()){
                    ans.insert(mp[p1]);
                    continue;
                }
                if(mp.find(p2)!=mp.end()){
                    ans.insert(mp[p2]);
                    continue;
                }
            }
        }
    }
    cout<<m-ans.size()<<endl;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e2+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int a[maxn][maxn],n,m,vis[maxn][maxn];
int head[maxn<<1],tot,dis[maxn<<1],s,t;
struct edge{int to,nxt,w;}e[100050];

void add(int u,int v,int w) {e[++tot]=(edge){v,head[u],w},head[u]=tot;}

void ins(int u,int v,int w=1) {add(u,v,w),add(v,u,0);}

int bfs() {
    memset(dis,-1,sizeof dis);
    queue<int > q;q.push(s),dis[s]=1;
    while(!q.empty()) {
        int x=q.front();q.pop();
        for(int i=head[x];i;i=e[i].nxt)
            if(e[i].w&&dis[e[i].to]==-1) {
                dis[e[i].to]=dis[x]+1;
                if(e[i].to==t) return 1;
                q.push(e[i].to);
            }
    }return 0;
}

int dfs(int x,int f) {
    if(x==t) return f;
    int used=0;
    for(int i=head[x];i;i=e[i].nxt)
        if(e[i].w&&dis[e[i].to]==dis[x]+e[i].w) {
            int d=dfs(e[i].to,min(f,e[i].w));
            e[i].w-=d,e[i^1].w+=d,f-=d,used+=d;
            if(!f) break;
        }
    if(!used) dis[x]=-1;
    return used;
}

int dinic() {
    int flow=0;
    while(bfs()) flow+=dfs(s,inf);
    return flow;
}

int main() {
    read(n),read(m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++) read(a[i][j]);
    for(int j=1;j<=m;j++) {
        s=n*2+1,t=s+1,tot=1;memset(vis,0,sizeof vis);
        for(int i=1;i<=t;i++) head[i]=0;
        for(int i=1;i<=n;i++)
            for(int k=j;k<=m;k++) {
                int c=(a[i][k]-1)/m+1;
                if(!vis[i][c]) vis[i][c]=tot+1,ins(i,c+n);
            }
        for(int i=1;i<=n;i++) ins(s,i),ins(i+n,t);
        dinic();
        for(int i=1;i<=n;i++)
            for(int k=1;k<=n;k++)
                if(vis[i][k]&&!e[vis[i][k]].w) {
                    for(int x=j;x<=m;x++) if((a[i][x]-1)/m+1==k) {swap(a[i][j],a[i][x]);break;}
                    break;
                }
    }
    for(int i=1;i<=n;i++,puts(""))
        for(int j=1;j<=m;j++) printf("%d ",a[i][j]);
    for(int i=1;i<=n;i++,puts("")) 
        for(int j=1;j<=m;j++) 
            for(int x=1;x<=n;x++) if((a[x][j]-1)/m+1==i) {printf("%d ",a[x][j]);break;}
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

int eliminate(vector< vector<int> > a, int n, int m){
    vector<int> sports(m, 0);
    int ret = 300;
    repp(k, m){
        rep(n){
            int j = 0;
            while(sports[a[i][j]] == -1) j++;
            sports[a[i][j]]++;
        }
        int max_sport = max_element(all(sports)) - sports.begin();
        ret = min(ret, sports[max_sport]);
        rep(m){
            if(sports[i] == -1 || i == max_sport) sports[i] = -1;
            else sports[i] = 0;
        }
    }
    return ret;
}

signed main(){
    int n,m;
    cin >> n >> m;
    vector< vector<int> > a(n, vector<int>(m));
    rep(n){
        repp(j, m){
            cin >> a[i][j];
            a[i][j]--;
        }
    }

    cout << eliminate(a, n, m);
}


Measured memory_bytes: 1024
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import Counter

N = map(int,readline())
S = [''.join(sorted(x.decode('utf-8'))) for x in read().split()]

counter = Counter(S)

answer = sum(x*(x-1)//2 for x in counter.values())
print(answer)

Measured memory_bytes: 21672
# 数値の取得
N = int(input())

# 1~9の積で表現できるか検査
cnt = 1
judge = ("No")
for cnt in range(1,10,1):
    if N // cnt <10\
    and N % cnt == 0:
        judge = ("Yes")
        break

# 結果を出力
print(judge)

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

#define MOD 1000000007;

int main(){
	int n;
	cin >> n;
	cout << (n+110)/111*111 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n, a, c, mn=1e9;
int main() {
	cin>>n;
	while(n--) {
		cin>>a;
		for(c=0; a%2==0; a/=2) c++;
		mn = min(mn, c);
	}
	cout<<mn;
	return 0;
}


Measured memory_bytes: 256
import bisect
import io
import sys

LINES = sys.stdin.read().splitlines()[::-1]


def readline():
    return LINES.pop()


A, B, Q = map(int, readline().split())
ss = [int(readline()) for _ in range(A)]
ts = [int(readline()) for _ in range(B)]
xs = [int(readline()) for _ in range(Q)]

ss.sort()
ts.sort()
for x in xs:
    i = bisect.bisect_left(ss, x)
    s1 = ss[i - 1] if 0 < i else -(10 ** 20)
    s2 = ss[i] if i < A else 10 ** 20
    i = bisect.bisect_left(ts, x)
    t1 = ts[i - 1] if 0 < i else -(10 ** 20)
    t2 = ts[i] if i < B else 10 ** 20

    # s1 < x < s2
    # t1 < x < t2
    print(min(
        x - min(s1, t1),  # s1, t1
        2 * (x - s1) + (t2 - x),  # s1, t2
        2 * (t2 - x) + (x - s1),  # t2, s1
        2 * (s2 - x) + (x - t1),  # s2, t1
        2 * (x - t1) + (s2 - x),  # t1, s2
        max(s2, t2) - x,  # s2, t2
    ))


Measured memory_bytes: 154908
//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1e4 + 5;
const int OO = 2e9;

int h,w,n,a[N],ans[101][101];

void init() {



}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> h >> w >> n;

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

        cin >> a[i];

    }

    int cur = 0;

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

        if(i&1) {

            for (int j = 0; j < w; ++j) {

                if (!a[cur]) ++cur;
                ans[i][j] = cur + 1;
                a[cur]--;

            }

        } else {

            for (int j = w-1; j >= 0; --j) {

                if (!a[cur]) ++cur;
                ans[i][j] = cur + 1;
                a[cur]--;

            }

        }

    }

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

        for(int j=0;j<w;++j) {

            cout << ans[i][j] << ' ';

        }

        cout << '\n';

    }

    return 0;

}

Measured memory_bytes: 384
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <utility>
using namespace std;

int main() {
	long long int N,K;
	cin >> N>>K;
	vector<long long int>h(N);
	for (auto& i : h)cin >> i;
	sort(h.begin(), h.end());
	long long int min_diff = *max_element(h.begin(), h.end());
	for (int i = 0; i < N-K+1; i++) {
		if (min_diff >h[i + K-1] - h[i])min_diff = h[i + K-1] - h[i];
	}
	cout << min_diff << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define task "D-Built"
#define nmax 100005
#define S second
#define F first
#define reset(x) memset(x,0,sizeof(x))
#define len(s) int(s.length())
#define endl '\n'
#define oo 1000000009
#define rank rankk

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii, int> piii;
pii x[nmax], y[nmax];

vector <int> a[nmax];
int dem = 0, par[nmax], rank[nmax], n;
long long res;
struct data
{
    int u,v,w;
};

bool cmp(data x, data y)
{
    return x.w < y.w;
}

data edge[2 * nmax];

int root(int u)
{
    if (par[u] != u) par[u] = root(par[u]);
    return par[u];
}


bool isJoint(int u, int v)
{
    u = root(u); v = root(v);
    if (u == v) return false;
    if (rank[u] == rank[v]) rank[u]++;
    if (rank[u] < rank[v]) par[u] = v;
    else par[v] = u;
    return true;
}

void init()
{
    // tao dsk
    sort(x+1,x+n+1);
    sort(y+1,y+n+1);
    for (int i = 1; i < n; i++)
        edge[++dem] = {x[i].S , x[i+1].S, abs(x[i].F - x[i+1].F)};
    for (int i = 1; i < n; i++)
        edge[++dem] = {y[i].S , y[i+1].S, abs(y[i].F - y[i+1].F)};
    sort(edge+1,edge+dem+1,cmp);

    for (int i = 1; i <= n; i++)
        par[i] = i, rank[i] = 0;
}

void solve()
{
    // tim Minimum Spanning Tree
    for (int i = 1; i <= dem; i++)
    {
        if (isJoint(edge[i].u , edge[i].v))
        {
            res += edge[i].w;
        }
    }
    cout << res;
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    cin >> n;
    for (int u,v,i = 1; i <= n; i++)
    {
        cin >> u >> v;
        x[i] = {u,i};
        y[i] = {v,i};
    }
    init();
    solve();

}


Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
#define int long long

int32_t main()
{
    int a,b,c,d;cin>>a>>b>>c>>d;
    int lcd=(c*d)/__gcd(c,d);
    int xac=(a-(a%c)+c)/c,xad=(a-(a%d)+d)/d,xbc=(b-(b%c))/c,xbd=(b-(b%d))/d,xacd=(a-(a%lcd)+lcd)/(lcd),xbcd=(b-(b%(lcd)))/(lcd);
    if(a%c==0)
    {
        xac=(a-(a%c))/c;
    }
    if(a%d==0)
    {
        xad=(a-(a%d))/d;
    }
    if(a%(lcd)==0)
    {
        xacd=(a-(a%(lcd)))/(lcd);
    }
    int sub=0;
    sub+=((xbc-xac)+(xbd-xad)-(xbcd-xacd));
    cout<<(b-a)-sub;
}


Measured memory_bytes: 256