akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<string>
#define MOD 998244353
#define INF 0x3f3f3f3f
#define eps 1e-4
#define N 210000
#define NUM 2000000
#define CHILD 29
#define DINF 99999999999.9
const double PI=acos(-1.0);
using namespace std;
typedef long long LL;
typedef pair<int,int > P;
int main()
{
	int i,j,n,m,a,b,c;
	scanf("%d",&n);
	a=n%10;
	n/=10;
	b=n%10;
	n/=10;
	c=n;
	if(a==c)
		printf("Yes\n");
	else
		printf("No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout,"");
//copy(v.beg,v.en,outp);
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 
inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
inline ll modpro(ll n,ll m,ll mod){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}
inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
inline ll powmod(ll x,ll y,ll mod){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}
ll min(ll a, ll b){
    if(a>b){
        return b;
    }
    return a;
}
 
ll max(ll a, ll b){
    if(a>b){
        return a;
    }
    return b;
}
bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 
ll power(ll x, ll y, ll mod) 
{ 
    ll res = 1; 
    x = x%mod; 
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % mod; 
  
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll a, ll mod) 
{ 
    return  powmod(a, mod - 2, mod); 
} 
ll modFact(ll n, ll mod) 
{ 
    if (n >=mod) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) %mod; 
  
    return result; 
} 
//cout<<setprecision(9)<<fixed<<sum<<endl; --- precision for double numbers
const int N=1e9 +7;
int main()
{
	int n;
	cin>>n;
	double arr[n];
	forl(i,0,n)cin>>arr[i];
	double dp[n][n+1];
	dp[0][1]=arr[0];
	dp[0][0]=1-arr[0];
	forl(j,2,n+1)
	{
		dp[0][j]=0;
	}
	forl(i,1,n+1)
	{
		dp[i][0]=dp[i-1][0]*(1-arr[i]);
		forl(j,1,n+1)
		{
			
			dp[i][j]=dp[i-1][j-1]*arr[i]+dp[i-1][j]*(1-arr[i]);
		}
		
	}
	double sum=0;
	forl(i,n/2+1,n+1)
	{
		sum+=dp[n][i];
	}
	cout<<setprecision(9)<<fixed<<sum<<endl;
}

Measured memory_bytes: 70528
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    int count = 0;
    if( N == 10 || N == 100 || N ==1000 || N == 10000 || N == 100000 ){
      System.out.println(10);
      return;
    }
    
      while( N > 0 ){
        count += N%10;
        N /= 10;
      }
    System.out.println(count);
  }
}

      

Measured memory_bytes: 23124
[N, A, B] = list(map(int, input().split()))

def main(N, A, B):

    if A == 0:
        return 0
    if B == 0:
        return N
    
    # main
    sumBlue = A * (N // (A + B))

    # amari
    sumBlue += min(A, N % (A + B))

    return sumBlue

if __name__ == "__main__":

    answer = main(N, A, B)
    print(answer)
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int par[100005],n,m,a[100005];
int parent(int x){
    if(par[x]==x)return x;
    return par[x]=parent(par[x]);
}
vector<int>nodes[100005];
int tr[100005];
bool cmp(int x,int y){return nodes[x].size()>nodes[y].size();}
bool cmp1(int x,int y){return a[x]<a[y];}
int main()
{
    cin>>n>>m;
    for(int i=0;i<n;++i){scanf("%d",a+i);par[i]=tr[i]=i;}
    for(int i=0;i<m;++i){
        int u,v;
        scanf("%d%d",&u,&v);
        u=parent(u);
        v=parent(v);
        par[u]=v;
    }
    for(int i=0;i<n;++i){
        int u=parent(i);
        nodes[u].push_back(i);
    }
    long long cost=0;
    sort(tr,tr+n,cmp);
    priority_queue<pair<int,int> >pq;
    for(int i=0;i<n;++i){
        int x=tr[i];
        if(nodes[x].size()==0)break;
        sort(nodes[x].begin(),nodes[x].end(),cmp1);
        if(!pq.empty()){
            int u=pq.top().second;cost+=-pq.top().first;
            pq.pop();
            int v=nodes[x][0];
            cost+=a[v];
            u=parent(u);v=parent(v);
            par[u]=v;
            for(int j=1;j<nodes[x].size();++j)pq.push({-a[nodes[x][j]],nodes[x][j]});
        }
        else{
            for(int j=0;j<nodes[x].size();++j)pq.push({-a[nodes[x][j]],nodes[x][j]});
        }
    }
    int cnt=0;
    for(int i=0;i<n;++i)cnt+=(par[i]==i);
    if(cnt>1)puts("Impossible");
    else cout<<cost<<endl;
}


Measured memory_bytes: 6912
PROGRAM ATCODER

implicit none
integer :: a,b,c

read*, a,b,c

if ( a<b ) then
  if ( c>=a .and. c<=b ) then
    print'(a)', 'Yes'
  else
    print'(a)', 'No'
  end if
else
  if ( c>=b .and. c<=a ) then
    print'(a)', 'Yes'
  else
    print'(a)', 'No'
  end if
end if

END PROGRAM ATCODER


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-5)

using namespace std;

int main(int argc, char *argv[]) {

	long N,D; cin >> N >> D;

	int ans = 0;
	for (int i = 0; i < N; i++) {
		long x,y; cin >> x >> y;
		if (D*D >= (x * x + y * y)) {
			ans++;	
		}
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
int mod = (int) 1e9 + 7;

int main(){
    
    int n;
    long k;
    cin >> n >> k;
    
    vector<int> a(n,0);
    rep(i,n){
        int x;
        cin >> x;
        a[i] = x - 1;
    }
    
    if(k < n){
        int x = 0;
        rep(i,k) x = a[x];
        cout << (x + 1) << "\n";
        return 0;
    }
    
    vector<int> b(n,0);
    int y = 0, count = 0;
    while(1){
        if(b[y] > 0) break;
        b[y] = 1;
        y = a[y];
        count++;
    }
    
    int z = y, loop = 1;
    while(1){
        if(a[z] == y) break;
        z = a[z];
        loop++;
    }
    
    long kk = (k - count) % loop;
    
    rep(i,kk) y = a[y];
    
    cout << (y + 1) << "\n";

    
    return 0;
}


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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}
template<typename T> inline T dmax(T x, T y){return x > y ? x : y;}
template<typename T> inline T dmin(T x, T y){return x < y ? x : y;}

const int MAXN = 2e5 + 5;

int N, a[MAXN], f[MAXN];

int main(){
#ifdef cydiater
	freopen("input.in", "r", stdin);
#endif
	scanf("%d", &N);
	up (i, 1, N) scanf("%d", &a[i]);
	up (i, 1, N) f[a[i]] = f[a[i] - 1] + 1;
	int ans = N;
	up (i, 1, N) cmin(ans, N - f[i]);
	printf("%d\n", ans);
	return 0;
}



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

#define rep(i,begin,end) for(int i=begin;i<=end;i++)
#define repi(i,end,begin) for(int i=end;i>=begin;i--)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long int ll;

#define MAXN 101
#define MAXW 100001

int n,w;
int weight[MAXN];
ll price[MAXN];
ll dp[MAXN][MAXW];

ll sol(int item, int cap){
	if(dp[item][cap] != -1) return dp[item][cap];

	if(cap == 0) return dp[item][cap] = 0;

	if(item == 1){
		if(weight[item] > cap) return dp[item][cap] = 0;
		else return dp[item][cap] = price[item];
	}

	if(weight[item] > cap) return dp[item][cap] = sol(item-1,cap);

	return dp[item][cap] = max(sol(item-1,cap), 1LL*price[item] + sol(item-1,cap-weight[item]));
}

int main(){
fio

cin >> n >> w;

memset(dp,-1,sizeof(dp));

rep(i,1,n){
	cin >> weight[i] >> price[i];
}

cout << sol(n,w) << endl;
return 0;
}

Measured memory_bytes: 79232
n, m, c  = map(int, input().split())
b = [int(i) for i in input().split()]
ans = 0
for i in range(n):
        a = [int(i) for i in input().split()]
        sum = 0
        for k in range(m):
            sum +=(a[k]*b[k])
        sum+=c
        if sum > 0: ans+=1
print(ans)

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

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    int cnt = 0;

    /*for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        for(int z = 0; z <= k; z++){
          if(x+y+z == s)
            cnt++;
        }
      }
    }*/

    for(int x = 0; x <= k; x++){
      for(int y = 0; y <= k; y++){
        int z = s - (x+y);
        if(0 <= z && z <= k)
          cnt++;
      }
    }

    System.out.println(cnt);
  }
}


Measured memory_bytes: 22740
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

int n, k;
int lvl[MAXN];
map<pair<int, int>, bool> was;

int main() {
	//freopen(NAME".in", "r", stdin);
	//freopen(NAME".out", "w", stdout);

	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		lvl[n - i + 1] = i;
	}
	int tt = n - 1;
	while (tt--) {
		int ct = 0;
		was.clear();
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				if (abs(lvl[i] - lvl[j]) == 2 || lvl[i] == lvl[j]) ct++;
			}
		}
		if (ct > k) {
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (ct == k) break;
					if (lvl[i] == lvl[j]) {
						ct--;
						was[mp(i, j)] = 1;
						was[mp(j, i)] = 1;
					}
				}
			}
		}

		if (ct == k) {
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (lvl[i] + 1 == lvl[j] || lvl[i] == lvl[j] + 1) {
						was[mp(i, j)] = 1;
						was[mp(j, i)] = 1;
					}					
				}
			}	
		    vector<pair<int, int>> v;
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (was[mp(i, j)] || was[mp(j, i)]) {
						v.pb(mp(i, j));
						was[mp(i, j)] = was[mp(j, i)] = 0;
					}					
				}
			}
			cout << sz(v) << '\n';
			for (auto i : v) {
				cout << i.F << ' ' << i.S << '\n';
			}
			return 0;			
		}
		int mx = 0;
		for (int i = 1; i <= n; i++) {
			mx = max(mx, lvl[i]);
		}
		for (int i = 1; i <= n; i++) {
			if (lvl[i] == mx) lvl[i]--;
		}
	}
	cout << -1;
	return 0;	
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.lang.Math.*;

public class Main{ 
    
    public static void main(String[] args)throws IOException{
	try{
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br=new BufferedReader(isr);
	String line;
	while((line=br.readLine())!=null){
	    StringTokenizer st=new StringTokenizer(line,",");
	    int[] sta = new int[10];
	    int tra1,tra2;
	    for(int i=0;i<10;i++)
		sta[i]=Integer.parseInt(st.nextToken());
	    tra1=Integer.parseInt(st.nextToken());
	    tra2=Integer.parseInt(st.nextToken());
	    int sum=0;
	    for(int i=0;i<10;i++)
		sum+=sta[i];
	    double t =(double) sum/(tra1+tra2);
	    //	     System.out.println(t+" "+sum);
	    sum=0;
	    for(int i=0;i<10;i++){
		if(tra1*t>sum&&tra1*t<=(sum+sta[i]))
		    System.out.println(i+1);
		sum+=sta[i];
	    }
	}
	}catch(java.lang.NumberFormatException e){
	    System.out.println(e);
	}
	
    }
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    int n, q;
    cin >> n >> q;
    queue<pair<string, int> > robin;
    for(int i=0; i<n; i++){
        string name; int time;
        cin >> name >> time;
        robin.push(make_pair(name, time));
    }
    int sum_time = 0;
    while(!robin.empty()){
        pair<string, int> process = robin.front();
        if(process.second > q){
            process.second -= q;
            sum_time += q;
            robin.pop();
            robin.push(process);
        }else{
            sum_time += process.second;
            robin.pop();
            cout << process.first << " " << sum_time << endl;
        }
    }
}


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

int main(){
    std::string str1;
    std::string str2;

    std::cin >> str1 >> str2;

    str2.pop_back();
    if(str1 == str2){
        std::cout << "Yes";
    }
    else{
        std:: cout << "No";
    }

}

Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>
 

int main(void) {
  
  int i, j;
  int tmp =0;
  
  char str[26];
  
  scanf("%s", str);
  
  for(i = 0; i < strlen(str); i++) {
     for(j = i + 1; j < strlen(str); j++) {
     
     if(str[i] == str[j]) {
     
     tmp = 1;
  }
  
  }
  
  }
  
  if (tmp == 1) {
    printf("no\n");
    
  } else {
    printf("yes\n");
    
  }
  
    return 0;
  }

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int zero = 0;
		int one = 0;
		for(int i = 0; i < str.length(); i++) {
			if(str.substring(i, i + 1).equals("0")) {
				zero++;
			} else {
				one++;
			}
		}
		System.out.println(Math.min(zero, one) * 2);
	}
}


Measured memory_bytes: 30992
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long l, r; cin >> l >> r;
    long long ans = 1e9;
    for (long long i = l; i <= min(r, l+2019); i++) {
        for (long long j = l+1; j <= min(r, l+1+2019); j++) {
            if (i >= j || j > r) continue;
            ans = min(ans, (i*j)%2019);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

while min(a) < n and k > 0:
  mark = [0] * (n + 1)
  for i in range(n):
    mark[max([0, i - a[i]])] += 1
    mark[min([n, i + a[i] + 1])] -= 1
  a = [mark[0]]
  for i in range(1, n):
    a.append(a[-1] + mark[i])
  k -= 1

print(' '.join(map(str, a)))

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	string s;
	char memo[6][6];
	FOR(i, 0, h-1) {
		cin >> s;
		FOR(j, 0, w-1) {
			memo[i][j] = s[j];
		}
	}
	int res = 0;
	for (int bit1 = 0; bit1 < (1 << w); bit1++) {
		for (int bit2 = 0; bit2 < (1 << h); bit2++) {
			int cnt = 0;
			FOR(i, 0, h - 1) {
				FOR(j, 0, w - 1) {
					if (memo[i][j] == '#' && (bit1&(1 << j)) && (bit2&(1 << i))) {
						cnt++;
					}
				}
			}
			if (cnt == k)res++;
		}
	}
	pv(res)
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> xs;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        xs.push_back(x);
        sum += x;
    }

    int best = sum;
    int best_ix = -1;
    for (int i = 0; i < n; i++) {
        int dist = std::abs(sum - xs[i] * n);
        if (dist < best) {
            best = dist;
            best_ix = i;
        }
    }
    std::cout << best_ix << std::endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int a = sc.nextInt();

		if ((h % a) != 0) {
			System.out.println((h / a) + 1);
		} else {
			System.out.println((h / a));
		}

		sc.close();
	}
}

Measured memory_bytes: 35516
package main

import "fmt"

func ExchangeNumber(x, y ,z int) (int, int, int) {
	tmp := x
	x = y
	y = tmp
	tmp = x
	x = z
	z = tmp
	return x, y, z
}

func main()  {
	var x, y, z int
	fmt.Scan(&x, &y, &z)
	fmt.Println(ExchangeNumber(x, y, z))
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int N = 3;
constexpr int N2 = 9;
constexpr int dx[4] = {0, -1, 0, 1};
constexpr int dy[4] = {1, 0, -1, 0};

struct Puzzle {
    int f[N2], z_pos, MD;
    int depth;
    bool operator<(const Puzzle& pz) const {
        rep(i, 0, N2) {
            if (f[i] == pz.f[i]) { continue; }
            return f[i] < pz.f[i];
        }
        return false;
    }
};

struct State {
    Puzzle pz;
    int estimate;
    bool operator<(const State& st) const { return estimate > st.estimate; }
};

void init_MD(vvi& MDT) {
    rep(i, 0, N2) {
        rep(j, 0, N2) { MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N); }
    }
}

int get_md(const Puzzle& pz, const vvi& MDT) {
    int sum = 0;
    rep(i, 0, N2) {
        if (pz.f[i] == N2) { continue; }
        sum += MDT[i][pz.f[i] - 1];
    }
    return sum;
}

int astar(const Puzzle& pz, const vvi& MDT) {
    State init;
    init.pz = pz;
    init.pz.depth = 0;
    init.pz.MD = get_md(init.pz, MDT);
    init.estimate = init.pz.MD;

    priority_queue<State> PQ;
    PQ.push(init);

    map<Puzzle, bool> seen;

    while (!PQ.empty()) {
        State st = PQ.top();
        PQ.pop();

        if (st.pz.MD == 0) { return st.pz.depth; }
        seen[st.pz] = true;

        int sx = st.pz.z_pos % N;
        int sy = st.pz.z_pos / N;

        rep(i, 0, 4) {
            int tx = sx + dx[i];
            int ty = sy + dy[i];
            if (tx < 0 || ty < 0 || tx >= N || ty >= N) { continue; }

            State next = st;
            next.pz.MD -= MDT[ty * N + tx][next.pz.f[ty * N + tx] - 1];
            next.pz.MD += MDT[sy * N + sx][next.pz.f[ty * N + tx] - 1];

            swap(next.pz.f[sy * N + sx], next.pz.f[ty * N + tx]);
            next.pz.z_pos = ty * N + tx;

            if (!seen[next.pz]) {
                ++next.pz.depth;
                next.estimate = next.pz.depth + next.pz.MD;
                PQ.push(next);
            }
        }
    }
    return -1;
}

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

    Puzzle pz;
    rep(i, 0, N2) {
        cin >> pz.f[i];
        if (pz.f[i] == 0) {
            pz.f[i] = N2;
            pz.z_pos = i;
        }
    }

    vvi MDT(N2, vi(N2));
    init_MD(MDT);

    cout << astar(pz, MDT) << endl;
    return 0;
}


Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define int			long long
#define ll 			long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	ll pre[n];
	rep(i,0,n)cin>>a[i];;
	ll suff[n];
	suff[n-1]=a[n-1];
	for(ll i=n-2;i>=0;i--){
		suff[i]=(suff[i+1]+a[i])%hell;
	}	
	pre[0]=a[0];
	rep(i,1,n){
		pre[i]=(pre[i-1]*a[i])%hell;
	}
	ll ans=0;
	for(ll i=0;i<n-1;i++){
		ans=(ans+(a[i]*suff[i+1])%hell)%hell;
	}
	cout<<ans<<endl;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 8380
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main(){
    int n;
    vector<LL> a;
    LL tmp_a;
    LL num_sum_b=0;
    LL num_sum_a=0;
    LL min_num;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        num_sum_b+=tmp_a;
        a.push_back(tmp_a);
    }
    num_sum_b-=a[0];
    num_sum_a+=a[0];
    min_num=abs(num_sum_b-num_sum_a);
    for(int i=1; i<n-1; i++){
        num_sum_b-=a[i];
        num_sum_a+=a[i];
        if(abs(num_sum_b-num_sum_a)<min_num){
            min_num=abs(num_sum_b-num_sum_a);
        }
    }

    cout << min_num << endl;

    return 0;
}


Measured memory_bytes: 2420
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 100010;
const int MAXP = 10000000;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;

int n;
struct node
{
	int x, y;
	bool operator < (const node &A) const
	{
		return x+y > A.x+A.y;
	}
}p[MAXN];

int main()
{
	
	cin >> n;
	for (int i = 1; i <= n; ++ i)
	{
		scanf("%d%d", &p[i].x, &p[i].y);
	}
	sort(p+1, p+n+1);
	
	ll ans = 0;
	for (int i = 1; i <= n; ++ i)
	{
		if (i%2 == 1)
			ans += p[i].x;
		else
			ans -= p[i].y;
	}
	cout << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 1024
# ABC162D - RGB Triplets
def main():
    n=int(input())
    s=input()
    ans=0
    d=[[0]*n for _ in range(3)]
    m=[[0]*n for _ in range(3)]
    l=[[0,2,1],[2,1,0],[1,0,2]]

    for i in range(n):
        d[ord(s[i])%3][i]=1
        m[ord(s[i])%3][i]=1

    for j in range(3):
        for i in range(n-1,0,-1):
            m[j][i-1]+=m[j][i]

    for i in range(n-2):
        for j in range(i+1,n-1):
            if s[i]==s[j]:
                continue
            ans+=m[l[ord(s[i])%3][ord(s[j])%3]][j+1]
            if j*2-i<n:
                ans-=d[l[ord(s[i])%3][ord(s[j])%3]][j*2-i]

    print(ans)
        
main()

Measured memory_bytes: 68556
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18



int main(){
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    int one;
    rep(i,N){
        cin >> A[i];
    }
    int ans = 0;
    if((N-K) % (K-1) == 0) ans = (N-K)/(K-1) + 1;
    else ans = (N-K)/(K-1) + 2;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int x=1,y=1;
	while(1){
		cout << x << "x" << y << "=" << x*y << endl;
		y=y+1;
		if(x==9&&y==10)break;
		else if(y==10){
			y=1;x=x+1;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1116
import sys
from collections import Counter
n = int(input())
x,y,h = [0]*n , [0]*n , [0]*n
q = 0
ze = 0

for i in range(n):
    x[i] ,y[i] ,h[i] = map(int,input().split())
    
ss = Counter(h)
if ss[0] >= n-1:
    ze = 1

for xx in range(101):
    for yy in range(101):
        fl = 1
        a = []
        for i in range(n):
            if h[i] != 0 or ze == 1:
                temp = abs(x[i]-xx) + abs(y[i]-yy) + h[i]
                a.append(temp)
                le = len(a)
                
                if le > 1:
                    if a[le-1] != a[le-2]:
                        fl = 0
                        
        if fl == 1:
            print(xx,yy,max(a))
            sys.exit()

Measured memory_bytes: 44140
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
	double money = 100;
	ll x,count=0;
	cin >> x;
	while (1)
	{
		money += (ll)((ll)money * 0.01);
		count++;
		if (money >= x)
		{
			cout << count << "\n";
			break;
		}
	}
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;
#define ll  long long
#define PI  acos(-1)
#define pb  push_back
#define ins insert
#define INF 5000000000000000007 //1e18+7
#define mk  make_pair
#define ff  first
#define ss  second
#define endl "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a) (ll)a.size()
#define double long double
#define coud(a,b) cout << fixed << setprecision((b)) << (a)
#define mset(x,y)  memset(x,y,sizeof(x))
#define all(x)   (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bp(n)  __builtin_popcountll(n)
#define mxt(a)  *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define trav(a, x)    for(auto &a : x)

const double eps=1e-7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int d8x[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int d8y[8]={+1, 0, -1, +1, -1, +1, 0, -1};
int d4x[4]={1, 0, 0, -1};
int d4y[4]={0, -1, 1, 0};
ll power(ll x,ll y){ll ans=1;x=x;while(y>0){if(y&1)ans=(ans*x);y=y>>1;x=(x*x);}return ans;}
ll sqr(ll x) { return x * x;}

template <typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template <class T> inline void chmax(T &x,T y){ x = max((x), (y));}
template <class T> inline void chmin(T &x,T y){ x = min((x), (y));}
template <class T> T abs(T x) { return x>0 ? x : -x;}
template <typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0) { if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
typedef pair<int,int>  pii;
typedef pair<ll,ll>  pll;
typedef vector<pll>  vpll;
typedef vector<pii>  vpii;
typedef vector<ll>   vll;
typedef vector<int>  vii;
#define minpq priority_queue<T,vector<T>,greater<T> >;
// #define T int
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
//*X.find_by_order(k) returns the kth largest element (0-based).
//X.order_of_key(val) returns the no. of values less than val.
ll ncr(ll n,ll r) {ll ans=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){ans*=(n-i);ans/=(i+1);}return ans;}
const int MOD = 1000000007;   
const int N = 100100;

// 🎲
 string s,t;
int ans = 1e9;
int ok(string now) {
  int cnt = 0;
  for (int i=0; i<sz(t); ++i) {
    if(t[i]!=now[i]) cnt++;
  }
  return cnt;
}
int32_t main() {
  cin.sync_with_stdio(0);cin.tie(0);
  cin.exceptions(cin.failbit);
  
  cin >> s >> t;
  for (int i=0; i<sz(s); ++i) {
    if(i + sz(t) <= sz(s))
     chmin(ans,ok(s.substr(i,sz(t))));
  }
  cout << ans;
  return 0; 
}

/* 
    stuff you shoulds look for
    * int overflow,array bounds.
    * special cases (n=1?).
    * N,MOD value.
*/

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>

#define InputIterator typename
#define RandomAccessIterator typename
#define ForwardIterator typename
#define Predicate typename

template<InputIterator I>
using DifferenceType = typename std::iterator_traits<I>::difference_type;

template<InputIterator I>
using IteratorCategory = typename std::iterator_traits<I>::iterator_category;

template<InputIterator I>
using ValueType = typename std::iterator_traits<I>::value_type;


// distance
template<InputIterator I>
DifferenceType<I> distance(I f, I l, std::input_iterator_tag) {
    // 事前条件: valid_range(f, l)
    DifferenceType<I> n(0);
    while (f != l) {
        ++f;
        ++n;
    }
    return n;
}

template<RandomAccessIterator I>
DifferenceType<I> distance(I f, I l, std::random_access_iterator_tag) {
    // 事前条件: valid_range(f, l)
    return l - f;
}

template<InputIterator I>
DifferenceType<I> mydistance(I f, I l) {
    return distance(f, l, IteratorCategory<I>());
}


// advance
template<InputIterator I>
void advance(I& x, DifferenceType<I> n, std::input_iterator_tag) {
    while (n) {
        --n;
        ++x;
    }
}

template<RandomAccessIterator I>
void advance(I& x, DifferenceType<I> n, std::random_access_iterator_tag) {
    x += n;
}

template<InputIterator I>
void myadvance(I& x, DifferenceType<I> n) {
    advance(x, n, IteratorCategory<I>());
}


// binary search
template<ForwardIterator I, Predicate P>
I partition_point_n(I f, DifferenceType<I> n, P p) {
    while (n) {
        I middle(f);
        DifferenceType<I> half(n >> 1);
        advance(middle, half);
        if (!p(*middle)) {
            n = half;
        } else {
            f = ++middle;
            n = n - (half + 1);
        }
    }
    return f;
}

template<ForwardIterator I, Predicate P>
I mypartition_point(I f, I l, P p) {
    return partition_point_n(f, distance(f, l), p);
}

// lower_bound
template<ForwardIterator I>
I mylower_bound(I f, I l, ValueType<I> a) {
    return mypartition_point(f, l,
            [=](ValueType<I> x) { return x < a; });
}

// upper_bound
template<ForwardIterator I>
I myupper_bound(I f, I l, ValueType<I> a) {
    return mypartition_point(f, l,
            [=](ValueType<I> x) { return x <= a; });
}

int main() {
    int n; std::cin >> n;
    std::vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; ++i) std::cin >> a[i];
    for (int i = 0; i < n; ++i) std::cin >> b[i];
    for (int i = 0; i < n; ++i) std::cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        auto lb = mylower_bound(a.begin(), a.end(), b[i]);
        auto ub = myupper_bound(c.begin(), c.end(), b[i]);

        ans += (long long)mydistance(a.begin(), lb) * mydistance(ub, c.end());
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 1408
use std::io;


fn main() {
    let c = read_one::<String>();
    let vowels = vec!["a", "i", "u", "e", "o"];
    if vowels.contains(&c.as_str()) {
        println!("vowel");
    } else {
        println!("consonant");
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#!/usr/bin/env ruby

n = gets.chomp.to_i

dict = {}
n.times do
  action, str = gets.chomp.split
  str = str.each_codepoint.map{ |i| i - 64 }.join.to_i
  case action
  when 'insert'
    dict[str] = 1
  when 'find'
    puts dict[str] ? 'yes' : 'no'
  end
end

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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define no cout << "No" << endl
#define yes cout << "Yes" << endl
#define tc ll t; cin >> t; while (t--)
#define sz(c) (ll) (c).size()
#define trav(x,c) for(auto &x : c)
#define all(c) (c).begin(), (c).end()
#define rll(c) (c).rbegin(), (c).rend()
#define _for(i,a,n) for(ll i = a ; i < n; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

int main() {
    godspeed;
    string s, t; cin >> s >> t;
    
    ll n = stoll(s), m = stoll(t);
    string x = "", y = "";
    _for(i,0,n) y += t;
    _for(i,0,m) x += s;

    cout << max(stoll(x),stoll(y));
}

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

int main() {
    int n;
    std::cin >> n;

    int taro_score = 0;
    int hanako_score = 0;
    for (int i = 0; i < n; i++) {
        std::string taro_word, hanako_word;
        std::cin >> taro_word >> hanako_word;
        if (taro_word.compare(hanako_word) > 0) {
            taro_score += 3;
        } else if (taro_word.compare(hanako_word) < 0) {
            hanako_score += 3;
        } else {
            taro_score += 1;
            hanako_score += 1;
        }
    }
    std::cout << taro_score << " " << hanako_score << std::endl;
}



Measured memory_bytes: 3232
#include <iostream>

using namespace std;

int paper[10][10];

void init() {
    for (int i = 0; i < 10; i++) 
        for (int j = 0; j < 10; j++) 
            paper[i][j] = 0;
}

void drop_small(int x, int y) {
    paper[y][x]++;
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    for (int i = 0; i < 4; i++) {
        if (y + dy[i] >= 10 || x + dx[i] >= 10) continue;
        if (y + dy[i] < 0  || x + dx[i] < 0 ) continue;
        paper[ y+dy[i] ][ x+dx[i] ]++;
    }
}

void drop_middle(int x, int y) {
    drop_small(x, y);
    int dx[4] = {1, 1, -1, -1}, dy[4] = {1, -1, 1, -1};
    for (int i = 0; i < 4; i++) {
        if (y + dy[i] >= 10 || x + dx[i] >= 10) continue;
        if (y + dy[i] < 0  || x + dx[i] < 0 ) continue;
        paper[ y+dy[i] ][ x+dx[i] ]++;
    }
}
    
void drop_large(int x, int y) {
    drop_middle(x, y);
    int dx[4] = {2, 0, -2, 0}, dy[4] = {0, 2, 0, -2};
    for (int i = 0; i < 4; i++) {
        if (y + dy[i] >= 10 || x + dx[i] >= 10) continue;
        if (y + dy[i] < 0  || x + dx[i] < 0 ) continue;
        paper[ y+dy[i] ][ x+dx[i] ]++;
    }
}

int main() {
    init();
    int x, y, s;
    char d;
    while (cin >> x >> d >> y >> d >> s) {
        switch (s) {
            case 1:
                drop_small(x, y);
                break;
            case 2:
                drop_middle(x, y);
                break;
            case 3:
                drop_large(x, y);
                break;
        }
    }

    int most = 0;
    int clean = 0;

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            if (paper[i][j] == 0) clean++;
            if (paper[i][j] > most) most = paper[i][j];
        }
    }

    cout << clean << endl;
    cout << most << endl;
    
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll n,k;
  cin>>n>>k;
  ll a[n+1]={0};
  while(k--)
  {
    ll d;
    cin>>d;
    while(d--)
    {
      ll b;
      cin>>b;
      a[b]++;
    }
  }
  ll ans=0;
  for(ll i=1;i<=n;i++)
  {
    if(a[i]==0)
      ans++;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 3652
#define taskname ""
#include <bits/stdc++.h>

using namespace std;

const int maxN = 1e5;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d);
    return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    if (n > m) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> x(m), diff(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    adjacent_difference(x.begin(), x.end(), diff.begin());
    diff[0] = -100001;
    sort(diff.begin(), diff.end());
    int ans = accumulate(diff.begin()+1, diff.end()-n+1, 0);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <vector>
#include <iostream>
using namespace std;
 
int main(){
    int w, n,a,b;
    char c;
    vector<int> ans;
    cin >> w >> n;


    for (int i = 0; i <= w; i++) {
       ans.push_back(i);
     }
    for (int i = 0; i < n; i++){
         cin >> a >> c >> b;

         swap(ans[a], ans[b]);
    }
 
    for (int i = 1; i <= w; i++)
    cout << ans[i] << endl;
}

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

class Program
{
    static void Main(string[] args)
    {

        long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        long ninzuu = a[0];
        long kosuu = a[1];

        long[] okasiflag = new long[ninzuu];

        for (int i = 0; i < kosuu; i++)
        {
            long[] b = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            if (b[0] == 0) { continue; }

            long[] c = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();


            for (int j = 0; j < b[0]; j++)
            {
                okasiflag[c[j] - 1] += 1;
            }

        }

        long count = okasiflag.Count(x => x == 0);
        Console.WriteLine(count);


    }
}

Measured memory_bytes: 28828
#!/usr/bin/env python3
import sys
import math

def solve(a: int, b: int, x: int):
    full = a*a*b
    
    if x >= full//2:
        theta = math.atan(2*b/a-2*x/a/a/a)
    else:
        theta = math.atan(a*b*b/x/2)
    
    print(theta*180/math.pi)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    solve(a, b, x)

if __name__ == '__main__':
    main()


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

const int N = 100005;
int n, a[N], b[N];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
        b[i] = a[i];
    }
    sort(b, b + n);
    int result = 0;
    for (int i = 0; i < n; ++i) {
        a[i] = lower_bound(b, b + n, a[i]) - b;
        if (!(i % 2) && a[i] % 2)
            ++result;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

	int x, y; cin >> x >> y;

	if (y % 2 == 0 && y-2*x >= 0 && 4*x - y >= 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll X;
  cin>>X;
  X/=200;
  cout<<10-X<<endl;
  return 0;
} 

Measured memory_bytes: 3624
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    string s;cin>>s;
    rep(i,0,s.size()){
        int t=s[i]-'A';
        t+=n;
        t%=26;
        char c=t+'A';
        cout<<c;
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define VMAX 10000
int n;

void CountingSort(int *A, int *B){
  int i,j;
  int C[VMAX+1];
  
  // init
  for(i=0; i<=VMAX; i++) C[i] = 0;

  // count
  for(j=0; j<n; j++) C[A[j+1]]++;

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

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

}

int main(){
  int *A,*B;
  int i;

  // input and alloc
  scanf("%d",&n);
  A = (int *)malloc(sizeof(int) * n+1);
  for(i=0; i<=n; i++) A[i] = 0;
  B = (int *)malloc(sizeof(int) * n+1);
  for(i=0; i<=n; i++) B[i] = 0;
  for(i=0; i<n; i++) scanf((i == n-1) ? "%d" : "%d ",&A[i+1]);

  // sort
  CountingSort(A,B);

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

  free(A);
  free(B);

  return 0;
}

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

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

    for(int i=0; i<=999; i++){
        string tmp = "";
        if(i < 10 ) tmp += "00";
        else if(i >= 10 && i<=99) tmp += "0";
        tmp += to_string(i);
        int check = 0;
        for(int j=0; j<S.size(); j++){
            if(check == 3) break;
            if(S[j] == tmp[check]) check++;
        }

        if(check == 3) ans++;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  vector<int>d(N),num(N);
  for(int i=0;i<N;i++){
    cin>>d.at(i);
    num.at(i)=i;
  }
  long long sum=0;
  int count=0;
  while(count<N){
    for(int i=count;i<N-1;i++){
      sum+=d.at(count)*d.at(i+1);
      //cout<<count<<" "<<i+1<<endl;
    }
    count++;
  }
  cout<<sum<<endl;
  return 0;
}

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

const int maxn = 100005;

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

int n, m, a[maxn], pos[maxn];

int main()
{
	n = gi(); m = gi();
	int cnt = 0;
	pos[0] = 1; pos[1] = m;
	for (int i = 1; i <= m; ++i) {
		a[i] = gi();
		if (a[i] & 1) {
			if (cnt == 2) return puts("Impossible"), 0;
			pos[cnt++] = i;
		}
	}
	swap(a[1], a[pos[0]]);
	swap(a[m], a[pos[1]]);
	if (m == 1 && a[1] == 1) return puts("1\n1\n1"), 0;
	for (int i = 1; i <= m; ++i) printf("%d ", a[i]);
	if (m == 1) return printf("\n2\n1 %d\n", n - 1), 0;
	printf("\n%d\n%d ", a[m] > 1 ? m : m - 1, a[1] + 1);
	for (int i = 2; i < m; ++i) printf("%d ", a[i]);
	if (a[m] > 1) printf("%d\n", a[m] - 1);
	
	return 0;
}



Measured memory_bytes: 256
use std::io;
fn main() {
    let mut buf = String::new();

    std::io::stdin().read_line(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();

    let a: u32 = iter.next().unwrap().parse().unwrap();
    let b: u32 = iter.next().unwrap().parse().unwrap();

    let ans = if  (a*b)%2 == 1  { "Yes" } else { "No" };
    println!("{}",ans);
}

Measured memory_bytes: 4352